88
88
isfor (ts:: TestsetExpr ) = ts. loops != = nothing
89
89
isfinal (ts:: TestsetExpr ) = isempty (ts. children)
90
90
91
+ struct _Invalid
92
+ global const invalid = _Invalid. instance
93
+ end
94
+
91
95
# replace unqualified `@testset` by TestsetExpr
92
96
function replace_ts (source, mod, x:: Expr , parent)
93
97
if x. head === :macrocall
94
98
name = x. args[1 ]
95
99
if name === Symbol (" @testset" )
96
100
@assert x. args[2 ] isa LineNumberNode
97
101
ts, hasbroken = parse_ts (x. args[2 ], mod, Tuple (x. args[3 : end ]), parent)
98
- ts != = nothing && parent != = nothing && push! (parent. children, ts)
102
+ ts != = invalid && parent != = nothing && push! (parent. children, ts)
99
103
ts, false # hasbroken counts only "proper" @test_broken, not recursive ones
100
104
elseif name === Symbol (" @test_broken" )
101
105
x, true
@@ -116,7 +120,7 @@ function replace_ts(source, mod, x::Expr, parent)
116
120
x, false
117
121
else @label default
118
122
body_br = map (z -> replace_ts (source, mod, z, parent), x. args)
119
- filter! (x -> first (x) != = nothing , body_br)
123
+ filter! (x -> first (x) != = invalid , body_br)
120
124
Expr (x. head, first .(body_br)... ), any (last .(body_br))
121
125
end
122
126
end
@@ -127,7 +131,7 @@ replace_ts(source, mod, x, _) = x, false
127
131
function parse_ts (source:: LineNumberNode , mod:: Module , args:: Tuple , parent= nothing )
128
132
function tserror (msg)
129
133
@error msg _file= String (source. file) _line= source. line _module= mod
130
- nothing , false
134
+ invalid , false
131
135
end
132
136
133
137
isempty (args) &&
@@ -433,7 +437,7 @@ function updatetests!(mod::Module, dup::Bool)
433
437
# the last version; should we delete all of the versions in this case?
434
438
for (tsargs, source) in news
435
439
ts, hasbroken = parse_ts (source, mod, tsargs)
436
- ts === nothing && continue
440
+ ts === invalid && continue
437
441
idx = get! (map, ts. desc, length (tests) + 1 )
438
442
if idx == length (tests) + 1
439
443
push! (tests, ts)
0 commit comments