summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorzah <zahary@gmail.com>2019-09-30 23:24:57 +0300
committerAndreas Rumpf <rumpf_a@web.de>2019-09-30 22:24:57 +0200
commita4ade435365065b7722d8111e0ad298f4f766452 (patch)
tree4447564a1af973837ca337bd7a0833c07d93135d /tests
parentdd082b6ec8308034a48761bf8a441b119ec0f351 (diff)
downloadNim-a4ade435365065b7722d8111e0ad298f4f766452.tar.gz
macros.newLit now works for ref object types (#12307)
Diffstat (limited to 'tests')
-rw-r--r--tests/macros/tnewlit.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/macros/tnewlit.nim b/tests/macros/tnewlit.nim
index 194f035ba..70683f880 100644
--- a/tests/macros/tnewlit.nim
+++ b/tests/macros/tnewlit.nim
@@ -5,6 +5,14 @@ type
     a : int
     b : string
 
+  RefObject = ref object
+    x: int
+
+  RegularObject = object
+    x: int
+
+  ObjectRefAlias = ref RegularObject
+
 macro test_newLit_MyType: untyped =
   let mt = MyType(a: 123, b:"foobar")
   result = newLit(mt)
@@ -167,3 +175,20 @@ macro test_newLit_set: untyped =
 block:
   let tmp: set[MyEnum] = {MyEnum.low .. MyEnum.high}
   doAssert tmp == test_newLit_set
+
+macro test_newLit_ref_object: untyped =
+  var x = RefObject(x: 10)
+  return newLit(x)
+
+block:
+  let x = test_newLit_ref_object()
+  doAssert $(x[]) == "(x: 10)"
+
+macro test_newLit_object_ref_alias: untyped =
+  var x = ObjectRefAlias(x: 10)
+  return newLit(x)
+
+block:
+  let x = test_newLit_object_ref_alias()
+  doAssert $(x[]) == "(x: 10)"
+