From 5ee263a62ccb0a0453d62b18d33e41c5f414f75f Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Tue, 9 Jun 2026 16:56:44 +0200 Subject: [PATCH 01/12] fix locally-defined overwrites in at-test_trixi_include --- src/macros.jl | 25 +++++++++++++++++++++---- test/test_test_trixi_include.jl | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/macros.jl b/src/macros.jl index a8dab61..f7503ca 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -74,18 +74,35 @@ macro test_trixi_include_base(elixir, args...) local atol = get_kwarg(args, :atol, atol_default) local rtol = get_kwarg(args, :rtol, rtol_default) - local kwargs = Pair{Symbol, Any}[] + # Build escaped kwarg expressions. For bare-symbol values, we use @isdefined at + # runtime to dispatch between two cases: + # - Locally-defined values (e.g. `baz_override`): @isdefined returns true (same + # world age), so the actual value is evaluated and passed to trixi_include. + # - Elixir-internal variable references: @isdefined + # returns false because bindings set inside Base.include have a newer world age + # and are invisible to the compiled testset closure. The Symbol is passed instead, + # so trixi_include can embed it as a variable reference resolved inside the elixir. + # For non-Symbol expressions (closures, calls, literals), always evaluate at call site. + local kwarg_exprs = Expr[] for arg in args if (arg.head == :(=) && !(arg.args[1] in (:additional_ignore_content, :l2, :linf, :RealT_for_test_tolerances, :atol, :rtol))) - push!(kwargs, Pair(arg.args...)) + key = arg.args[1] + val = arg.args[2] + if val isa Symbol + push!(kwarg_exprs, + Expr(:kw, key, + esc(:((@isdefined $val) ? $val : $(QuoteNode(val)))))) + else + push!(kwarg_exprs, Expr(:kw, key, esc(val))) + end end end # if `maxiters` is set in tests, it is usually set to a small number to # run only a few steps - ignore possible warnings coming from that - if any(==(:maxiters) ∘ first, kwargs) + if any(e -> e.args[1] == :maxiters, kwarg_exprs) args = append_to_kwargs(args, :additional_ignore_content, [ r"┌ Warning: Verbosity toggle: max_iters \n│ Interrupted\. Larger maxiters is needed\..*\n└ @ SciMLBase .+\n", @@ -99,7 +116,7 @@ macro test_trixi_include_base(elixir, args...) mpi_isroot() && println($(esc(elixir))) # evaluate examples in the scope of the module they're called from - @trixi_test_nowarn trixi_include(@__MODULE__, $(esc(elixir)); $kwargs...) $additional_ignore_content + @trixi_test_nowarn trixi_include(@__MODULE__, $(esc(elixir)); $(kwarg_exprs...)) $additional_ignore_content # if present, compare l2 and linf errors against reference values if !isnothing($l2) || !isnothing($linf) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index bc3e22a..e987eed 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -138,6 +138,39 @@ end end end + @trixi_testset "locally defined override" begin + example = """ + baz = 42 + """ + + mktemp() do path, io + write(io, example) + close(io) + + # overwrite included variable by a locally defined value (not a module global) + local_baz = 7 + @test_trixi_include_base(path, baz=local_baz) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :baz) + @test (@invokelatest mod.baz) == 7 + else + @test @isdefined baz + @test baz == 7 + end + + @test_trixi_include(path, baz=local_baz) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :baz) + @test (@invokelatest mod.baz) == 7 + else + @test @isdefined baz + @test baz == 7 + end + end + end + @trixi_testset "additional_ignore_content" begin example = """ @warn "Test warning" From 17884fb9624ce7b6e17a1c52a797e98b5cb446cc Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Tue, 9 Jun 2026 17:15:35 +0200 Subject: [PATCH 02/12] fix for julia v1.10 --- src/macros.jl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/macros.jl b/src/macros.jl index f7503ca..9730d21 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -74,15 +74,21 @@ macro test_trixi_include_base(elixir, args...) local atol = get_kwarg(args, :atol, atol_default) local rtol = get_kwarg(args, :rtol, rtol_default) - # Build escaped kwarg expressions. For bare-symbol values, we use @isdefined at - # runtime to dispatch between two cases: - # - Locally-defined values (e.g. `baz_override`): @isdefined returns true (same - # world age), so the actual value is evaluated and passed to trixi_include. - # - Elixir-internal variable references: @isdefined - # returns false because bindings set inside Base.include have a newer world age - # and are invisible to the compiled testset closure. The Symbol is passed instead, - # so trixi_include can embed it as a variable reference resolved inside the elixir. + # Build escaped kwarg expressions. For bare-symbol values there are three cases: + # 1. Symbol is also a key in this kwarg list (e.g. `seed=6, x=seed`): always pass + # as Symbol so trixi_include resolves it inside the elixir after the other + # override (seed=6) has been applied. + # 2. Locally-defined values (e.g. `baz_override` defined in the testset body): + # @isdefined returns true (same world age), so the actual value is passed. + # 3. Elixir-internal variable references (e.g. bare `x=seed` with no seed= key): + # on Julia >= 1.12, @isdefined returns false because bindings set inside + # Base.include have a newer world age; on older Julia the value is visible and + # also correct (same as the elixir default). # For non-Symbol expressions (closures, calls, literals), always evaluate at call site. + local kwarg_keys = Set(arg.args[1] for arg in args + if arg.head == :(=) && + !(arg.args[1] in (:additional_ignore_content, :l2, :linf, + :RealT_for_test_tolerances, :atol, :rtol))) local kwarg_exprs = Expr[] for arg in args if (arg.head == :(=) && @@ -90,7 +96,12 @@ macro test_trixi_include_base(elixir, args...) :RealT_for_test_tolerances, :atol, :rtol))) key = arg.args[1] val = arg.args[2] - if val isa Symbol + if val isa Symbol && val in kwarg_keys + # Case 1: chained override — pass as Symbol for elixir-internal resolution + push!(kwarg_exprs, Expr(:kw, key, QuoteNode(val))) + elseif val isa Symbol + # Cases 2 & 3: use @isdefined to capture locally-defined values while + # falling back to Symbol for elixir-internal references push!(kwarg_exprs, Expr(:kw, key, esc(:((@isdefined $val) ? $val : $(QuoteNode(val)))))) From bdd9c2e9e32a93a65bfac437dd85499bab5664f0 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Tue, 9 Jun 2026 17:18:28 +0200 Subject: [PATCH 03/12] format --- src/macros.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/macros.jl b/src/macros.jl index 9730d21..e9a3949 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -85,7 +85,8 @@ macro test_trixi_include_base(elixir, args...) # Base.include have a newer world age; on older Julia the value is visible and # also correct (same as the elixir default). # For non-Symbol expressions (closures, calls, literals), always evaluate at call site. - local kwarg_keys = Set(arg.args[1] for arg in args + local kwarg_keys = Set(arg.args[1] + for arg in args if arg.head == :(=) && !(arg.args[1] in (:additional_ignore_content, :l2, :linf, :RealT_for_test_tolerances, :atol, :rtol))) From ed25f76ac58099c7d382bfff8c4cf34499550312 Mon Sep 17 00:00:00 2001 From: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> Date: Tue, 9 Jun 2026 19:25:09 +0200 Subject: [PATCH 04/12] remove unclear reference Co-authored-by: Marco Artiano <57838732+MarcoArtiano@users.noreply.github.com> --- src/macros.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/macros.jl b/src/macros.jl index e9a3949..3cfd974 100644 --- a/src/macros.jl +++ b/src/macros.jl @@ -78,7 +78,7 @@ macro test_trixi_include_base(elixir, args...) # 1. Symbol is also a key in this kwarg list (e.g. `seed=6, x=seed`): always pass # as Symbol so trixi_include resolves it inside the elixir after the other # override (seed=6) has been applied. - # 2. Locally-defined values (e.g. `baz_override` defined in the testset body): + # 2. Locally-defined values defined in the testset body: # @isdefined returns true (same world age), so the actual value is passed. # 3. Elixir-internal variable references (e.g. bare `x=seed` with no seed= key): # on Julia >= 1.12, @isdefined returns false because bindings set inside From ec15b71b738b311e6ecbe84fcac1dbef7ce38fef Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Wed, 10 Jun 2026 09:59:09 +0200 Subject: [PATCH 05/12] add more tests --- test/test_test_trixi_include.jl | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index e987eed..f2b7da9 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -138,6 +138,45 @@ end end end + @trixi_testset "chained override, all assignment forms" begin + example = """ + seed = 42 + f(; x = 0) = x + x = 1 + x_kw_pos = f(x = 1) + x_kw_semi = f(; x = 1) + """ + + mktemp() do path, io + write(io, example) + close(io) + + @test_trixi_include_base(path, seed=6, x=seed) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test (@invokelatest mod.x) == 6 + @test (@invokelatest mod.x_kw_pos) == 6 + @test (@invokelatest mod.x_kw_semi) == 6 + else + @test x_regular == 6 + @test x_kw_pos == 6 + @test x_kw_semi == 6 + end + + @test_trixi_include(path, seed=6, x=seed) + if VERSION >= v"1.12" + mod = @__MODULE__ + @test (@invokelatest mod.x) == 6 + @test (@invokelatest mod.x_kw_pos) == 6 + @test (@invokelatest mod.x_kw_semi) == 6 + else + @test x_regular == 6 + @test x_kw_pos == 6 + @test x_kw_semi == 6 + end + end + end + @trixi_testset "locally defined override" begin example = """ baz = 42 From 7b9af4f18639a34cf904c496bfa2ecdf996a4c43 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Wed, 10 Jun 2026 10:01:16 +0200 Subject: [PATCH 06/12] fix --- test/test_test_trixi_include.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index f2b7da9..bd2e3c5 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -158,7 +158,7 @@ end @test (@invokelatest mod.x_kw_pos) == 6 @test (@invokelatest mod.x_kw_semi) == 6 else - @test x_regular == 6 + @test x == 6 @test x_kw_pos == 6 @test x_kw_semi == 6 end @@ -170,7 +170,7 @@ end @test (@invokelatest mod.x_kw_pos) == 6 @test (@invokelatest mod.x_kw_semi) == 6 else - @test x_regular == 6 + @test x == 6 @test x_kw_pos == 6 @test x_kw_semi == 6 end From 03c8833652cdda1ad019766013f4e8f65b4df1ae Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Wed, 10 Jun 2026 10:03:10 +0200 Subject: [PATCH 07/12] remove test_trixi_include to avoid overwriting f --- test/test_test_trixi_include.jl | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index bd2e3c5..d492bed 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -162,18 +162,6 @@ end @test x_kw_pos == 6 @test x_kw_semi == 6 end - - @test_trixi_include(path, seed=6, x=seed) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test (@invokelatest mod.x) == 6 - @test (@invokelatest mod.x_kw_pos) == 6 - @test (@invokelatest mod.x_kw_semi) == 6 - else - @test x == 6 - @test x_kw_pos == 6 - @test x_kw_semi == 6 - end end end From 37714cf4b3a2f3b54fa488612a44c8824c9eb061 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Wed, 10 Jun 2026 10:36:38 +0200 Subject: [PATCH 08/12] add more tests for locally defined overrides --- test/test_test_trixi_include.jl | 55 +++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index d492bed..abc9e38 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -138,9 +138,8 @@ end end end - @trixi_testset "chained override, all assignment forms" begin + @trixi_testset "normal override, all assignment forms" begin example = """ - seed = 42 f(; x = 0) = x x = 1 x_kw_pos = f(x = 1) @@ -151,7 +150,7 @@ end write(io, example) close(io) - @test_trixi_include_base(path, seed=6, x=seed) + @test_trixi_include_base(path, x=6) if VERSION >= v"1.12" mod = @__MODULE__ @test (@invokelatest mod.x) == 6 @@ -165,35 +164,57 @@ end end end - @trixi_testset "locally defined override" begin + @trixi_testset "chained override, all assignment forms" begin example = """ - baz = 42 + seed = 42 + f(; x = 0) = x + x = 1 + x_kw_pos = f(x = 1) + x_kw_semi = f(; x = 1) """ mktemp() do path, io write(io, example) close(io) - # overwrite included variable by a locally defined value (not a module global) - local_baz = 7 - @test_trixi_include_base(path, baz=local_baz) + @test_trixi_include_base(path, seed=6, x=seed) if VERSION >= v"1.12" mod = @__MODULE__ - @test @invokelatest isdefined(mod, :baz) - @test (@invokelatest mod.baz) == 7 + @test (@invokelatest mod.x) == 6 + @test (@invokelatest mod.x_kw_pos) == 6 + @test (@invokelatest mod.x_kw_semi) == 6 else - @test @isdefined baz - @test baz == 7 + @test x == 6 + @test x_kw_pos == 6 + @test x_kw_semi == 6 end + end + end - @test_trixi_include(path, baz=local_baz) + @trixi_testset "locally defined override, all assignment forms" begin + example = """ + f(; x = 0) = x + x = 1 + x_kw_pos = f(x = 1) + x_kw_semi = f(; x = 1) + """ + + mktemp() do path, io + write(io, example) + close(io) + + # overwrite included variable by a locally defined value (not a module global) + local_x = 6 + @test_trixi_include_base(path, x=local_x) if VERSION >= v"1.12" mod = @__MODULE__ - @test @invokelatest isdefined(mod, :baz) - @test (@invokelatest mod.baz) == 7 + @test (@invokelatest mod.x) == 6 + @test (@invokelatest mod.x_kw_pos) == 6 + @test (@invokelatest mod.x_kw_semi) == 6 else - @test @isdefined baz - @test baz == 7 + @test x == 6 + @test x_kw_pos == 6 + @test x_kw_semi == 6 end end end From 42709c658ce9ed9b6fba364e3f48e096bde578f4 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Wed, 10 Jun 2026 14:02:53 +0200 Subject: [PATCH 09/12] move definition of f outside example --- test/test_test_trixi_include.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index abc9e38..34200cd 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -139,8 +139,8 @@ end end @trixi_testset "normal override, all assignment forms" begin + global f(; x = 0) = x example = """ - f(; x = 0) = x x = 1 x_kw_pos = f(x = 1) x_kw_semi = f(; x = 1) @@ -165,9 +165,9 @@ end end @trixi_testset "chained override, all assignment forms" begin + global f(; x = 0) = x example = """ seed = 42 - f(; x = 0) = x x = 1 x_kw_pos = f(x = 1) x_kw_semi = f(; x = 1) @@ -192,8 +192,8 @@ end end @trixi_testset "locally defined override, all assignment forms" begin + global f(; x = 0) = x example = """ - f(; x = 0) = x x = 1 x_kw_pos = f(x = 1) x_kw_semi = f(; x = 1) From 696388bba390f29d8e9dc8d02e487b51c4575a35 Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Sat, 13 Jun 2026 21:53:15 +0200 Subject: [PATCH 10/12] add tests for NamedTuple and function keyword argument --- test/test_test_trixi_include.jl | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index 34200cd..eb61442 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -144,6 +144,11 @@ end x = 1 x_kw_pos = f(x = 1) x_kw_semi = f(; x = 1) + y = (; x = 1) + function g(; x = 1) + return x + end + y_g = g() """ mktemp() do path, io @@ -156,10 +161,14 @@ end @test (@invokelatest mod.x) == 6 @test (@invokelatest mod.x_kw_pos) == 6 @test (@invokelatest mod.x_kw_semi) == 6 + @test (@invokelatest mod.y).x == 6 + @test (@invokelatest mod.y_g) == 6 else @test x == 6 @test x_kw_pos == 6 @test x_kw_semi == 6 + @test y.x == 6 + @test y_g == 6 end end end @@ -171,6 +180,11 @@ end x = 1 x_kw_pos = f(x = 1) x_kw_semi = f(; x = 1) + y = (; x = 1) + function g(; x = 1) + return x + end + y_g = g() """ mktemp() do path, io @@ -183,10 +197,14 @@ end @test (@invokelatest mod.x) == 6 @test (@invokelatest mod.x_kw_pos) == 6 @test (@invokelatest mod.x_kw_semi) == 6 + @test (@invokelatest mod.y).x == 6 + @test (@invokelatest mod.y_g) == 6 else @test x == 6 @test x_kw_pos == 6 @test x_kw_semi == 6 + @test y.x == 6 + @test y_g == 6 end end end @@ -197,6 +215,11 @@ end x = 1 x_kw_pos = f(x = 1) x_kw_semi = f(; x = 1) + y = (; x = 1) + function g(; x = 1) + return x + end + y_g = g() """ mktemp() do path, io @@ -211,10 +234,14 @@ end @test (@invokelatest mod.x) == 6 @test (@invokelatest mod.x_kw_pos) == 6 @test (@invokelatest mod.x_kw_semi) == 6 + @test (@invokelatest mod.y).x == 6 + @test (@invokelatest mod.y_g) == 6 else @test x == 6 @test x_kw_pos == 6 @test x_kw_semi == 6 + @test y.x == 6 + @test y_g == 6 end end end From 281695ab4e03d16d2b13e6466ab90ea11e7b281f Mon Sep 17 00:00:00 2001 From: Joshua Lampert Date: Sat, 13 Jun 2026 21:56:56 +0200 Subject: [PATCH 11/12] remove julia version gate --- test/test_test_trixi_include.jl | 192 +++++++++----------------------- 1 file changed, 54 insertions(+), 138 deletions(-) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index eb61442..bd28684 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -20,45 +20,25 @@ end # just include @test_trixi_include_base(path) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 4 - else - @test @isdefined x - @test x == 4 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 4 @test_trixi_include(path) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 4 - else - @test @isdefined x - @test x == 4 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 4 # include and overwrite included variable by a constant @test_trixi_include_base(path, x=9) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 9 - else - @test @isdefined x - @test x == 9 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 9 @test_trixi_include(path, x=9) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 9 - else - @test @isdefined x - @test x == 9 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 9 end end @@ -75,66 +55,36 @@ end # overwrite included variable by a (global) variable global override = 5 @test_trixi_include_base(path, x=override) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 5 - else - @test @isdefined x - @test x == 5 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 5 @test_trixi_include(path, x=override) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 5 - else - @test @isdefined x - @test x == 5 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 5 # overwrite included variable by another included variable @test_trixi_include_base(path, x=seed) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 42 - else - @test @isdefined x - @test x == 42 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 42 @test_trixi_include(path, x=seed) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 42 - else - @test @isdefined x - @test x == 42 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 42 # overwrite included variable by supplied variable @test_trixi_include_base(path, seed=6, x=seed) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 6 - else - @test @isdefined x - @test x == 6 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 6 @test_trixi_include(path, seed=6, x=seed) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :x) - @test (@invokelatest mod.x) == 6 - else - @test @isdefined x - @test x == 6 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :x) + @test (@invokelatest mod.x) == 6 end end @@ -156,20 +106,12 @@ end close(io) @test_trixi_include_base(path, x=6) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test (@invokelatest mod.x) == 6 - @test (@invokelatest mod.x_kw_pos) == 6 - @test (@invokelatest mod.x_kw_semi) == 6 - @test (@invokelatest mod.y).x == 6 - @test (@invokelatest mod.y_g) == 6 - else - @test x == 6 - @test x_kw_pos == 6 - @test x_kw_semi == 6 - @test y.x == 6 - @test y_g == 6 - end + mod = @__MODULE__ + @test (@invokelatest mod.x) == 6 + @test (@invokelatest mod.x_kw_pos) == 6 + @test (@invokelatest mod.x_kw_semi) == 6 + @test (@invokelatest mod.y).x == 6 + @test (@invokelatest mod.y_g) == 6 end end @@ -192,20 +134,12 @@ end close(io) @test_trixi_include_base(path, seed=6, x=seed) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test (@invokelatest mod.x) == 6 - @test (@invokelatest mod.x_kw_pos) == 6 - @test (@invokelatest mod.x_kw_semi) == 6 - @test (@invokelatest mod.y).x == 6 - @test (@invokelatest mod.y_g) == 6 - else - @test x == 6 - @test x_kw_pos == 6 - @test x_kw_semi == 6 - @test y.x == 6 - @test y_g == 6 - end + mod = @__MODULE__ + @test (@invokelatest mod.x) == 6 + @test (@invokelatest mod.x_kw_pos) == 6 + @test (@invokelatest mod.x_kw_semi) == 6 + @test (@invokelatest mod.y).x == 6 + @test (@invokelatest mod.y_g) == 6 end end @@ -229,20 +163,12 @@ end # overwrite included variable by a locally defined value (not a module global) local_x = 6 @test_trixi_include_base(path, x=local_x) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test (@invokelatest mod.x) == 6 - @test (@invokelatest mod.x_kw_pos) == 6 - @test (@invokelatest mod.x_kw_semi) == 6 - @test (@invokelatest mod.y).x == 6 - @test (@invokelatest mod.y_g) == 6 - else - @test x == 6 - @test x_kw_pos == 6 - @test x_kw_semi == 6 - @test y.x == 6 - @test y_g == 6 - end + mod = @__MODULE__ + @test (@invokelatest mod.x) == 6 + @test (@invokelatest mod.x_kw_pos) == 6 + @test (@invokelatest mod.x_kw_semi) == 6 + @test (@invokelatest mod.y).x == 6 + @test (@invokelatest mod.y_g) == 6 end end @@ -344,24 +270,14 @@ end close(io) @test_trixi_include_base(path, RealT=Float32) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :RealT) - @test (@invokelatest mod.RealT) == Float32 - else - @test @isdefined RealT - @test RealT == Float32 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :RealT) + @test (@invokelatest mod.RealT) == Float32 @test_trixi_include(path, RealT=Float32) - if VERSION >= v"1.12" - mod = @__MODULE__ - @test @invokelatest isdefined(mod, :RealT) - @test (@invokelatest mod.RealT) == Float32 - else - @test @isdefined RealT - @test RealT == Float32 - end + mod = @__MODULE__ + @test @invokelatest isdefined(mod, :RealT) + @test (@invokelatest mod.RealT) == Float32 end end end From 4d0c5c4b8aa81fc8367ae511e005af755dfd9f68 Mon Sep 17 00:00:00 2001 From: Hendrik Ranocha Date: Fri, 19 Jun 2026 20:48:20 +0200 Subject: [PATCH 12/12] test more cases --- test/test_test_trixi_include.jl | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/test_test_trixi_include.jl b/test/test_test_trixi_include.jl index bd28684..a8ebe5d 100644 --- a/test/test_test_trixi_include.jl +++ b/test/test_test_trixi_include.jl @@ -99,6 +99,16 @@ end return x end y_g = g() + function h(x = 1) + return x + end + y_h = h() + y_let = 0 + y_let_global = 0 + let x = 1 + y_let = x + global y_let_global = x + end """ mktemp() do path, io @@ -112,6 +122,9 @@ end @test (@invokelatest mod.x_kw_semi) == 6 @test (@invokelatest mod.y).x == 6 @test (@invokelatest mod.y_g) == 6 + @test (@invokelatest mod.y_h) == 6 + @test (@invokelatest mod.y_let) == 0 # let block introduces a local scope + @test (@invokelatest mod.y_let_global) == 6 end end @@ -127,6 +140,16 @@ end return x end y_g = g() + function h(x = 1) + return x + end + y_h = h() + y_let = 0 + y_let_global = 0 + let x = 1 + y_let = x + global y_let_global = x + end """ mktemp() do path, io @@ -140,6 +163,9 @@ end @test (@invokelatest mod.x_kw_semi) == 6 @test (@invokelatest mod.y).x == 6 @test (@invokelatest mod.y_g) == 6 + @test (@invokelatest mod.y_h) == 6 + @test (@invokelatest mod.y_let) == 0 # let block introduces a local scope + @test (@invokelatest mod.y_let_global) == 6 end end @@ -154,6 +180,16 @@ end return x end y_g = g() + function h(x = 1) + return x + end + y_h = h() + y_let = 0 + y_let_global = 0 + let x = 1 + y_let = x + global y_let_global = x + end """ mktemp() do path, io @@ -169,6 +205,9 @@ end @test (@invokelatest mod.x_kw_semi) == 6 @test (@invokelatest mod.y).x == 6 @test (@invokelatest mod.y_g) == 6 + @test (@invokelatest mod.y_h) == 6 + @test (@invokelatest mod.y_let) == 0 # let block introduces a local scope + @test (@invokelatest mod.y_let_global) == 6 end end