summary refs log tree commit diff stats
path: root/tests/js/test1.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/js/test1.nim')
-rw-r--r--tests/js/test1.nim41
1 files changed, 35 insertions, 6 deletions
diff --git a/tests/js/test1.nim b/tests/js/test1.nim
index 012b98833..7ad3f85f6 100644
--- a/tests/js/test1.nim
+++ b/tests/js/test1.nim
@@ -1,19 +1,17 @@
 discard """
-  cmd: "nimrod js --hints:on $# $#"
   output: "1261129"
 """
 
-# This file tests the ECMAScript generator
+# This file tests the JavaScript generator
 
-import
-  dom, strutils
+import strutils
 
 var
   inputElement = "1123"
 
-proc OnButtonClick(inputElement: string) {.exportc.} =
+proc onButtonClick(inputElement: string) {.exportc.} =
   let v = $inputElement
-  if v.allCharsInSet(whiteSpace):
+  if v.allCharsInSet(WhiteSpace):
     echo "only whitespace, hu?"
   else:
     var x = parseInt(v)
@@ -21,3 +19,34 @@ proc OnButtonClick(inputElement: string) {.exportc.} =
 
 onButtonClick(inputElement)
 
+block:
+  var s: string
+  s.add("hi")
+  doAssert(s == "hi")
+
+block:
+  var s: string
+  s.insert("hi", 0)
+  doAssert(s == "hi")
+
+block:
+  var s: string
+  s.setLen(2)
+  s[0] = 'h'
+  s[1] = 'i'
+  doAssert(s == "hi")
+
+block:
+  var s: seq[int]
+  s.setLen(2)
+  doAssert(s == @[0, 0])
+
+block:
+  var s: seq[int]
+  s.insert(2, 0)
+  doAssert(s == @[2])
+
+block:
+  var s: seq[int]
+  s.add(2)
+  doAssert(s == @[2])