Skip to content

Commit ebadff4

Browse files
committed
Support interpolation.
1 parent b6b4a08 commit ebadff4

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

src/FileCheck.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ function parse_kwargs(args)
120120
end
121121

122122
# collect checks used in the @filecheck block by piggybacking on macro expansion
123-
const checks = Tuple{Any,Bool,String,String}[]
123+
const checks = Tuple{Any,Bool,String,Any}[]
124124

125125
macro check(args...)
126126
kwargs = parse_kwargs(args[1:end-1])
@@ -266,11 +266,11 @@ macro filecheck(args...)
266266
stmts = Expr[:(local _checks = String[])]
267267
for (cond, literal, name, pattern) in collected
268268
literal_str = literal ? "{LITERAL}" : ""
269-
directive = "$name$literal_str: $pattern"
269+
prefix = "$name$literal_str: "
270270
if cond === nothing
271-
push!(stmts, :(push!(_checks, $directive)))
271+
push!(stmts, :(push!(_checks, $prefix * $(pattern))))
272272
else
273-
push!(stmts, :(if $(cond); push!(_checks, $directive); end))
273+
push!(stmts, :(if $(cond); push!(_checks, $prefix * $(pattern)); end))
274274
end
275275
end
276276
push!(stmts, :(local _check_str = join(_checks, "\n")))

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,4 +332,12 @@ end
332332
end
333333
end
334334

335+
@testset "interpolation" begin
336+
foo = 42
337+
@test @filecheck begin
338+
@check "foo = $foo"
339+
println("foo = 42")
340+
end
341+
end
342+
335343
end # @testset "FileCheck"

0 commit comments

Comments
 (0)