diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2019-01-04 04:54:02 -0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-01-04 13:54:02 +0100 |
commit | 319b46230cd96fe22a7d95b931e90ccf09783e61 (patch) | |
tree | a5e831377d13b0bbc12be7d0d54da3fa0d9b246f /tests/system | |
parent | 5101b6befd55a7e32694a09a23dc818cb63dcbb6 (diff) | |
download | Nim-319b46230cd96fe22a7d95b931e90ccf09783e61.tar.gz |
fix bug in doAssertRaises when exception==Exception (#10172)
* fix bug in doAssertRaises when exception==Exception * add testcase for doAssertRaises
Diffstat (limited to 'tests/system')
-rw-r--r-- | tests/system/tsystem_misc.nim | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/system/tsystem_misc.nim b/tests/system/tsystem_misc.nim index 98bc3f4a3..f53a86e9a 100644 --- a/tests/system/tsystem_misc.nim +++ b/tests/system/tsystem_misc.nim @@ -112,6 +112,18 @@ doAssertRaises(IndexError): foo(toOpenArray(arrNeg, -1, 0)) doAssertRaises(IndexError): foo(toOpenArray(arrNeg, -1, -3)) +doAssertRaises(Exception): + raise newException(Exception, "foo") + +block: + var didThrow = false + try: + doAssertRaises(IndexError): # should fail since it's wrong exception + raise newException(FieldError, "foo") + except AssertionError: + # ok, throwing was correct behavior + didThrow = true + doAssert didThrow type seqqType = ptr UncheckedArray[int] let qData = cast[seqqType](addr seqq[0]) |