diff options
author | Araq <rumpf_a@web.de> | 2015-09-10 11:08:48 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-09-10 11:08:48 +0200 |
commit | a92f3bead327a1ec7049f89ba9a0f392426c7b0a (patch) | |
tree | 402f0b437144d1561ecfb8c1e5e972d1de3789a6 /tests/vm/tconstobj.nim | |
parent | d7a472743b6d3e7c0062621d0b861d20edf89663 (diff) | |
download | Nim-a92f3bead327a1ec7049f89ba9a0f392426c7b0a.tar.gz |
fixes #3195
Diffstat (limited to 'tests/vm/tconstobj.nim')
-rw-r--r-- | tests/vm/tconstobj.nim | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim index 414708945..51f30fb78 100644 --- a/tests/vm/tconstobj.nim +++ b/tests/vm/tconstobj.nim @@ -1,8 +1,9 @@ discard """ - output: '''(name: hello)''' + output: '''(name: hello) +(-1, 0)''' """ -# bug #2774 +# bug #2774, bug #3195 type Foo = object name: string @@ -12,3 +13,24 @@ const fooArray = [ ] echo fooArray[0] + + +type + Position = object + x, y: int + +proc `$`(pos: Position): string = + result = "(" & $pos.x & ", " & $pos.y & ")" + +proc newPos(x, y: int): Position = + result = Position(x: x, y: y) + +const + offset: array[1..4, Position] = [ + newPos(-1, 0), + newPos(1, 0), + newPos(0, -1), + newPos(0, 1) + ] + +echo offset[1] |