diff options
author | yglukhov <yuriy.glukhov@gmail.com> | 2015-05-27 16:48:10 +0300 |
---|---|---|
committer | Oscar Campbell <oscar@campbell.nu> | 2015-06-07 13:14:10 +0200 |
commit | c55f5dfca263788169c21fcff2dd78103a20e891 (patch) | |
tree | e268570e9ad2a8a9cb136ae916721c0a6c7ca496 | |
parent | ccb9ae2d52cc42f2489a7bbd758c924a4dbbe872 (diff) | |
download | Nim-c55f5dfca263788169c21fcff2dd78103a20e891.tar.gz |
Perform lambda lifting for compile-time stuff when targeting JS. Enable unittest test.
-rw-r--r-- | compiler/lambdalifting.nim | 6 | ||||
-rw-r--r-- | lib/pure/unittest.nim | 9 | ||||
-rw-r--r-- | tests/js/tunittests.nim | 5 |
3 files changed, 10 insertions, 10 deletions
diff --git a/compiler/lambdalifting.nim b/compiler/lambdalifting.nim index c68bc352c..69b45c980 100644 --- a/compiler/lambdalifting.nim +++ b/compiler/lambdalifting.nim @@ -946,7 +946,11 @@ proc transformOuterProc(o: POuterContext, n: PNode; it: TIter): PNode = proc liftLambdas*(fn: PSym, body: PNode): PNode = # XXX gCmd == cmdCompileToJS does not suffice! The compiletime stuff needs # the transformation even when compiling to JS ... - if body.kind == nkEmpty or gCmd == cmdCompileToJS or + + # However we can do lifting for the stuff which is *only* compiletime. + let isCompileTime = sfCompileTime in fn.flags or fn.kind == skMacro + + if body.kind == nkEmpty or (gCmd == cmdCompileToJS and not isCompileTime) or fn.skipGenericOwner.kind != skModule: # ignore forward declaration: result = body diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 092b1fba2..dbbd3cabc 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -99,8 +99,9 @@ template test*(name: expr, body: stmt): stmt {.immediate, dirty.} = body except: - checkpoint("Unhandled exception: " & getCurrentExceptionMsg()) - echo getCurrentException().getStackTrace() + when not defined(js): + checkpoint("Unhandled exception: " & getCurrentExceptionMsg()) + echo getCurrentException().getStackTrace() fail() finally: @@ -114,9 +115,7 @@ proc checkpoint*(msg: string) = template fail* = bind checkpoints for msg in items(checkpoints): - # this used to be 'echo' which now breaks due to a bug. XXX will revisit - # this issue later. - stdout.writeln msg + echo msg when not defined(ECMAScript): if abortOnError: quit(1) diff --git a/tests/js/tunittests.nim b/tests/js/tunittests.nim index 8a264a5e0..4b09c99a9 100644 --- a/tests/js/tunittests.nim +++ b/tests/js/tunittests.nim @@ -1,10 +1,7 @@ discard """ - disabled: "true" + output: '''[OK] >:)''' """ -# Unittest uses lambdalifting at compile-time which we disable for the JS -# codegen! So this cannot and will not work for quite some time. - import unittest suite "Bacon": |