testament improvement: allow inline error messages inside test cases (#15294)
* testament support for inline error messages * adapt teffects1.nim test to show the potential
This commit is contained in:
parent
61c85e034d
commit
9a110047cb
3 changed files with 142 additions and 21 deletions
|
|
@ -1,13 +1,5 @@
|
|||
discard """
|
||||
errormsg: "type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'"
|
||||
file: "teffects1.nim"
|
||||
line: 38
|
||||
cmd: "nim check $file"
|
||||
nimout: '''teffects1.nim(22, 28) template/generic instantiation from here
|
||||
teffects1.nim(23, 13) Error: can raise an unlisted exception: ref IOError
|
||||
teffects1.nim(22, 29) Hint: 'IO2Error' is declared but not used [XDeclaredButNotUsed]
|
||||
teffects1.nim(38, 21) Error: type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
|
||||
.raise effects differ'''
|
||||
"""
|
||||
|
||||
type
|
||||
|
|
@ -20,7 +12,10 @@ type
|
|||
proc forw: int {. .}
|
||||
|
||||
proc lier(): int {.raises: [IO2Error].} =
|
||||
writeLine stdout, "arg"
|
||||
#[tt.Hint ^ 'IO2Error' is declared but not used [XDeclaredButNotUsed] ]#
|
||||
writeLine stdout, "arg" #[tt.Error
|
||||
^ can raise an unlisted exception: ref IOError
|
||||
]#
|
||||
|
||||
proc forw: int =
|
||||
raise newException(IOError, "arg")
|
||||
|
|
@ -35,5 +30,9 @@ proc foo(x: int): string {.raises: [ValueError].} =
|
|||
raise newException(ValueError, "Use single digit")
|
||||
$x
|
||||
|
||||
var p: MyProcType = foo
|
||||
var p: MyProcType = foo #[tt.Error
|
||||
^
|
||||
type mismatch: got <proc (x: int): string{.noSideEffect, gcsafe, locks: 0.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
|
||||
|
||||
]#
|
||||
{.pop.}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue