mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-16 22:11:18 +00:00
added $ for refs and removed == for ref test
== in refs should use the pointer to compare
This commit is contained in:
@@ -7,15 +7,19 @@ proc makeObj(x: int): ref Obj =
|
||||
new(result)
|
||||
result.foo = x
|
||||
|
||||
proc initObject(x: int): Obj =
|
||||
proc initObj(x: int): Obj =
|
||||
result.foo = x
|
||||
|
||||
suite "object basic methods":
|
||||
test "it should convert an objcet to a string":
|
||||
var obj = makeObj(1)
|
||||
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)")
|
||||
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))
|
||||
|
||||
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))
|
||||
|
||||
Reference in New Issue
Block a user