summary refs log tree commit diff stats
path: root/tests/js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/js')
-rw-r--r--tests/js/taddr.nim7
-rw-r--r--tests/js/tbyvar.nim8
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/js/taddr.nim b/tests/js/taddr.nim
index 1fba30d55..d8ff4c11b 100644
--- a/tests/js/taddr.nim
+++ b/tests/js/taddr.nim
@@ -70,3 +70,10 @@ proc testPtr(p: pointer, a: int) =
 var i = 123
 testPtr(addr i, 5)
 doAssert(i == 124)
+
+var someGlobal = 5
+proc getSomeGlobalPtr(): ptr int = addr someGlobal
+let someGlobalPtr = getSomeGlobalPtr()
+doAssert(someGlobalPtr[] == 5)
+someGlobalPtr[] = 10
+doAssert(someGlobal == 10)
diff --git a/tests/js/tbyvar.nim b/tests/js/tbyvar.nim
index 9714cd56b..40aebd13b 100644
--- a/tests/js/tbyvar.nim
+++ b/tests/js/tbyvar.nim
@@ -41,3 +41,11 @@ proc bar(s: var seq[int], a: int) =
   foo(s)
 s.bar(5)
 doAssert(s == @[123, 1])
+
+import tables
+block: # Test get addr of byvar return value
+  var t = initTable[string, int]()
+  t["hi"] = 5
+  let a = addr t["hi"]
+  a[] = 10
+  doAssert(t["hi"] == 10)