summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--testament/categories.nim2
-rw-r--r--tests/config.nims1
-rw-r--r--tests/generics/mdotlookup.nim4
-rw-r--r--tests/iter/tyieldintry.nim60
-rw-r--r--tests/overload/toverload_various.nim2
-rw-r--r--tests/template/template_various.nim6
-rw-r--r--tests/template/tparams_gensymed.nim2
7 files changed, 38 insertions, 39 deletions
diff --git a/testament/categories.nim b/testament/categories.nim
index b5e8a5454..6375105ee 100644
--- a/testament/categories.nim
+++ b/testament/categories.nim
@@ -588,7 +588,7 @@ proc runJoinedTest(r: var TResults, cat: Category, testsDir: string, options: st
           except ValueError:
             # e.g. for `tests/navigator/tincludefile.nim` which have multiple
             # specs; this will be handled elsewhere
-            echo "parseSpec failed for: '$1', assuming this will be handled outside of megatest" % file
+            echo "parseSpec raised ValueError for: '$1', assuming this will be handled outside of megatest" % file
             continue
           if isJoinableSpec(spec):
             specs.add spec
diff --git a/tests/config.nims b/tests/config.nims
index f876cb612..d7f6ae7f9 100644
--- a/tests/config.nims
+++ b/tests/config.nims
@@ -28,6 +28,7 @@ hint("Processing", off)
 # switch("define", "nimTestsEnableFlaky")
 
 # switch("hint", "ConvFromXtoItselfNotNeeded")
+# switch("warningAsError", "InheritFromException") # would require fixing a few tests
 
 # experimental API's are enabled in testament, refs https://github.com/timotheecour/Nim/issues/575
 # sync with `kochdocs.docDefines` or refactor.
diff --git a/tests/generics/mdotlookup.nim b/tests/generics/mdotlookup.nim
index 470fa0a51..3112c133f 100644
--- a/tests/generics/mdotlookup.nim
+++ b/tests/generics/mdotlookup.nim
@@ -1,9 +1,9 @@
-proc baz(o: any): int = 5 # if bar is exported, it works
+proc baz(o: auto): int = 5 # if bar is exported, it works
 
 type MyObj = object
   x: int
 
-proc foo*(b: any) =
+proc foo*(b: auto) =
   var o: MyObj
   echo b.baz, " ", o.x.baz, " ", b.baz()
 
diff --git a/tests/iter/tyieldintry.nim b/tests/iter/tyieldintry.nim
index 3d5260800..9862fe1de 100644
--- a/tests/iter/tyieldintry.nim
+++ b/tests/iter/tyieldintry.nim
@@ -1,17 +1,15 @@
 discard """
-targets: "c"
-output: "ok"
+  targets: "c cpp"
 """
-var closureIterResult = newSeq[int]()
 
-# XXX Investigate why this fails now for 'nim cpp'
+var closureIterResult = newSeq[int]()
 
 proc checkpoint(arg: int) =
   closureIterResult.add(arg)
 
 type
-  TestException = object of Exception
-  AnotherException = object of Exception
+  TestError = object of CatchableError
+  AnotherError = object of CatchableError
 
 proc testClosureIterAux(it: iterator(): int, exceptionExpected: bool, expectedResults: varargs[int]) =
   closureIterResult.setLen(0)
@@ -21,7 +19,7 @@ proc testClosureIterAux(it: iterator(): int, exceptionExpected: bool, expectedRe
   try:
     for i in it():
       closureIterResult.add(i)
-  except TestException:
+  except TestError:
     exceptionCaught = true
 
   if closureIterResult != @expectedResults or exceptionCaught != exceptionExpected:
@@ -39,8 +37,8 @@ proc test(it: iterator(): int, expectedResults: varargs[int]) =
 proc testExc(it: iterator(): int, expectedResults: varargs[int]) =
   testClosureIterAux(it, true, expectedResults)
 
-proc raiseException() =
-  raise newException(TestException, "Test exception!")
+proc raiseTestError() =
+  raise newException(TestError, "Test exception!")
 
 block:
   iterator it(): int {.closure.} =
@@ -58,8 +56,8 @@ block:
     yield 0
     try:
       checkpoint(1)
-      raiseException()
-    except TestException:
+      raiseTestError()
+    except TestError:
       checkpoint(2)
       yield 3
       checkpoint(4)
@@ -89,7 +87,7 @@ block:
     yield 0
     try:
       yield 1
-      raiseException()
+      raiseTestError()
       yield 2
     finally:
       checkpoint(3)
@@ -103,8 +101,8 @@ block:
   iterator it(): int {.closure.} =
     try:
       try:
-        raiseException()
-      except AnotherException:
+        raiseTestError()
+      except AnotherError:
         yield 123
       finally:
         checkpoint(3)
@@ -117,8 +115,8 @@ block:
   iterator it(): int {.closure.} =
     try:
       yield 1
-      raiseException()
-    except AnotherException:
+      raiseTestError()
+    except AnotherError:
       checkpoint(123)
     finally:
       checkpoint(2)
@@ -134,12 +132,12 @@ block:
         yield 1
         try:
           yield 2
-          raiseException()
-        except AnotherException:
+          raiseTestError()
+        except AnotherError:
           yield 123
         finally:
           yield 3
-      except AnotherException:
+      except AnotherError:
         yield 124
       finally:
         yield 4
@@ -170,10 +168,10 @@ block:
     try:
       try:
         yield 0
-        raiseException()
+        raiseTestError()
       finally:
         checkpoint(1)
-    except TestException:
+    except TestError:
       yield 2
       return
     finally:
@@ -188,10 +186,10 @@ block:
     try:
       try:
         yield 0
-        raiseException()
+        raiseTestError()
       finally:
         return # Return in finally should stop exception propagation
-    except AnotherException:
+    except AnotherError:
       yield 2
       return
     finally:
@@ -228,9 +226,9 @@ block:
     var foo = 123
     let i = try:
         yield 0
-        raiseException()
+        raiseTestError()
         1
-      except TestException as e:
+      except TestError as e:
         assert(e.msg == "Test exception!")
         case foo
         of 1:
@@ -262,9 +260,9 @@ block:
     template tryexcept: int =
       try:
         yield 1
-        raiseException()
+        raiseTestError()
         123
-      except TestException:
+      except TestError:
         yield 2
         checkpoint(3)
         4
@@ -323,11 +321,11 @@ block:
     for i in 0 .. 1:
       try:
         yield 1
-        raiseException()
-      except TestException as e:
+        raiseTestError()
+      except TestError as e:
         doAssert(e.msg == "Test exception!")
         yield 2
-      except AnotherException:
+      except AnotherError:
         yield 123
       except:
         yield 1234
@@ -497,5 +495,3 @@ block: #17849 - yield in case subject
     yield 5
 
   test(it, 1, 2, 13, 5)
-
-echo "ok"
diff --git a/tests/overload/toverload_various.nim b/tests/overload/toverload_various.nim
index f913ce3ee..55a8d17e6 100644
--- a/tests/overload/toverload_various.nim
+++ b/tests/overload/toverload_various.nim
@@ -395,7 +395,7 @@ block:
   template bar2[F,T](x: FooUn[F,T]): int = 1
   template bar2[F,T1,T2](x: FooBi[F,T1,T2]): int = 2
 
-  proc test(x: any, n: int) =
+  proc test(x: auto, n: int) =
     doAssert(foo1(x) == n)
     doAssert(foo2(x) == n)
     doAssert(bar1(x) == n)
diff --git a/tests/template/template_various.nim b/tests/template/template_various.nim
index 75226ea2d..e7a2be748 100644
--- a/tests/template/template_various.nim
+++ b/tests/template/template_various.nim
@@ -94,7 +94,7 @@ block generic_templates:
 
   var i3: int = t1[int]("xx")
 
-
+from strutils import contains
 
 block tgetast_typeliar:
   proc error(s: string) = quit s
@@ -111,7 +111,9 @@ block tgetast_typeliar:
     var message : NimNode = newLit(condition.repr)
     # echo message
     result = getAst assertOrReturn2(condition, message)
-    echo result.repr
+    # echo result.repr
+    let s = result.repr
+    doAssert """error("Assertion failed:""" in s
 
   proc point(size: int16): tuple[x, y: int16] =
     # returns random point in square area with given `size`
diff --git a/tests/template/tparams_gensymed.nim b/tests/template/tparams_gensymed.nim
index 1444667f4..b68d7e253 100644
--- a/tests/template/tparams_gensymed.nim
+++ b/tests/template/tparams_gensymed.nim
@@ -72,7 +72,7 @@ proc concreteProc(x: int) =
   forStatic i, 0..3:
     echo i
 
-proc genericProc(x: any) =
+proc genericProc(x: auto) =
   forStatic i, 0..3:
     echo i