diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/collections/tsets.nim | 17 | ||||
-rw-r--r-- | tests/generics/tinferredgenericprocs.nim | 20 | ||||
-rw-r--r-- | tests/sets/tsets_lt.nim | 12 |
3 files changed, 49 insertions, 0 deletions
diff --git a/tests/collections/tsets.nim b/tests/collections/tsets.nim new file mode 100644 index 000000000..656c5b3f2 --- /dev/null +++ b/tests/collections/tsets.nim @@ -0,0 +1,17 @@ +discard """ + output: '''true +true''' +""" + +import sets +var + a = initSet[int]() + b = initSet[int]() + c = initSet[string]() + +for i in 0..5: a.incl(i) +for i in 1..6: b.incl(i) +for i in 0..5: c.incl($i) + +echo map(a, proc(x: int): int = x + 1) == b +echo map(a, proc(x: int): string = $x) == c diff --git a/tests/generics/tinferredgenericprocs.nim b/tests/generics/tinferredgenericprocs.nim new file mode 100644 index 000000000..ac445fd32 --- /dev/null +++ b/tests/generics/tinferredgenericprocs.nim @@ -0,0 +1,20 @@ +discard """ + output: '''123 +1 +2 +3''' +""" + +# https://github.com/Araq/Nimrod/issues/797 +proc foo[T](s:T):string = $s + +type IntStringProc = proc(x: int): string + +var f1 = IntStringProc(foo) +var f2: proc(x: int): string = foo +var f3: IntStringProc = foo + +echo f1(1), f2(2), f3(3) + +for x in map([1,2,3], foo): echo x + diff --git a/tests/sets/tsets_lt.nim b/tests/sets/tsets_lt.nim new file mode 100644 index 000000000..6d0b3a60c --- /dev/null +++ b/tests/sets/tsets_lt.nim @@ -0,0 +1,12 @@ +discard """ + output: '''true +true +true''' +""" + +var s, s1: set[char] +s = {'a'..'d'} +s1 = {'a'..'c'} +echo s1 < s +echo s1 * s == {'a'..'c'} +echo s1 <= s |