summary refs log tree commit diff stats
path: root/tests/concepts/tgraph.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-10-22 12:12:05 +0200
committerAraq <rumpf_a@web.de>2015-10-22 12:14:32 +0200
commit9cc25f8b772905fcfdbdb7f059458083d177bb51 (patch)
tree6b95aa5d17a9d523113c510aefe8e9493f6c03c5 /tests/concepts/tgraph.nim
parentec2d3700539c0286836a859bd7dcfd05fc66f182 (diff)
downloadNim-9cc25f8b772905fcfdbdb7f059458083d177bb51.tar.gz
fixes #3452
Diffstat (limited to 'tests/concepts/tgraph.nim')
-rw-r--r--tests/concepts/tgraph.nim29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/concepts/tgraph.nim b/tests/concepts/tgraph.nim
new file mode 100644
index 000000000..a0177a043
--- /dev/null
+++ b/tests/concepts/tgraph.nim
@@ -0,0 +1,29 @@
+discard """
+  output: '''XY is Node
+MyGraph is Graph'''
+"""
+# bug #3452
+import math
+
+type
+    Node* = concept n
+        `==`(n, n) is bool
+
+    Graph* = concept g
+        var x: Node
+        distance(g, x, x) is float
+
+    XY* = tuple[x, y: int]
+
+    MyGraph* = object
+        points: seq[XY]
+
+if XY is Node:
+    echo "XY is Node"
+
+proc distance*( g: MyGraph, a, b: XY): float =
+    sqrt( pow(float(a.x - b.x), 2) + pow(float(a.y - b.y), 2) )
+
+if MyGraph is Graph:
+    echo "MyGraph is Graph"
+