summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-02-28 21:28:19 +0100
committerAraq <rumpf_a@web.de>2013-02-28 21:28:19 +0100
commitd13bcf657503a84f3568b86a7cfce4a28be03f7b (patch)
tree2c29bb8edfcb944449095e2c92a120663958ed93 /tests
parent8090b6c02704cd7e8942ac846c9e086874d88241 (diff)
downloadNim-d13bcf657503a84f3568b86a7cfce4a28be03f7b.tar.gz
better overloading resolution for generics
Diffstat (limited to 'tests')
-rwxr-xr-xtests/run/toverl3.nim20
-rwxr-xr-xtests/run/toverlop.nim16
2 files changed, 20 insertions, 16 deletions
diff --git a/tests/run/toverl3.nim b/tests/run/toverl3.nim
new file mode 100755
index 000000000..b3e0f2fa7
--- /dev/null
+++ b/tests/run/toverl3.nim
@@ -0,0 +1,20 @@
+discard """
+  file: "toverl3.nim"
+  output: '''m1
+tup1'''
+"""
+
+# Tests more specific generic match:

+

+proc m[T](x: T) = echo "m2"
+proc m[T](x: var ref T) = echo "m1"
+
+proc tup[S, T](x: tuple[a: S, b: ref T]) = echo "tup1"
+proc tup[S, T](x: tuple[a: S, b: T]) = echo "tup2"
+
+var
+  obj: ref int
+  tu: tuple[a: int, b: ref bool]
+  
+m(obj)
+tup(tu)
diff --git a/tests/run/toverlop.nim b/tests/run/toverlop.nim
deleted file mode 100755
index ce302345f..000000000
--- a/tests/run/toverlop.nim
+++ /dev/null
@@ -1,16 +0,0 @@
-discard """
-  file: "toverlop.nim"
-  output: "3"
-"""
-# Test operator overloading

-

-proc `%` (a, b: int): int =

-  return a mod b

-

-var x, y: int

-x = 15

-y = 6

-write(stdout, x % y)

-#OUT 3

-
-