diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/concepts/t5968.nim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/concepts/t5968.nim b/tests/concepts/t5968.nim new file mode 100644 index 000000000..adb374c65 --- /dev/null +++ b/tests/concepts/t5968.nim @@ -0,0 +1,20 @@ +discard """ + exitcode: 0 +""" + +type + Enumerable[T] = concept e + for it in e: + it is T + +proc cmap[T, G](e: Enumerable[T], fn: proc(t: T): G): seq[G] = + result = @[] + for it in e: result.add(fn(it)) + +import json + +var x = %["hello", "world"] + +var z = x.cmap(proc(it: JsonNode): string = it.getStr & "!") +assert z == @["hello!", "world!"] + |