summary refs log tree commit diff stats
path: root/tests/compile
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2012-10-03 01:50:26 +0300
committerZahary Karadjov <zahary@gmail.com>2012-10-03 01:59:50 +0300
commit2e5265bef54ef260213a2ad6ec417f48571c2824 (patch)
treed15efa6aaa2d30f9484026a5ee7c238fd85fb32f /tests/compile
parent9c8bc3a244b4bbcdc56fdd255bb4e1a7ed30f781 (diff)
downloadNim-2e5265bef54ef260213a2ad6ec417f48571c2824.tar.gz
experimental support for querying the type of expressions within macros
normalised the line endings of macros.nim (minor edits otherwise)
Diffstat (limited to 'tests/compile')
-rw-r--r--tests/compile/tmacrotypes.nim12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/compile/tmacrotypes.nim b/tests/compile/tmacrotypes.nim
new file mode 100644
index 000000000..7697dba27
--- /dev/null
+++ b/tests/compile/tmacrotypes.nim
@@ -0,0 +1,12 @@
+import macros, typetraits
+
+macro checkType(ex, expected: expr): stmt {.immediate.} =
+  var t = ex.typ
+  assert t.name == expected.strVal
+
+proc voidProc = echo "hello"
+proc intProc(a, b): int = 10
+
+checkType(voidProc(), "void")
+checkType(intProc(10, 20.0), "int")
+checkType(noproc(10, 20.0), "Error Type")