From 7fc9dfcb2400aa0a97cad85ee0d16713e30fec8b Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Thu, 21 Feb 2013 14:29:39 -0600 Subject: added tests for == and $ --- tests/run/tobject.nim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/run/tobject.nim (limited to 'tests') 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)) -- cgit 1.4.1-2-gfad0