Skip to content

Commit ec62e98

Browse files
committed
fixup(Lib/unittest): skipIf,skipUnless that returns a proc not compile...
...that accepts a body now may discard body if cond is static
1 parent 5d78aa5 commit ec62e98

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/pylib/Lib/unittest/case_py.nim

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,22 @@ template skip*(reason: string): untyped =
109109
110110
proc asis_id[P: proc](x: P): P = x
111111
112-
template skipIf*(condition: bool, reason: string) =
112+
template skipIf*(condition: bool, reason: string): proc =
113113
bind asis_id, skip
114-
if condition:
115-
return skip(reason)
116-
return asis_id
114+
if condition: skip(reason)
115+
else: asis_id
116+
117+
template doIf(cond: bool; body) =
118+
if cond: body
119+
template doIf(cond: static bool; body) =
120+
when cond: body
117121
118122
template skipIf*(condition: bool, reason: string; body) =
123+
bind doIf
119124
addSkip reason
120-
if not condition:
121-
body
125+
doIf not condition, body
122126
123-
template skipUnless*(condition: bool, reason: string) =
127+
template skipUnless*(condition: bool, reason: string): proc =
124128
bind skipIf
125129
skipIf(not condition, reason)
126130

0 commit comments

Comments
 (0)