mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
48 lines
698 B
Nim
48 lines
698 B
Nim
|
|
import
|
|
unittest, macros
|
|
|
|
var
|
|
a = 1
|
|
b = 22
|
|
c = 1
|
|
d = 3
|
|
|
|
suite "my suite":
|
|
setup:
|
|
echo "suite setup"
|
|
var testVar = "from setup"
|
|
|
|
teardown:
|
|
echo "suite teardown"
|
|
|
|
test "first suite test":
|
|
testVar = "modified"
|
|
echo "test var: " & testVar
|
|
check a > b
|
|
|
|
test "second suite test":
|
|
echo "test var: " & testVar
|
|
|
|
proc foo: bool =
|
|
echo "running foo"
|
|
return true
|
|
|
|
proc err =
|
|
raise newException(ArithmeticError, "some exception")
|
|
|
|
test "final test":
|
|
echo "inside suite-less test"
|
|
|
|
check:
|
|
a == c
|
|
foo()
|
|
d > 10
|
|
|
|
test "arithmetic failure":
|
|
expect(ArithmeticError):
|
|
err()
|
|
|
|
expect(ArithmeticError, CatchableError):
|
|
discard foo()
|