summary refs log tree commit diff stats
path: root/tests/js/testobjs.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/js/testobjs.nim')
-rw-r--r--tests/js/testobjs.nim39
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/js/testobjs.nim b/tests/js/testobjs.nim
index 0166c0f38..b61d06471 100644
--- a/tests/js/testobjs.nim
+++ b/tests/js/testobjs.nim
@@ -1,5 +1,7 @@
 discard """
-  action: run
+  output: '''{"columns":[{"t":null},{"t":null}]}
+{"columns":[{"t":null},{"t":null}]}
+'''
 """
 
 ## Tests javascript object generation
@@ -32,7 +34,40 @@ var
   recurse1 = Recurse[int](data: 1, next: recurse2)
 
 
-doAssert test.name == "Jorden"
+doAssert test.name == cstring"Jorden"
 doAssert knight.age == 19
 doAssert knight.item.price == 50
 doAssert recurse1.next.next.data == 3
+
+# bug #6035
+proc toJson*[T](data: T): cstring {.importc: "JSON.stringify".}
+
+type
+  Column = object
+    t: ref Column
+
+  Test2 = object
+    columns: seq[Column]
+
+var test1 = Test2(columns: @[Column(t: nil), Column(t: nil)])
+let test2 = test1
+
+echo toJSON(test1)
+echo toJSON(test2)
+
+block issue10005:
+  type
+    Player = ref object of RootObj
+      id*: string
+      nickname*: string
+      color*: string
+
+  proc newPlayer(nickname: string, color: string): Player =
+    let pl = Player(color: "#123", nickname: nickname)
+    return Player(
+        id: "foo",
+        nickname: nickname,
+        color: color,
+    )
+
+  doAssert newPlayer("foo", "#1232").nickname == "foo"