removed $ for refs upon request
This commit is contained in:
parent
e366eeaafc
commit
7168ceb5e1
2 changed files with 7 additions and 19 deletions
|
|
@ -1557,8 +1557,6 @@ proc `<`*[T: tuple](x, y: T): bool =
|
||||||
if c > 0: return false
|
if c > 0: return false
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc `$`*[T: ref](x: T): string = $x[]
|
|
||||||
|
|
||||||
proc `$`*[T: tuple|object](x: T): string =
|
proc `$`*[T: tuple|object](x: T): string =
|
||||||
## generic ``$`` operator for tuples that is lifted from the components
|
## generic ``$`` operator for tuples that is lifted from the components
|
||||||
## of `x`. Example:
|
## of `x`. Example:
|
||||||
|
|
|
||||||
|
|
@ -3,23 +3,13 @@ import unittest
|
||||||
type Obj = object
|
type Obj = object
|
||||||
foo: int
|
foo: int
|
||||||
|
|
||||||
proc makeObj(x: int): ref Obj =
|
proc makeObj(x: int): Obj =
|
||||||
new(result)
|
|
||||||
result.foo = x
|
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 "object basic methods":
|
||||||
suite "ref":
|
test "it should convert an object to a string":
|
||||||
stringTest(makeObj)
|
var obj = makeObj(1)
|
||||||
suite "value":
|
# Should be "obj: (foo: 1)" or similar.
|
||||||
stringTest(initObj)
|
check($obj == "(foo: 1)")
|
||||||
test "it should test equality based on fields":
|
test "it should test equality based on fields":
|
||||||
check(initObj(1) == initObj(1))
|
check(makeObj(1) == makeObj(1))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue