Skip to content

Commit

Permalink
remove catch-all doAssertRaises overload from this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Nov 10, 2020
1 parent 6d0bdb7 commit d15a7d3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

- Removed deprecated `iup` module from stdlib, it has already moved to [nimble](https://github.com/nim-lang/iup).

- `doAssertRaises` now correctly handles foreign exceptions; it also allows a catch-all form that includes foreign exceptions.
- `doAssertRaises` now correctly handles foreign exceptions.

## Language changes

Expand Down
18 changes: 1 addition & 17 deletions lib/system/assertions.nim
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ template onFailedAssert*(msg, code: untyped): untyped {.dirty.} =
code

template doAssertRaises*(exception: typedesc, code: untyped) =
## Raises ``AssertionDefect`` if specified ``code`` does not raise the
## specified exception.
## Raises ``AssertionDefect`` if specified ``code`` does not raise `exception`.
## Example:
##
## .. code-block:: nim
Expand Down Expand Up @@ -110,18 +109,3 @@ template doAssertRaises*(exception: typedesc, code: untyped) =
except: raisedForeign()
if wrong:
raiseAssert(begin & " nothing was raised" & msgEnd)

template doAssertRaises*(code: untyped) =
## Raises `AssertionDefect` if specified `code` does not raise anything,
## including a foreign exception.
## Example:
##
## .. code-block:: nim
## doAssertRaises: raise newException(ValueError, "Hello World")
var wrong = false
try:
if true: code
wrong = true
except: discard
if wrong:
raiseAssert("nothing was raised by: " & astToStr(code))

0 comments on commit d15a7d3

Please sign in to comment.