tobject.nim 358 B

12345678910111213141516
  1. import unittest
  2. type Obj = object
  3. foo: int
  4. proc makeObj(x: int): Obj =
  5. result.foo = x
  6. suite "object basic methods":
  7. test "it should convert an object to a string":
  8. var obj = makeObj(1)
  9. # Should be "obj: (foo: 1)" or similar.
  10. check($obj == "(foo: 1)")
  11. test "it should test equality based on fields":
  12. check(makeObj(1) == makeObj(1))