diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-09-07 01:54:59 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-09-07 01:54:59 +0200 |
commit | af1e84f54da32b5e8e917edc533c6efa6846acc2 (patch) | |
tree | 7f5a361e855356ae0a4900a1e17b78956436c648 /tests/js | |
parent | c033ff990acceac6d2095242fa17501e98555973 (diff) | |
download | Nim-af1e84f54da32b5e8e917edc533c6efa6846acc2.tar.gz |
Automatic deref for everything but pointers in asm/emit (#8891)
Fixes #7249
Diffstat (limited to 'tests/js')
-rw-r--r-- | tests/js/t7249.nim | 21 | ||||
-rw-r--r-- | tests/js/tmangle.nim | 8 | ||||
-rw-r--r-- | tests/js/tstringitems.nim | 2 |
3 files changed, 26 insertions, 5 deletions
diff --git a/tests/js/t7249.nim b/tests/js/t7249.nim new file mode 100644 index 000000000..52eee2f7c --- /dev/null +++ b/tests/js/t7249.nim @@ -0,0 +1,21 @@ +discard """ + output: ''' +a -> 2 +a <- 2 +''' +""" + +import jsffi + +var a = JsAssoc[cstring, int]{a: 2} + +for z, b in a: + echo z, " -> ", b + +proc f = + var a = JsAssoc[cstring, int]{a: 2} + + for z, b in a: + echo z, " <- ", b + +f() diff --git a/tests/js/tmangle.nim b/tests/js/tmangle.nim index c4167ba39..c97bf7029 100644 --- a/tests/js/tmangle.nim +++ b/tests/js/tmangle.nim @@ -27,10 +27,10 @@ block: var global = T(a: 11, b: "foo") proc test(): bool = var obj = T(a: 11, b: "foo") - {. emit: [result, " = (", obj.addr[], "[0].a == 11);"] .} - {. emit: [result, " = ", result, " && (", obj.addr[], "[0].b == \"foo\");"] .} - {. emit: [result, " = ", result, " && (", global, "[0].a == 11);"] .} - {. emit: [result, " = ", result, " && (", global, "[0].b == \"foo\");"] .} + {. emit: [result, " = (", obj.addr[], ".a == 11);"] .} + {. emit: [result, " = ", result, " && (", obj.addr[], ".b == \"foo\");"] .} + {. emit: [result, " = ", result, " && (", global, ".a == 11);"] .} + {. emit: [result, " = ", result, " && (", global, ".b == \"foo\");"] .} echo test() # Test addr of field: diff --git a/tests/js/tstringitems.nim b/tests/js/tstringitems.nim index ff016642e..f09793dde 100644 --- a/tests/js/tstringitems.nim +++ b/tests/js/tstringitems.nim @@ -45,7 +45,7 @@ block: # Test compile-time binary data generation, invalid unicode block: # Test unicode strings const constStr = "Привет!" var jsStr : cstring - {.emit: """`jsStr`[0] = "Привет!";""".} + {.emit: """`jsStr` = "Привет!";""".} doAssert($jsStr == constStr) var runtimeStr = "При" |