summary refs log tree commit diff stats
path: root/tests/assert
diff options
context:
space:
mode:
authorJacek Sieka <arnetheduck@gmail.com>2020-04-28 19:56:01 +0200
committerGitHub <noreply@github.com>2020-04-28 19:56:01 +0200
commit7d6cbf290a5e0cbce14b9926f57221a017f20a4a (patch)
treef8bf7d55e271571ebbb817ff28858c29e712382b /tests/assert
parentcd9af6b8040bc72985d457e5169e18ded7c107d6 (diff)
downloadNim-7d6cbf290a5e0cbce14b9926f57221a017f20a4a.tar.gz
Error -> Defect for defects (#13908)
* Error -> Defect for defects

The distinction between Error and Defect is subjective,
context-dependent and somewhat arbitrary, so when looking at an
exception, it's hard to guess what it is - this happens often when
looking at a `raises` list _without_ opening the corresponding
definition and digging through layers of inheritance.

With the help of a little consistency in naming, it's at least possible
to start disentangling the two error types and the standard lib can set
a good example here.
Diffstat (limited to 'tests/assert')
-rw-r--r--tests/assert/tassert.nim2
-rw-r--r--tests/assert/tassert2.nim14
-rw-r--r--tests/assert/tassert_c.nim2
3 files changed, 9 insertions, 9 deletions
diff --git a/tests/assert/tassert.nim b/tests/assert/tassert.nim
index 99929f080..a14fec317 100644
--- a/tests/assert/tassert.nim
+++ b/tests/assert/tassert.nim
@@ -10,7 +10,7 @@ proc callC() = callA()
 
 try:
   callC()
-except AssertionError:
+except AssertionDefect:
   write(stdout, "assertion failure!")
 except:
   write(stdout, "unknown exception!")
diff --git a/tests/assert/tassert2.nim b/tests/assert/tassert2.nim
index 3cff47a24..5d849aaad 100644
--- a/tests/assert/tassert2.nim
+++ b/tests/assert/tassert2.nim
@@ -18,12 +18,12 @@ type
 
 try:
   doAssert(false, "msg1") # doAssert test
-except AssertionError as e:
+except AssertionDefect as e:
   assert e.msg.endsWith "tassert2.nim(20, 11) `false` msg1"
 
 try:
   assert false # assert test with no msg
-except AssertionError as e:
+except AssertionDefect as e:
   assert e.msg.endsWith "tassert2.nim(25, 10) `false` "
 
 try:
@@ -31,13 +31,13 @@ try:
   doAssert(a+a==1) # assert test with Ast expression
   # BUG: const folding would make "1+1==1" appear as `false` in
   # assert message
-except AssertionError as e:
+except AssertionDefect as e:
   assert e.msg.endsWith "`a + a == 1` "
 
 try:
   let a = 1
   doAssert a+a==1 # ditto with `doAssert` and no parens
-except AssertionError as e:
+except AssertionDefect as e:
   assert e.msg.endsWith "`a + a == 1` "
 
 proc fooStatic() =
@@ -91,14 +91,14 @@ block: ## checks for issue https://github.com/nim-lang/Nim/issues/8518
 
   try:
     doAssert fun("foo1") == fun("foo2"), "mymsg"
-  except AssertionError as e:
+  except AssertionDefect as e:
     # used to expand out the template instantiaiton, sometimes filling hundreds of lines
     assert e.msg.endsWith ""
 
 block: ## checks for issue https://github.com/nim-lang/Nim/issues/9301
   try:
     doAssert 1 + 1 == 3
-  except AssertionError as e:
+  except AssertionDefect as e:
     # used to const fold as false
     assert e.msg.endsWith "tassert2.nim(100, 14) `1 + 1 == 3` "
 
@@ -106,6 +106,6 @@ block: ## checks AST isn't transformed as it used to
   let a = 1
   try:
     doAssert a > 1
-  except AssertionError as e:
+  except AssertionDefect as e:
     # used to rewrite as `1 < a`
     assert e.msg.endsWith "tassert2.nim(108, 14) `a > 1` "
diff --git a/tests/assert/tassert_c.nim b/tests/assert/tassert_c.nim
index 4357e0584..cbb565f84 100644
--- a/tests/assert/tassert_c.nim
+++ b/tests/assert/tassert_c.nim
@@ -33,7 +33,7 @@ try:
   proc foo() =
     assert(false)
   foo()
-except AssertionError:
+except AssertionDefect:
   let e = getCurrentException()
   let trace = e.getStackTrace
   if tmatch(trace, expected): echo true else: echo "wrong trace:\n" & trace