summary refs log tree commit diff stats
path: root/tests/modules/treorder.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/modules/treorder.nim')
-rw-r--r--tests/modules/treorder.nim47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/modules/treorder.nim b/tests/modules/treorder.nim
new file mode 100644
index 000000000..ff0b2e071
--- /dev/null
+++ b/tests/modules/treorder.nim
@@ -0,0 +1,47 @@
+discard """
+  matrix: "-d:testdef"
+  output: '''works 34
+34
+defined
+3'''
+"""
+
+{.experimental: "codeReordering".}
+
+{.push callconv: stdcall.}
+
+proc bar(x: T)
+
+proc foo() =
+  bar(34)
+  whendep()
+
+proc foo(dummy: int) = echo dummy
+
+proc bar(x: T) =
+  echo "works ", x
+  foo(x)
+
+when defined(testdef):
+  proc whendep() = echo "defined"
+else:
+  proc whendep() = echo "undefined"
+
+foo()
+
+type
+  T = int
+
+
+when not declared(goo):
+  proc goo(my, omy) = echo my
+
+when not declared(goo):
+  proc goo(my, omy) = echo omy
+
+using
+  my, omy: int
+
+goo(3, 4)
+
+{.pop.}