summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-04-06 19:53:24 +0200
committerAraq <rumpf_a@web.de>2014-04-06 19:53:24 +0200
commit5d6053173a0db2b4d0dd1c334c41075fe8d9850e (patch)
tree2f0c16dfe878ca13e2e06bf9acbf2a02f94984fd
parenta4ccd7b86524a9292441dd61eb6fd1c3ceba70ca (diff)
downloadNim-5d6053173a0db2b4d0dd1c334c41075fe8d9850e.tar.gz
fixes #297
-rw-r--r--tests/typerel/texplicitcmp.nim32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/typerel/texplicitcmp.nim b/tests/typerel/texplicitcmp.nim
new file mode 100644
index 000000000..8aec9885a
--- /dev/null
+++ b/tests/typerel/texplicitcmp.nim
@@ -0,0 +1,32 @@
+discard """
+  output: '''[1 2 3 ]
+[1 2 3 ]
+[1 2 3 ]'''
+"""
+
+# bug #297
+
+import json, tables, algorithm
+
+proc outp(a: openarray[int]) =
+  stdout.write "["
+  for i in a: stdout.write($i & " ")
+  stdout.write "]\n"
+
+proc works() =
+  var f = @[3, 2, 1]
+  sort(f, system.cmp[int])
+  outp(f)
+
+proc weird(json_params: TTable) =
+  var f = @[3, 2, 1]
+  # The following line doesn't compile: type mismatch. Why?
+  sort(f, system.cmp[int])
+  outp(f)
+
+when isMainModule:
+  var t = @[3, 2, 1]
+  sort(t, system.cmp[int])
+  outp(t)
+  works()
+  weird(initTable[string, TJsonNode]())