test1.nim 747 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. discard """
  2. output: "1261129"
  3. """
  4. # This file tests the JavaScript generator
  5. import strutils
  6. var
  7. inputElement = "1123"
  8. proc onButtonClick(inputElement: string) {.exportc.} =
  9. let v = $inputElement
  10. if v.allCharsInSet(WhiteSpace):
  11. echo "only whitespace, hu?"
  12. else:
  13. var x = parseInt(v)
  14. echo x*x
  15. onButtonClick(inputElement)
  16. block:
  17. var s: string
  18. s.add("hi")
  19. doAssert(s == "hi")
  20. block:
  21. var s: string
  22. s.insert("hi", 0)
  23. doAssert(s == "hi")
  24. block:
  25. var s: string
  26. s.setLen(2)
  27. s[0] = 'h'
  28. s[1] = 'i'
  29. doAssert(s == "hi")
  30. block:
  31. var s: seq[int]
  32. s.setLen(2)
  33. doAssert(s == @[0, 0])
  34. block:
  35. var s: seq[int]
  36. s.insert(2, 0)
  37. doAssert(s == @[2])
  38. block:
  39. var s: seq[int]
  40. s.add(2)
  41. doAssert(s == @[2])