summary refs log tree commit diff stats
path: root/tests/objects/tobject.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/objects/tobject.nim')
-rw-r--r--tests/objects/tobject.nim50
1 files changed, 40 insertions, 10 deletions
diff --git a/tests/objects/tobject.nim b/tests/objects/tobject.nim
index 34856eaef..a185bebcb 100644
--- a/tests/objects/tobject.nim
+++ b/tests/objects/tobject.nim
@@ -1,8 +1,3 @@
-discard """
-output: "[Suite] object basic methods"
-"""
-
-import unittest
 
 type Obj = object
   foo: int
@@ -10,13 +5,13 @@ type Obj = object
 proc makeObj(x: int): Obj =
   result.foo = x
 
-suite "object basic methods":
-  test "it should convert an object to a string":
+block: # object basic methods
+  block: # 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))
+    doAssert($obj == "(foo: 1)")
+  block: # it should test equality based on fields
+    doAssert(makeObj(1) == makeObj(1))
 
 # bug #10203
 
@@ -42,3 +37,38 @@ var b: TMyObj = a
 type
   InheritableFoo {.inheritable.} = ref object
   InheritableBar = ref object of InheritableFoo # ERROR.
+
+block: # bug #14698
+  const N = 3
+  type Foo[T] = ref object
+    x1: int
+    when N == 2:
+      x2: float
+    when N == 3:
+      x3: seq[int]
+    else:
+      x4: char
+      x4b: array[9, char]
+
+  let t = Foo[float](x1: 1)
+  doAssert $(t[]) == "(x1: 1, x3: @[])"
+  doAssert t.sizeof == int.sizeof
+  type Foo1 = object
+    x1: int
+    x3: seq[int]
+  doAssert t[].sizeof == Foo1.sizeof
+
+# bug #147
+type
+  TValue* {.pure, final.} = object of RootObj
+    a: int
+  PValue = ref TValue
+  PPValue = ptr PValue
+
+
+var x: PValue
+new x
+var sp: PPValue = addr x
+
+sp.a = 2
+doAssert sp.a == 2