diff options
author | Zahary Karadjov <zahary@gmail.com> | 2017-06-19 20:44:28 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-06-20 11:29:42 +0200 |
commit | 16eb4b1fee14e41807ff5c368ea848b71f258182 (patch) | |
tree | 801d23bfcbc8377f54f2986ec5fa9d34003e4645 /tests/concepts/tgraph.nim | |
parent | 8f4b3743277119a0ec231738fdd3931476c186d9 (diff) | |
download | Nim-16eb4b1fee14e41807ff5c368ea848b71f258182.tar.gz |
Fix #5127
Diffstat (limited to 'tests/concepts/tgraph.nim')
-rw-r--r-- | tests/concepts/tgraph.nim | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/tests/concepts/tgraph.nim b/tests/concepts/tgraph.nim index a0177a043..985f04a61 100644 --- a/tests/concepts/tgraph.nim +++ b/tests/concepts/tgraph.nim @@ -1,29 +1,34 @@ -discard """ - output: '''XY is Node -MyGraph is Graph''' -""" # bug #3452 import math type - Node* = concept n - `==`(n, n) is bool + Node* = concept n + `==`(n, n) is bool - Graph* = concept g - var x: Node - distance(g, x, x) is float + Graph1* = concept g + type N = Node + distance(g, N, N) is float - XY* = tuple[x, y: int] + Graph2 = concept g + distance(g, Node, Node) is float - MyGraph* = object - points: seq[XY] + Graph3 = concept g + var x: Node + distance(g, x, x) is float -if XY is Node: - echo "XY is Node" + XY* = tuple[x, y: int] + + MyGraph* = object + points: seq[XY] + +static: + assert 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) ) + sqrt( pow(float(a.x - b.x), 2) + pow(float(a.y - b.y), 2) ) -if MyGraph is Graph: - echo "MyGraph is Graph" +static: + assert MyGraph is Graph1 + assert MyGraph is Graph2 + assert MyGraph is Graph3 |