diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-09-03 03:14:56 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-09-03 03:14:56 +0300 |
commit | 6082595e968f000b5089b1db7e72ad55bbf3fac3 (patch) | |
tree | 06a76e725c59524b5e7ab23e8c5f1a7c1bef5e54 /tests/compile | |
parent | 39da6979add895cf58e9c6f883ef8df465975cd6 (diff) | |
parent | c8c8d2035af189bdf63b39d4e47266a6e67c38b9 (diff) | |
download | Nim-6082595e968f000b5089b1db7e72ad55bbf3fac3.tar.gz |
Merge branch 'type-classes' into upstream
Diffstat (limited to 'tests/compile')
-rw-r--r-- | tests/compile/tcompiles.nim | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/tests/compile/tcompiles.nim b/tests/compile/tcompiles.nim index 1a1d947b1..d0fccdaff 100644 --- a/tests/compile/tcompiles.nim +++ b/tests/compile/tcompiles.nim @@ -1,31 +1,26 @@ -discard """ - output: '''obj has '==': false -int has '==': true -false -true -true -no''' -""" - # test the new 'compiles' feature: template supports(opr, x: expr): bool {.immediate.} = compiles(opr(x)) or compiles(opr(x, x)) +template ok(x: expr): stmt = + static: assert(x) + +template no(x: expr): stmt = + static: assert(not x) + type TObj = object var myObj {.compileTime.}: TObj -echo "obj has '==': ", supports(`==`, myObj) -echo "int has '==': ", supports(`==`, 45) +ok supports(`==`, myObj) +ok supports(`==`, 45) + +no supports(`++`, 34) +ok supports(`not`, true) +ok supports(`+`, 34) -echo supports(`++`, 34) -echo supports(`not`, true) -echo supports(`+`, 34) +no compiles(4+5.0 * "hallo") -when compiles(4+5.0 * "hallo"): - echo "yes" -else: - echo "no" |