Add test for PR #35 (#37)

* Add test for PR #35
This commit is contained in:
andri lim 2024-01-22 10:45:02 +07:00 committed by GitHub
parent db67e2ad76
commit 13bf4d444d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 2 deletions

View File

@ -20,7 +20,35 @@ discard """
'''
"""
import unittest2, sequtils
import ../unittest2, sequtils
from std/exitprocs import nil
#------------------------------------------------------------------------------
# Tests using backdoors
# This kind of tests should be executed first
#------------------------------------------------------------------------------
suite "PR #35":
setup:
# ensure teardown is called at the end
doAssert(true)
teardown:
if testStatusIMPL != TestStatus.FAILED:
testStatusIMPL = TestStatus.FAILED
exitProcs.setProgramResult(QuitFailure)
debugEcho "PR #35 test FAILED"
else:
testStatusIMPL = TestStatus.OK
exitProcs.setProgramResult(QuitSuccess)
test "something":
# emulate exception
raise newException(ValueError, "error")
#------------------------------------------------------------------------------
# Regular tests
#------------------------------------------------------------------------------
proc doThings(spuds: var int): int =
spuds = 24

View File

@ -1028,7 +1028,7 @@ template fail* =
when declared(testStatusIMPL):
testStatusIMPL = TestStatus.FAILED
programResult = 1
exitProcs.setProgramResult(1)
for formatter in formatters:
let formatter = formatter # avoid lent iterator