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/t21439.nim5
-rw-r--r--tests/js/t7109.nim8
-rw-r--r--tests/js/tasyncjs.nim5
-rw-r--r--tests/js/tcodegendeclproc.nim2
-rw-r--r--tests/js/tdanger.nim17
-rw-r--r--tests/js/tjsffi.nim9
-rw-r--r--tests/js/tjsffi_old.nim4
-rw-r--r--tests/js/tjsnimscombined.nim1
-rw-r--r--tests/js/tjsnimscombined.nims1
-rw-r--r--tests/js/tnativeexc.nim2
-rw-r--r--tests/js/tos.nim10
-rw-r--r--tests/js/ttypedarray.nim2
12 files changed, 46 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/tasyncjs.nim b/tests/js/tasyncjs.nim
index 3de143643..f3b273c44 100644
--- a/tests/js/tasyncjs.nim
+++ b/tests/js/tasyncjs.nim
@@ -99,4 +99,9 @@ block asyncPragmaInType:
   proc foo() {.async.} = discard
   var x: Handler = foo
 
+block: # 13341
+  proc f {.async.} =
+    proc g: int =
+      result = 123
+
 discard main()
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 2e57f70c1..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:
@@ -265,3 +266,9 @@ block: # test **
   doAssert to(`**`(a + a, b), int) == 2
 
   doAssert to(`**`(toJs(1) + toJs(1), toJs(2)), int) == 4
+
+block: # issue #21208
+  type MyEnum = enum baz
+  var obj: JsObject
+  {.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/tnativeexc.nim b/tests/js/tnativeexc.nim
index ea371c1cd..8b2b43e8f 100644
--- a/tests/js/tnativeexc.nim
+++ b/tests/js/tnativeexc.nim
@@ -18,7 +18,7 @@ try:
 except JsEvalError:
   doAssert false
 except JsSyntaxError as se:
-  doAssert se.message == "Unexpected token ; in JSON at position 0"
+  doAssert se.message == "Unexpected token ';', \";;\" is not valid JSON"
 except JsError as e:
   doAssert false
 
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