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")
&id=6431e602160a5f2e1323a057e9c0166431e5a002'>^
a16e6bd22 ^






015b814e6 ^

da825a0fe ^
a16e6bd22 ^



45185f84d ^
a16e6bd22 ^






b893bd074 ^
45f9c5b94 ^



a16e6bd22 ^

18033026c ^
1c9b4e5d3 ^


a16e6bd22 ^


43d1181c0 ^
da825a0fe ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65