diff options
author | Araq <rumpf_a@web.de> | 2015-10-22 12:12:05 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-10-22 12:14:32 +0200 |
commit | 9cc25f8b772905fcfdbdb7f059458083d177bb51 (patch) | |
tree | 6b95aa5d17a9d523113c510aefe8e9493f6c03c5 /tests/concepts/tgraph.nim | |
parent | ec2d3700539c0286836a859bd7dcfd05fc66f182 (diff) | |
download | Nim-9cc25f8b772905fcfdbdb7f059458083d177bb51.tar.gz |
fixes #3452
Diffstat (limited to 'tests/concepts/tgraph.nim')
-rw-r--r-- | tests/concepts/tgraph.nim | 29 |
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" + |