make tests green again
This commit is contained in:
parent
e3379770b2
commit
84c4e7a502
2 changed files with 8 additions and 8 deletions
|
|
@ -3,7 +3,7 @@ discard """
|
||||||
exitcode: 1
|
exitcode: 1
|
||||||
"""
|
"""
|
||||||
|
|
||||||
proc returnsNil(): string = return nil
|
proc returnsNil(): ref int = return nil
|
||||||
|
|
||||||
iterator fields*(a, b: int): int =
|
iterator fields*(a, b: int): int =
|
||||||
if a == b:
|
if a == b:
|
||||||
|
|
@ -17,6 +17,6 @@ proc main(): string =
|
||||||
result = ""
|
result = ""
|
||||||
for i in fields(0, 1):
|
for i in fields(0, 1):
|
||||||
let x = returnsNil()
|
let x = returnsNil()
|
||||||
result &= "string literal " & $x
|
result &= "string literal " & $x[]
|
||||||
|
|
||||||
echo main()
|
echo main()
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ proc `$`*(data: Tcommandline_results): string =
|
||||||
|
|
||||||
# - Parse code
|
# - Parse code
|
||||||
|
|
||||||
template raise_or_quit(exception, message: expr): stmt {.immediate.} =
|
template raise_or_quit(exception, message: untyped) =
|
||||||
## Avoids repeating if check based on the default quit_on_failure variable.
|
## Avoids repeating if check based on the default quit_on_failure variable.
|
||||||
##
|
##
|
||||||
## As a special case, if message has a zero length the call to quit won't
|
## As a special case, if message has a zero length the call to quit won't
|
||||||
|
|
@ -230,15 +230,15 @@ template run_custom_proc(parsed_parameter: Tparsed_parameter,
|
||||||
##
|
##
|
||||||
## Pass in the string of the parameter triggering the call. If the
|
## Pass in the string of the parameter triggering the call. If the
|
||||||
if not custom_validator.isNil:
|
if not custom_validator.isNil:
|
||||||
|
try:
|
||||||
|
let message = custom_validator(parameter, parsed_parameter)
|
||||||
|
if not message.isNil and message.len > 0:
|
||||||
|
raise_or_quit(ValueError, ("Failed to validate value for " &
|
||||||
|
"parameter $1:\n$2" % [escape(parameter), message]))
|
||||||
except:
|
except:
|
||||||
raise_or_quit(ValueError, ("Couldn't run custom proc for " &
|
raise_or_quit(ValueError, ("Couldn't run custom proc for " &
|
||||||
"parameter $1:\n$2" % [escape(parameter),
|
"parameter $1:\n$2" % [escape(parameter),
|
||||||
getCurrentExceptionMsg()]))
|
getCurrentExceptionMsg()]))
|
||||||
let message = custom_validator(parameter, parsed_parameter)
|
|
||||||
if not message.isNil and message.len > 0:
|
|
||||||
raise_or_quit(ValueError, ("Failed to validate value for " &
|
|
||||||
"parameter $1:\n$2" % [escape(parameter), message]))
|
|
||||||
|
|
||||||
|
|
||||||
proc parse_parameter(quit_on_failure: bool, param, value: string,
|
proc parse_parameter(quit_on_failure: bool, param, value: string,
|
||||||
param_kind: Tparam_kind): Tparsed_parameter =
|
param_kind: Tparam_kind): Tparsed_parameter =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue