diff options
Diffstat (limited to 'tests/js')
-rw-r--r-- | tests/js/t21439.nim | 5 | ||||
-rw-r--r-- | tests/js/t7109.nim | 8 | ||||
-rw-r--r-- | tests/js/tcodegendeclproc.nim | 2 | ||||
-rw-r--r-- | tests/js/tdanger.nim | 17 | ||||
-rw-r--r-- | tests/js/tjsffi.nim | 5 | ||||
-rw-r--r-- | tests/js/tjsffi_old.nim | 4 | ||||
-rw-r--r-- | tests/js/tjsnimscombined.nim | 1 | ||||
-rw-r--r-- | tests/js/tjsnimscombined.nims | 1 | ||||
-rw-r--r-- | tests/js/tos.nim | 10 | ||||
-rw-r--r-- | tests/js/ttypedarray.nim | 2 |
10 files changed, 35 insertions, 20 deletions
diff --git a/tests/js/t21439.nim b/tests/js/t21439.nim index 972356cd0..3caeb090a 100644 --- a/tests/js/t21439.nim +++ b/tests/js/t21439.nim @@ -1,8 +1,5 @@ -discard """ - action: "compile" -""" - proc test(a: openArray[string]): proc = + let a = @a result = proc = for i in a: discard i diff --git a/tests/js/t7109.nim b/tests/js/t7109.nim index 0d071dbbf..a1a3b718e 100644 --- a/tests/js/t7109.nim +++ b/tests/js/t7109.nim @@ -1,8 +1,8 @@ -discard """ - errormsg: "Closure iterators are not supported by JS backend!" -""" - iterator iter*(): int {.closure.} = yield 3 var x = iter +doAssert x() == 3 + +let fIt = iterator(): int = yield 70 +doAssert fIt() == 70 diff --git a/tests/js/tcodegendeclproc.nim b/tests/js/tcodegendeclproc.nim index 3acf0bc13..33064bdf1 100644 --- a/tests/js/tcodegendeclproc.nim +++ b/tests/js/tcodegendeclproc.nim @@ -3,7 +3,7 @@ discard """ -1 8 ''' - ccodecheck: "'console.log(-1); function fac_' \\d+ '(n_' \\d+ ')'" + ccodecheck: "'console.log(-1); function fac__tcodegendeclproc_u1(n_p0)'" """ proc fac(n: int): int {.codegenDecl: "console.log(-1); function $2($3)".} = return n diff --git a/tests/js/tdanger.nim b/tests/js/tdanger.nim new file mode 100644 index 000000000..9088859a8 --- /dev/null +++ b/tests/js/tdanger.nim @@ -0,0 +1,17 @@ +discard """ + matrix: ";--d:danger" +""" + +block: + proc foo() = + var name = int64(12) + var x = uint32(name) + var m = x + 12 + + var y = int32(name) + var n = y + 1 + + doAssert m == uint32(n + 11) + + + foo() diff --git a/tests/js/tjsffi.nim b/tests/js/tjsffi.nim index b54d13e43..f27ea5546 100644 --- a/tests/js/tjsffi.nim +++ b/tests/js/tjsffi.nim @@ -1,4 +1,5 @@ discard """ +matrix: "--legacy:jsnolambdalifting;" output: ''' 3 2 @@ -180,7 +181,7 @@ block: # Test lit block: # Test bindMethod type TestObject = object a: int - onWhatever: proc(e: int): int + onWhatever: proc(e: int): int {.nimcall.} proc handleWhatever(this: TestObject, e: int): int = e + this.a block: @@ -269,5 +270,5 @@ block: # test ** block: # issue #21208 type MyEnum = enum baz var obj: JsObject - {.emit: "`obj` = {bar: {baz: 123}}".} + {.emit: "`obj` = {bar: {baz: 123}};".} discard obj.bar.baz diff --git a/tests/js/tjsffi_old.nim b/tests/js/tjsffi_old.nim index 19f30ee2c..378003f4e 100644 --- a/tests/js/tjsffi_old.nim +++ b/tests/js/tjsffi_old.nim @@ -279,8 +279,8 @@ block: block: type TestObject = object a: int - onWhatever: proc(e: int): int - proc handleWhatever(this: TestObject, e: int): int = + onWhatever: proc(e: int): int {.nimcall.} + proc handleWhatever(this: TestObject, e: int): int {.nimcall.} = e + this.a proc test(): bool = let obj = TestObject(a: 9, onWhatever: bindMethod(handleWhatever)) diff --git a/tests/js/tjsnimscombined.nim b/tests/js/tjsnimscombined.nim new file mode 100644 index 000000000..4d3e6c453 --- /dev/null +++ b/tests/js/tjsnimscombined.nim @@ -0,0 +1 @@ +import std/jsffi diff --git a/tests/js/tjsnimscombined.nims b/tests/js/tjsnimscombined.nims new file mode 100644 index 000000000..01b93d3fa --- /dev/null +++ b/tests/js/tjsnimscombined.nims @@ -0,0 +1 @@ +# test the condition where both `js` and `nimscript` are defined (nimscript receives priority) diff --git a/tests/js/tos.nim b/tests/js/tos.nim index bfe3cd9b4..40fb52bcf 100644 --- a/tests/js/tos.nim +++ b/tests/js/tos.nim @@ -13,11 +13,9 @@ block: doAssert not "foo".isAbsolute doAssert relativePath("", "bar") == "" doAssert normalizedPath(".///foo//./") == "foo" - let cwd = getCurrentDir() - let isWindows = '\\' in cwd - # defined(windows) doesn't work with -d:nodejs but should - # these actually break because of that (see https://github.com/nim-lang/Nim/issues/13469) - if not isWindows: + when nimvm: discard + else: + let cwd = getCurrentDir() doAssert cwd.isAbsolute - doAssert relativePath(getCurrentDir() / "foo", "bar") == "../foo" + doAssert relativePath(getCurrentDir() / "foo", "bar") == ".." / "foo" diff --git a/tests/js/ttypedarray.nim b/tests/js/ttypedarray.nim index 08b5fcdde..4807cb103 100644 --- a/tests/js/ttypedarray.nim +++ b/tests/js/ttypedarray.nim @@ -1,5 +1,5 @@ discard """ - matrix: "--jsbigint64:off; --jsbigint64:on" + matrix: "--jsbigint64:off -d:nimStringHash2; --jsbigint64:on" """ import std/private/jsutils |