diff options
author | Simon Hafner <hafnersimon@gmail.com> | 2013-02-21 14:29:39 -0600 |
---|---|---|
committer | Simon Hafner <hafnersimon@gmail.com> | 2013-02-21 14:29:39 -0600 |
commit | 7fc9dfcb2400aa0a97cad85ee0d16713e30fec8b (patch) | |
tree | 00d4fa85610706e17dfa5a67eb430f622c83c7d6 | |
parent | 45c9975e9c9fe063d68aa5eb6df0457ca9ac7457 (diff) | |
download | Nim-7fc9dfcb2400aa0a97cad85ee0d16713e30fec8b.tar.gz |
added tests for == and $
-rw-r--r-- | tests/run/tobject.nim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/run/tobject.nim b/tests/run/tobject.nim new file mode 100644 index 000000000..b6a2461ac --- /dev/null +++ b/tests/run/tobject.nim @@ -0,0 +1,20 @@ +import unittest + +type Obj = object + foo: int + +proc makeObj(x: int): ref Obj = + new(result) + result.foo = x + +proc initObject(x: int): Obj = + result.foo = x + +suite "object basic methods": + test "it should convert an objcet to a string": + var obj = makeObj(1) + discard $obj + test "it should test equality based on fields": + check(initObj(1) == initObj(1)) + test "it should test equality based on fields for refs too": + check(makeObj(1) == makeObj(1)) |