diff options
Diffstat (limited to 'tests/macros/tclosuremacro.nim')
-rw-r--r-- | tests/macros/tclosuremacro.nim | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/macros/tclosuremacro.nim b/tests/macros/tclosuremacro.nim index 5c41c317a..44c2411a5 100644 --- a/tests/macros/tclosuremacro.nim +++ b/tests/macros/tclosuremacro.nim @@ -5,8 +5,6 @@ calling mystuff yes calling mystuff yes -calling sugarWithPragma -sugarWithPragma called ''' """ @@ -40,7 +38,7 @@ proc pass2(f: (int, int) -> int): (int) -> int = doAssert pass2((x, y) => x + y)(4) == 6 -fun(x, y: int) {.noSideEffect.} => x + y +const fun = (x, y: int) {.noSideEffect.} => x + y doAssert typeof(fun) is (proc (x, y: int): int {.nimcall.}) doAssert fun(3, 4) == 7 @@ -70,4 +68,13 @@ m: proc mystuff() = echo "yes" -sugarWithPragma() {.m.} => echo "sugarWithPragma called" +const typedParamAndPragma = (x, y: int) -> int => x + y +doAssert typedParamAndPragma(1, 2) == 3 + +type + Bot = object + call: proc (): string {.noSideEffect.} + +var myBot = Bot() +myBot.call = () {.noSideEffect.} => "I'm a bot." +doAssert myBot.call() == "I'm a bot." |