From 7168ceb5e1ec6686b13f5da1f2c9a4db07ac90ec Mon Sep 17 00:00:00 2001 From: Simon Hafner Date: Thu, 21 Feb 2013 16:37:22 -0600 Subject: [PATCH] removed `$` for refs upon request --- lib/system.nim | 2 -- tests/run/tobject.nim | 24 +++++++----------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 3f15dbeaf2..db78d27405 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -1557,8 +1557,6 @@ proc `<`*[T: tuple](x, y: T): bool = if c > 0: return false return false -proc `$`*[T: ref](x: T): string = $x[] - proc `$`*[T: tuple|object](x: T): string = ## generic ``$`` operator for tuples that is lifted from the components ## of `x`. Example: diff --git a/tests/run/tobject.nim b/tests/run/tobject.nim index b2fd212366..5fec844417 100644 --- a/tests/run/tobject.nim +++ b/tests/run/tobject.nim @@ -3,23 +3,13 @@ import unittest type Obj = object foo: int -proc makeObj(x: int): ref Obj = - new(result) +proc makeObj(x: int): Obj = result.foo = x -proc initObj(x: int): Obj = - result.foo = x - -template stringTest(init: expr) = - test "it should convert an object to a string": - var obj = `init`(1) - # Should be "obj: (foo: 1)" or similar. - check($obj == "(foo: 1)") - suite "object basic methods": - suite "ref": - stringTest(makeObj) - suite "value": - stringTest(initObj) - test "it should test equality based on fields": - check(initObj(1) == initObj(1)) + test "it should convert an object to a string": + var obj = makeObj(1) + # Should be "obj: (foo: 1)" or similar. + check($obj == "(foo: 1)") + test "it should test equality based on fields": + check(makeObj(1) == makeObj(1))