This commit is contained in:
Fabian Keller 2017-06-18 00:01:27 +02:00 • committed by Andreas Rumpf
commit b189b24a4f
5 changed files with 28 additions and 2 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
nimcache/ nimcache/
/tests/tester

View file

@ -47,12 +47,18 @@ proc tcall2(n, tmpContext: NimNode): NimNode =
assert n.len == result.len assert n.len == result.len
if L > 0: if L > 0:
result[L-1] = tcall2(result[L-1], tmpContext) result[L-1] = tcall2(result[L-1], tmpContext)
of nnkStmtList, nnkStmtListExpr, nnkWhenStmt, nnkIfStmt, nnkCaseStmt, of nnkStmtList, nnkStmtListExpr, nnkWhenStmt, nnkIfStmt, nnkTryStmt,
nnkTryStmt, nnkFinally: nnkFinally:
# recurse for every child: # recurse for every child:
result = copyNimNode(n) result = copyNimNode(n)
for x in n: for x in n:
result.add tcall2(x, tmpContext) result.add tcall2(x, tmpContext)
of nnkCaseStmt:
# recurse for children, but don't add call for case ident
result = copyNimNode(n)
result.add n[0]
for i in 1 ..< n.len:
result.add tcall2(n[i], tmpContext)
of nnkVarSection, nnkLetSection, nnkConstSection: of nnkVarSection, nnkLetSection, nnkConstSection:
result = n result = n
of nnkCallKinds: of nnkCallKinds:

18
tests/compiler_tests.nim Normal file
View file

@ -0,0 +1,18 @@
include karaxprelude
block:
type
TestEnum {.pure.} = enum
ValA, ValB
var e = TestEnum.ValA
proc renderDom(): VNode {.used.} =
result = buildHtml():
tdiv():
case e
of TestEnum.ValA:
tdiv: text "A"
of TestEnum.ValB:
tdiv: text "B"

View file

@ -8,6 +8,7 @@ proc exec(cmd: string) =
proc main = proc main =
exec("nim js tests/diffDomTests.nim") exec("nim js tests/diffDomTests.nim")
exec("nim js tests/compiler_tests.nim")
exec("nim js examples/todoapp/todoapp.nim") exec("nim js examples/todoapp/todoapp.nim")
exec("nim js examples/scrollapp/scrollapp.nim") exec("nim js examples/scrollapp/scrollapp.nim")
exec("nim js examples/mediaplayer/playerapp.nim") exec("nim js examples/mediaplayer/playerapp.nim")