diff options
Diffstat (limited to 'tests/macros/tclosuremacro.nim')
-rw-r--r-- | tests/macros/tclosuremacro.nim | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/tests/macros/tclosuremacro.nim b/tests/macros/tclosuremacro.nim index 9f2137dec..5c41c317a 100644 --- a/tests/macros/tclosuremacro.nim +++ b/tests/macros/tclosuremacro.nim @@ -1,19 +1,16 @@ discard """ - output: '''10 -10 -10 -3 -3 + output: ''' noReturn -6 calling mystuff yes calling mystuff yes +calling sugarWithPragma +sugarWithPragma called ''' """ -import future, macros +import sugar, macros proc twoParams(x: (int, int) -> int): int = result = x(5, 5) @@ -30,23 +27,23 @@ proc noReturn(x: () -> void) = proc doWithOneAndTwo(f: (int, int) -> int): int = f(1,2) -echo twoParams(proc (a, b: auto): auto = a + b) -echo twoParams((x, y) => x + y) - -echo oneParam(x => x+5) - -echo noParams(() => 3) - -echo doWithOneAndTwo((x, y) => x + y) +doAssert twoParams(proc (a, b: auto): auto = a + b) == 10 +doAssert twoParams((x, y) => x + y) == 10 +doAssert oneParam(x => x+5) == 10 +doAssert noParams(() => 3) == 3 +doAssert doWithOneAndTwo((x, y) => x + y) == 3 noReturn((() -> void) => echo("noReturn")) proc pass2(f: (int, int) -> int): (int) -> int = ((x: int) -> int) => f(2, x) -echo pass2((x, y) => x + y)(4) +doAssert pass2((x, y) => x + y)(4) == 6 +fun(x, y: int) {.noSideEffect.} => x + y +doAssert typeof(fun) is (proc (x, y: int): int {.nimcall.}) +doAssert fun(3, 4) == 7 proc register(name: string; x: proc()) = echo "calling ", name @@ -72,3 +69,5 @@ macro m(x: untyped): untyped = m: proc mystuff() = echo "yes" + +sugarWithPragma() {.m.} => echo "sugarWithPragma called" |