summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2017-06-19 17:40:20 +0300
committerAndreas Rumpf <rumpf_a@web.de>2017-06-20 11:29:42 +0200
commitb199c5af4ef76c44bef0ea50bbe163410bd8fdaf (patch)
treed902d276ad83c1919e0f58dedf80cd96016b779d /tests
parent24966e006a56e25fc1cb5c03d1d8ac12dc69d557 (diff)
downloadNim-b199c5af4ef76c44bef0ea50bbe163410bd8fdaf.tar.gz
fix #5968
Diffstat (limited to 'tests')
-rw-r--r--tests/concepts/t5968.nim20
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!"]
+