diff options
author | BigEpsilon <BigEpsilon@users.noreply.github.com> | 2017-10-28 11:33:35 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-28 11:33:35 +0200 |
commit | e2af486434c7ff401c412d890b490b4ac11ab321 (patch) | |
tree | 0861cd9a9f8f2da4cf7d99564e5d11f8772a06dd /tests/pragmas/treorder.nim | |
parent | e13513546981167e4d1ee38993b2589e14531fb9 (diff) | |
download | Nim-e2af486434c7ff401c412d890b490b4ac11ab321.tar.gz |
Add sections (type, var, let, const, using) support for reorder pragma (#6326)
Diffstat (limited to 'tests/pragmas/treorder.nim')
-rw-r--r-- | tests/pragmas/treorder.nim | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/pragmas/treorder.nim b/tests/pragmas/treorder.nim new file mode 100644 index 000000000..6a6bbff4d --- /dev/null +++ b/tests/pragmas/treorder.nim @@ -0,0 +1,75 @@ +discard """ +output:'''0 +1 +2 +3''' +""" + +import macros +{.reorder: on .} + +echo foo(-1) +echo callWithFoo(0) +echo(CA+CD) +echo useTypes(TA(x:TB(x:1)), 2) +second(0) + +template callWithFoo(arg: untyped): untyped = + foo(arg) + +proc first(i: int): void + +proc second(i: int): void = + make(first) + first(i) + +proc useTypes(a: TA, d: TD): int = + result = a.x.x+d + +type + TDoubleCyclic = ref object + x: TCyclicA + y: TCyclicB + +type + TCyclicA = ref object + x: TDoubleCyclic + +type + TCyclicB = ref object + x: TDoubleCyclic + +const + CA = 1 + CB = CC + +type + TA = object + x: TB + TC = type(CC) + TD = type(CA) + +const + CC = 1 + CD = CB + +type + TB = object + x: TC + +proc foo(x: int): int = + result = bar(x) + +proc bar(x: int): int = + result = x+1 + +macro make(arg: untyped): untyped = + ss &= arg.repr + ss &= " " + discard + +proc first(i: int): void = + make(second) + +static: + var ss: string = "" \ No newline at end of file |