diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-12-12 10:15:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-12 10:15:25 +0100 |
commit | d9ae9201c442f2e1427140283f3eab77b4f8c70c (patch) | |
tree | 5c3d7de95238b830969bf2e6f698fb2074d4a725 /tests/pragmas | |
parent | 3a70d18b84d777b9c38f33692d3bf2aa1c0d1a85 (diff) | |
parent | 1d16676dd6a31de03bfc87a5dfdee482b27b51b5 (diff) | |
download | Nim-d9ae9201c442f2e1427140283f3eab77b4f8c70c.tar.gz |
Merge pull request #9937 from cooldome/pragmablock_custom_pragma
Language feature: implement custom pragmas in pragma blocks
Diffstat (limited to 'tests/pragmas')
-rw-r--r-- | tests/pragmas/tcustom_pragma.nim | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/pragmas/tcustom_pragma.nim b/tests/pragmas/tcustom_pragma.nim index ae0f39631..0bc4d2f18 100644 --- a/tests/pragmas/tcustom_pragma.nim +++ b/tests/pragmas/tcustom_pragma.nim @@ -174,3 +174,25 @@ type var foo: Something foo.cardinal = north doAssert foo.b.hasCustomPragma(thingy) == true + + +proc myproc(s: string): int = + {.thingy.}: + s.len + +doAssert myproc("123") == 3 + +let xx = compiles: + proc myproc_bad(s: string): int = + {.not_exist.}: + s.len +doAssert: xx == false + + +macro checkSym(s: typed{nkSym}): untyped = + let body = s.getImpl.body + doAssert body[1].kind == nnkPragmaBlock + doAssert body[1][0].kind == nnkPragma + doAssert body[1][0][0] == bindSym"thingy" + +checkSym(myproc) \ No newline at end of file |