summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2014-03-06 23:03:02 +0200
committerZahary Karadjov <zahary@gmail.com>2014-03-06 23:03:02 +0200
commit249dd7027302c913513cf577beed83512236fc57 (patch)
tree527fd7921e51c8efa5fc079d7eefea42e9ed27ef /tests
parent862c0ef83d7a85798df0474522dd4ba8cfcab674 (diff)
downloadNim-249dd7027302c913513cf577beed83512236fc57.tar.gz
test cases for the new handling of iterators by the `is` operator
Diffstat (limited to 'tests')
-rw-r--r--tests/types/tisopr.nim28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/types/tisopr.nim b/tests/types/tisopr.nim
index 6d3c51749..f173b93f4 100644
--- a/tests/types/tisopr.nim
+++ b/tests/types/tisopr.nim
@@ -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]
+