new tester; all tests categorized
This commit is contained in:
parent
51ee524109
commit
20b5f31c03
481 changed files with 794 additions and 2506 deletions
26
tests/compiles/tcompiles.nim
Normal file
26
tests/compiles/tcompiles.nim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# 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
|
||||
|
||||
ok supports(`==`, myObj)
|
||||
ok supports(`==`, 45)
|
||||
|
||||
no supports(`++`, 34)
|
||||
ok supports(`not`, true)
|
||||
ok supports(`+`, 34)
|
||||
|
||||
no compiles(4+5.0 * "hallo")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue