diff options
Diffstat (limited to 'tests/macros/tbindsym.nim')
-rw-r--r-- | tests/macros/tbindsym.nim | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/macros/tbindsym.nim b/tests/macros/tbindsym.nim index e1e3b5112..a493d6a88 100644 --- a/tests/macros/tbindsym.nim +++ b/tests/macros/tbindsym.nim @@ -1,4 +1,9 @@ discard """ + nimout: '''initApple +deinitApple +Coral +enum + redCoral, blackCoral''' output: '''TFoo TBar''' """ @@ -11,7 +16,7 @@ type TTextKind = enum TFoo, TBar -macro test: stmt = +macro test: untyped = var x = @[TFoo, TBar] result = newStmtList() for i in x: @@ -23,3 +28,40 @@ macro test: stmt = bindSym("TBar")) test() + +# issue 7827, bindSym power up +{.experimental: "dynamicBindSym".} +type + Apple = ref object + name: string + color: int + weight: int + +proc initApple(name: string): Apple = + discard + +proc deinitApple(x: Apple) = + discard + +macro wrapObject(obj: typed, n: varargs[untyped]): untyped = + let m = n[0] + for x in m: + var z = bindSym x + echo z.repr + +wrapObject(Apple): + initApple + deinitApple + +type + Coral = enum + redCoral + blackCoral + +macro mixer(): untyped = + let m = "Co" & "ral" + let x = bindSym(m) + echo x.repr + echo getType(x).repr + +mixer() |