Skip to content

Commit

Permalink
Add test for Overlay Method Table
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Feb 10, 2025
1 parent d579849 commit 1ba5ec9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3855,6 +3855,36 @@ do_test("includet with mod arg (issue #689)") && @testset "includet with mod arg
@test Driver.Codes.Common.foo == 2
end

do_test("Overlay Method Tables") && @testset "Overlay Method Tables" begin
# Issue #646
testdir = newtestdir()
file = joinpath(testdir, "overlaymt.jl")
write(file, """
Base.Experimental.@MethodTable(method_table)
foo_mt() = 1
Base.Experimental.@overlay Main.method_table foo_mt() = 2
""")
sleep(mtimedelay)
includet(file)
@test foo_mt() == 1
methods = Base._methods_by_ftype(Tuple{typeof(foo_mt)}, method_table, 1, Base.get_world_counter())
ci = Base.uncompressed_ir(methods[1].method)
@test ci.code[end] == Core.ReturnNode(2)
sleep(mtimedelay)
write(file, """
Base.Experimental.@MethodTable(method_table)
foo_mt() = 1
Base.Experimental.@overlay Main.method_table foo_mt() = 3
""")
sleep(mtimedelay)
@test foo_mt() == 1
methods = Base._methods_by_ftype(Tuple{typeof(foo_mt)}, method_table, 1, Base.get_world_counter())
ci = Base.uncompressed_ir(methods[1].method)
@test_broken ci.code[end] == Core.ReturnNode(3)
end

do_test("misc - coverage") && @testset "misc - coverage" begin
@test Revise.ReviseEvalException("undef", UndefVarError(:foo)).loc isa String
@test !Revise.throwto_repl(UndefVarError(:foo))
Expand Down

0 comments on commit 1ba5ec9

Please sign in to comment.