summary refs log tree commit diff stats
path: root/tests/js/tnilstrs.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/js/tnilstrs.nim')
-rw-r--r--tests/js/tnilstrs.nim25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/js/tnilstrs.nim b/tests/js/tnilstrs.nim
new file mode 100644
index 000000000..6c1e4e401
--- /dev/null
+++ b/tests/js/tnilstrs.nim
@@ -0,0 +1,25 @@
+block:
+  var x: string
+  var y = "foo"
+
+  echo x
+  doAssert x == ""
+  doAssert "" == x
+
+  add(x, y)
+  y[0] = 'm'
+  doAssert y == "moo" and x == "foo"
+
+block:
+  var x = "foo".cstring
+  var y: string
+  add(y, x)
+  doAssert y == "foo"
+
+block:
+  type Foo = object
+    a: string
+  var foo = Foo(a: "foo")
+  var y = move foo.a
+  doAssert foo.a.len == 0
+  doAssert y == "foo"