mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 05:20:31 +00:00
committed by
Andreas Rumpf
parent
a6c3bbf01a
commit
befca425c4
@@ -4123,10 +4123,13 @@ else:
|
||||
|
||||
template doAssertRaises*(exception, code: untyped): typed =
|
||||
## Raises ``AssertionError`` if specified ``code`` does not raise the
|
||||
## specified exception.
|
||||
runnableExamples:
|
||||
doAssertRaises(ValueError):
|
||||
raise newException(ValueError, "Hello World")
|
||||
## specified exception. Example:
|
||||
##
|
||||
## .. code-block:: nim
|
||||
## doAssertRaises(ValueError):
|
||||
## raise newException(ValueError, "Hello World")
|
||||
# TODO: investigate why runnableExamples here caused
|
||||
# https://github.com/nim-lang/Nim/issues/8223
|
||||
var wrong = false
|
||||
try:
|
||||
code
|
||||
|
||||
Reference in New Issue
Block a user