removed $ for refs upon request

This commit is contained in:
Simon Hafner
2013-02-21 16:37:22 -06:00
parent e366eeaafc
commit 7168ceb5e1
2 changed files with 7 additions and 19 deletions

View File

@@ -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:

View File

@@ -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))