Open MilesCranmer opened 7 months ago
Apart from the arguably nicer syntax, what is the benefit of the above compared to
julia> @testset begin
local logi = log(im)
@test imag(logi) == π/2
@test !iszero(real(logi))
end
which is compatible with older Julia versions?
benefit of the above compared to
Better ergonomics. It's a huge pain to need to write out local
for all relevant unittest variables, especially given some of my test suites are 1000s of lines of code. By being less ergonomic it's also less safe, because many people just won't bother to do it – they would need to figure out exactly what variables need to be local
. let ... end
just does this for me automatically. If we can do @testset let
then I can just ctrl-F replace all instances of @testset begin
and be done with it.
Also the nice part about Compat.jl is I can write backwards-compatible code without needing to miss out on the current Julia API goodness.
@aviatesk would you be up for pushing your PR https://github.com/JuliaLang/julia/pull/50151 to here as well? Or maybe comment on if there’s a sensible workaround. Like a @lettestset
macro
The new unit testing syntax on Julia 1.9 is extremely useful. For example:
The downside is that it's only Julia 1.9, so I can't actually use it in my packages, as I want to maintain compatibility with Julia 1.6.
So, it would be great if this syntax could be added to Compat.jl!
Best, Miles