diff options
author | Araq <rumpf_a@web.de> | 2015-03-16 23:02:03 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-03-16 23:02:20 +0100 |
commit | bf90b9c8338b7aedad62e4978e50b5227e8a29b1 (patch) | |
tree | ec609aab93dcfa8864aec294ff6e819756889c69 /tests/concepts/tmanual.nim | |
parent | bc264618f532013e8816a824fb41a6b1cfbee712 (diff) | |
download | Nim-bf90b9c8338b7aedad62e4978e50b5227e8a29b1.tar.gz |
fixes #2346
Diffstat (limited to 'tests/concepts/tmanual.nim')
-rw-r--r-- | tests/concepts/tmanual.nim | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/concepts/tmanual.nim b/tests/concepts/tmanual.nim new file mode 100644 index 000000000..243992aed --- /dev/null +++ b/tests/concepts/tmanual.nim @@ -0,0 +1,44 @@ +discard """ + output: '''1 +2 +3 +4 +5 +6 +a +b +t +e +s +t +''' + disabled: "true" +""" + +template accept(e: expr) = + static: assert compiles(e) + +template reject(e: expr) = + static: assert(not compiles(e)) + +type + Container[T] = generic C + C.len is Ordinal + items(c) is iterator + for value in C: + type(value) is T + +proc takesIntContainer(c: Container[int]) = + for e in c: echo e + +takesIntContainer(@[1, 2, 3]) +reject takesIntContainer(@["x", "y"]) + +proc takesContainer(c: Container) = + for e in c: echo e + +takesContainer(@[4, 5, 6]) +takesContainer(@["a", "b"]) +takesContainer "test" +reject takesContainer(10) + |