I have a template for writing tests
template assertVal*(value, expected, error: untyped): untyped=
## helper function to help write testcases
doAssert value==expected, expectMsg(error, $value, $expected)
I would also like to print the expression that produced value
expectMsg formats the error message to be printed
func expectMsg*(error: string, got: string, expect: string): string=
## Formats message to be printed to terminal after an error
## `error`: The error message formatted for the terminal
## `got`: The incorrect result that was gotten
## `expect`: The correct result
return """$#!
$#: $#
$#: $#
""" % [errorMsg(error.capitalizeAscii), infoMsg("Got "),
got, infoMsg("Expected"), expect]
for example
assertVal(parseMove(index, fenstrings[1]), 0, "error in move parser")
I get:
Error in move parser
Got : 1
Expected: 0
I want it to produce this output
line 2 -> parseMove(index, fenstrings[1])
Error in move parser
Got : 1
Expected: 0