aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/include/tast2.h6
-rw-r--r--tests/tast2.nim12
2 files changed, 15 insertions, 3 deletions
diff --git a/tests/include/tast2.h b/tests/include/tast2.h
index 7e15ac0..3c6148a 100644
--- a/tests/include/tast2.h
+++ b/tests/include/tast2.h
@@ -23,6 +23,12 @@ extern "C" {
#define BOOL true
#define MATHEXPR (1 + 2/3*20 - 100)
#define ANDEXPR (100 & 11000)
+#define CASTEXPR (int) 34
+
+#define NULLCHAR '\0'
+#define OCTCHAR '\012'
+#define HEXCHAR '\xFE'
+#define TRICKYSTR "\x4E\034\nfoo\0\'\"\r\v\a\b\e\f\t\\\?bar"
#define ALLSHL (SHL1 | SHL2 | SHL3)
diff --git a/tests/tast2.nim b/tests/tast2.nim
index d65e34a..d00552c 100644
--- a/tests/tast2.nim
+++ b/tests/tast2.nim
@@ -93,11 +93,11 @@ macro testFields(t: typed, fields: static[string] = "") =
for i in 0 ..< rl.len:
let
name = ($rl[i][0]).strip(chars = {'*'})
- typ = ($(rl[i][1].repr())).replace("\n", "").replace(" ", "")
+ typ = ($(rl[i][1].repr())).replace("\n", "").replace(" ", "").replace("typeof", "type")
n = names.find(name)
assert n != -1, $t & "." & name & " invalid"
- assert types[n] == typ,
- "typeof(" & $t & ":" & name & ") != " & types[n] & ", is " & typ
+ assert types[n].replace("typeof", "type") == typ,
+ "typeof(" & $t & ":" & name & ") != " & types[n].replace("typeof", "type") & ", is " & typ
assert A == 2
assert B == 1.0
@@ -118,6 +118,12 @@ assert BINEXPR == 5
assert BOOL == true
assert MATHEXPR == -99
assert ANDEXPR == 96
+assert CASTEXPR == 34.chr
+
+assert TRICKYSTR == "N\x1C\nfoo\x00\'\"\c\v\a\b\e\f\t\\\\?bar"
+assert NULLCHAR == '\0'
+assert OCTCHAR == '\n'
+assert HEXCHAR.int == 0xFE
assert SHL1 == (1.uint shl 1)
assert SHL2 == (1.uint shl 2)