test cases for the new handling of iterators by the is operator
This commit is contained in:
parent
862c0ef83d
commit
249dd70273
3 changed files with 36 additions and 9 deletions
|
|
@ -1,5 +1,8 @@
|
|||
discard """
|
||||
output: "true true false yes"
|
||||
output: '''true
|
||||
true
|
||||
false
|
||||
yes'''
|
||||
"""
|
||||
|
||||
proc IsVoid[T](): string =
|
||||
|
|
@ -11,3 +14,26 @@ proc IsVoid[T](): string =
|
|||
const x = int is int
|
||||
echo x, " ", float is float, " ", float is string, " ", IsVoid[void]()
|
||||
|
||||
template yes(e: expr): stmt =
|
||||
static: assert e
|
||||
|
||||
template no(e: expr): stmt =
|
||||
static: assert(not e)
|
||||
|
||||
var s = @[1, 2, 3]
|
||||
|
||||
yes s.items is iterator
|
||||
no s.items is proc
|
||||
|
||||
yes s.items is iterator: int
|
||||
no s.items is iterator: float
|
||||
|
||||
yes s.items is iterator: TNumber
|
||||
no s.items is iterator: object
|
||||
|
||||
type
|
||||
Iter[T] = iterator: T
|
||||
|
||||
yes s.items is Iter[TNumber]
|
||||
no s.items is Iter[float]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue