Skip to content

Commit 5c6015e

Browse files
committed
Add test for Overlay Method Table
1 parent bf833b6 commit 5c6015e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/runtests.jl

+30
Original file line numberDiff line numberDiff line change
@@ -3762,6 +3762,36 @@ do_test("includet with mod arg (issue #689)") && @testset "includet with mod arg
37623762
@test Driver.Codes.Common.foo == 2
37633763
end
37643764

3765+
do_test("Overlay Method Tables") && @testset "Overlay Method Tables" begin
3766+
# Issue #646
3767+
testdir = newtestdir()
3768+
file = joinpath(testdir, "overlaymt.jl")
3769+
write(file, """
3770+
Base.Experimental.@MethodTable(method_table)
3771+
3772+
foo_mt() = 1
3773+
Base.Experimental.@overlay Main.method_table foo_mt() = 2
3774+
""")
3775+
sleep(mtimedelay)
3776+
includet(file)
3777+
@test foo_mt() == 1
3778+
methods = Base._methods_by_ftype(Tuple{typeof(foo_mt)}, method_table, 1, Base.get_world_counter())
3779+
ci = Base.uncompressed_ir(methods[1].method)
3780+
@test ci.code[end] == Core.ReturnNode(2)
3781+
sleep(mtimedelay)
3782+
write(file, """
3783+
Base.Experimental.@MethodTable(method_table)
3784+
3785+
foo_mt() = 1
3786+
Base.Experimental.@overlay Main.method_table foo_mt() = 3
3787+
""")
3788+
sleep(mtimedelay)
3789+
@test foo_mt() == 1
3790+
methods = Base._methods_by_ftype(Tuple{typeof(foo_mt)}, method_table, 1, Base.get_world_counter())
3791+
ci = Base.uncompressed_ir(methods[1].method)
3792+
@test_broken ci.code[end] == Core.ReturnNode(3)
3793+
end
3794+
37653795
do_test("misc - coverage") && @testset "misc - coverage" begin
37663796
@test Revise.ReviseEvalException("undef", UndefVarError(:foo)).loc isa String
37673797
@test !Revise.throwto_repl(UndefVarError(:foo))

0 commit comments

Comments
 (0)