fix bug in doAssertRaises when exception==Exception (#10172)
* fix bug in doAssertRaises when exception==Exception * add testcase for doAssertRaises
This commit is contained in:
parent
5101b6befd
commit
319b46230c
2 changed files with 31 additions and 11 deletions
|
|
@ -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])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue