summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pragmas/tused.nim32
-rw-r--r--tests/stdlib/tunittest.nim15
2 files changed, 39 insertions, 8 deletions
diff --git a/tests/pragmas/tused.nim b/tests/pragmas/tused.nim
index f3126bd45..4a317f874 100644
--- a/tests/pragmas/tused.nim
+++ b/tests/pragmas/tused.nim
@@ -1,13 +1,35 @@
 discard """
-  output: '''8'''
+  nimout: '''
+compile start
+tused.nim(15, 8) Hint: 'tused.echoSub(a: int, b: int)' is declared but not used [XDeclaredButNotUsed]
+compile end'''
+  output: "8\n8"
 """
 
-template implementArithOps(T) =
+static:
+  echo "compile start"
+
+template implementArithOpsOld(T) =
+  proc echoAdd(a, b: T) =
+    echo a + b
+  proc echoSub(a, b: T) =
+    echo a - b
+
+template implementArithOpsNew(T) =
   proc echoAdd(a, b: T) {.used.} =
     echo a + b
   proc echoSub(a, b: T) {.used.} =
     echo a - b
 
-# no warning produced for the unused 'echoSub'
-implementArithOps(int)
-echoAdd 3, 5
+block:
+  # should produce warning for the unused 'echoSub'
+  implementArithOpsOld(int)
+  echoAdd 3, 5
+
+block:
+  # no warning produced for the unused 'echoSub'
+  implementArithOpsNew(int)
+  echoAdd 3, 5
+
+static:
+  echo "compile end"
diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim
index e87cd3508..3f8601323 100644
--- a/tests/stdlib/tunittest.nim
+++ b/tests/stdlib/tunittest.nim
@@ -1,5 +1,11 @@
+discard """
+  nimout: "compile start\ncompile end"
+"""
+
 import unittest, sequtils
 
+static:
+  echo "compile start"
 
 proc doThings(spuds: var int): int =
   spuds = 24
@@ -10,9 +16,9 @@ test "#964":
   check spuds == 24
 
 
-from strutils import toUpper
+from strutils import toUpperAscii
 test "#1384":
-  check(@["hello", "world"].map(toUpper) == @["HELLO", "WORLD"])
+  check(@["hello", "world"].map(toUpperAscii) == @["HELLO", "WORLD"])
 
 
 import options
@@ -57,7 +63,7 @@ suite "suite with only teardown":
 
 suite "suite with only setup":
   setup:
-    var testVar = "from setup"
+    var testVar {.used.} = "from setup"
 
   test "unittest with only setup 1":
     check testVar == "from setup"
@@ -89,3 +95,6 @@ suite "bug #4494":
       var tags = @[1, 2, 3, 4, 5]
       check:
         allIt(0..3, tags[it] != tags[it + 1])
+
+static:
+  echo "compile end"