summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/enum/tenumitems.nim2
-rw-r--r--tests/js/taddr.nim8
-rw-r--r--tests/js/testmagic.nim5
-rw-r--r--tests/js/testobjs.nim12
-rw-r--r--tests/js/trefbyvar.nim35
-rw-r--r--tests/js/tunittests.nim5
-rw-r--r--tests/misc/tissue710.nim2
-rw-r--r--tests/misc/tnoop.nim2
-rw-r--r--tests/modules/topaque.nim8
-rw-r--r--tests/parallel/tptr_to_ref.nim26
-rw-r--r--tests/stdlib/tunittest.nim21
-rw-r--r--tests/tuples/twrongtupleaccess.nim2
-rw-r--r--tests/vm/tconstobj.nim14
13 files changed, 124 insertions, 18 deletions
diff --git a/tests/enum/tenumitems.nim b/tests/enum/tenumitems.nim
index 04737fa9e..38233aad7 100644
--- a/tests/enum/tenumitems.nim
+++ b/tests/enum/tenumitems.nim
@@ -1,6 +1,6 @@
 discard """
   line: 7
-  errormsg: "undeclared identifier: 'items'"
+  errormsg: "attempting to call undeclared routine: 'items'"
 """
 
 type a = enum b,c,d
diff --git a/tests/js/taddr.nim b/tests/js/taddr.nim
index 6a60aa902..f9c89fbc3 100644
--- a/tests/js/taddr.nim
+++ b/tests/js/taddr.nim
@@ -1,3 +1,7 @@
+discard """
+  action: run
+"""
+
 type T = object
   x: int
   s: string
@@ -29,8 +33,10 @@ doAssert objDeref.x == 42
 obj.s = "lorem ipsum dolor sit amet"
 var indexAddr = addr(obj.s[2])
 
-doAssert indexAddr[] == '4'
+doAssert indexAddr[] == 'r'
 
 indexAddr[] = 'd'
 
 doAssert indexAddr[] == 'd'
+
+doAssert obj.s == "lodem ipsum dolor sit amet"
diff --git a/tests/js/testmagic.nim b/tests/js/testmagic.nim
index 5f793ae05..8e06f1a9b 100644
--- a/tests/js/testmagic.nim
+++ b/tests/js/testmagic.nim
@@ -1,5 +1,7 @@
 discard """
-  output: '''true'''
+  output: '''true
+123
+'''
 """
 
 # This file tests some magic
@@ -7,3 +9,4 @@ discard """
 var foo = cstring("foo")
 var bar = cstring("foo")
 echo(foo == bar)
+echo "01234"[1 .. ^2]
diff --git a/tests/js/testobjs.nim b/tests/js/testobjs.nim
index 4fb9a83dc..0166c0f38 100644
--- a/tests/js/testobjs.nim
+++ b/tests/js/testobjs.nim
@@ -1,3 +1,7 @@
+discard """
+  action: run
+"""
+
 ## Tests javascript object generation
 
 type
@@ -28,7 +32,7 @@ var
   recurse1 = Recurse[int](data: 1, next: recurse2)
 
 
-assert(test.name == "Jorden")
-assert(knight.age == 19)
-assert(knight.item.price == 50)
-assert(recurse1.next.next.data == 3)
+doAssert test.name == "Jorden"
+doAssert knight.age == 19
+doAssert knight.item.price == 50
+doAssert recurse1.next.next.data == 3
diff --git a/tests/js/trefbyvar.nim b/tests/js/trefbyvar.nim
new file mode 100644
index 000000000..68dd36543
--- /dev/null
+++ b/tests/js/trefbyvar.nim
@@ -0,0 +1,35 @@
+discard """
+  output: '''0
+5
+0
+5'''
+"""
+
+# bug #2476
+
+type A = ref object
+    m: int
+
+proc f(a: var A) =
+    var b: A
+    b.new()
+    b.m = 5
+    a = b
+
+var t: A
+t.new()
+
+echo t.m
+t.f()
+echo t.m
+
+proc main =
+  # now test the same for locals
+  var t: A
+  t.new()
+
+  echo t.m
+  t.f()
+  echo t.m
+
+main()
diff --git a/tests/js/tunittests.nim b/tests/js/tunittests.nim
index 8a264a5e0..4b09c99a9 100644
--- a/tests/js/tunittests.nim
+++ b/tests/js/tunittests.nim
@@ -1,10 +1,7 @@
 discard """
-  disabled: "true"
+  output: '''[OK] >:)'''
 """
 
-# Unittest uses lambdalifting at compile-time which we disable for the JS
-# codegen! So this cannot and will not work for quite some time.
-
 import unittest
 
 suite "Bacon":
diff --git a/tests/misc/tissue710.nim b/tests/misc/tissue710.nim
index ecfdf653e..3b6d3e5f3 100644
--- a/tests/misc/tissue710.nim
+++ b/tests/misc/tissue710.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tissue710.nim"
   line: 8
-  errorMsg: "undeclared identifier: '||'"
+  errorMsg: "attempting to call undeclared routine: '||'"
 """
 var sum = 0
 for x in 3..1000:
diff --git a/tests/misc/tnoop.nim b/tests/misc/tnoop.nim
index 10c2eb2ec..1e3fbe6cf 100644
--- a/tests/misc/tnoop.nim
+++ b/tests/misc/tnoop.nim
@@ -1,7 +1,7 @@
 discard """
   file: "tnoop.nim"
   line: 11
-  errormsg: "undeclared identifier: 'a'"
+  errormsg: "attempting to call undeclared routine: 'a'"
 """
 
 
diff --git a/tests/modules/topaque.nim b/tests/modules/topaque.nim
index f0587c959..84e2388bc 100644
--- a/tests/modules/topaque.nim
+++ b/tests/modules/topaque.nim
@@ -1,16 +1,16 @@
 discard """
   file: "topaque.nim"
   line: 16
-  errormsg: "undeclared identifier: \'buffer\'"
+  errormsg: "undeclared field: \'buffer\'"
 """
 # Test the new opaque types
 
-import 
+import
   mopaque
-  
+
 var
   L: TLexer
-  
+
 L.filename = "ha"
 L.line = 34
 L.buffer[0] = '\0' #ERROR_MSG undeclared field: 'buffer'
diff --git a/tests/parallel/tptr_to_ref.nim b/tests/parallel/tptr_to_ref.nim
new file mode 100644
index 000000000..66d618481
--- /dev/null
+++ b/tests/parallel/tptr_to_ref.nim
@@ -0,0 +1,26 @@
+# bug #2854
+
+import locks, threadpool, osproc
+
+const MAX_WORKERS = 10
+
+type
+  Killer = object
+    lock: Lock
+    bailed {.guard: lock.}: bool
+    processes {.guard: lock.}: array[0..MAX_WORKERS-1, foreign ptr Process]
+
+template hold(lock: Lock, body: stmt) =
+  lock.acquire
+  defer: lock.release
+  {.locks: [lock].}:
+    body
+
+proc initKiller*(): Killer =
+  initLock(result.lock)
+  result.lock.hold:
+    result.bailed = false
+    for i, _ in result.processes:
+      result.processes[i] = nil
+
+var killer = initKiller()
diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim
new file mode 100644
index 000000000..b23b3cdab
--- /dev/null
+++ b/tests/stdlib/tunittest.nim
@@ -0,0 +1,21 @@
+import unittest
+
+
+proc doThings(spuds: var int): int =
+  spuds = 24
+  return 99
+test "#964":
+  var spuds = 0
+  check doThings(spuds) == 99
+  check spuds == 24
+
+
+from strutils import toUpper
+test "#1384":
+  check(@["hello", "world"].map(toUpper) == @["HELLO", "WORLD"])
+
+
+import options
+test "unittest typedescs":
+  check(none(int) == none(int))
+  check(none(int) != some(1))
diff --git a/tests/tuples/twrongtupleaccess.nim b/tests/tuples/twrongtupleaccess.nim
index 1a9ae64a2..b1684b097 100644
--- a/tests/tuples/twrongtupleaccess.nim
+++ b/tests/tuples/twrongtupleaccess.nim
@@ -1,7 +1,7 @@
 discard """
   file: "twrongtupleaccess.nim"
   line: 9
-  errormsg: "undeclared identifier: \'setBLAH\'"
+  errormsg: "attempting to call undeclared routine: \'setBLAH\'"
 """
 # Bugfix
 
diff --git a/tests/vm/tconstobj.nim b/tests/vm/tconstobj.nim
new file mode 100644
index 000000000..414708945
--- /dev/null
+++ b/tests/vm/tconstobj.nim
@@ -0,0 +1,14 @@
+discard """
+  output: '''(name: hello)'''
+"""
+
+# bug #2774
+
+type Foo = object
+  name: string
+
+const fooArray = [
+  Foo(name: "hello")
+]
+
+echo fooArray[0]