@@ -4,7 +4,7 @@ using CodeTracking
44using Test, InteractiveUtils, REPL, LinearAlgebra, SparseArrays
55# Note: ColorTypes needs to be installed, but note the intentional absence of `using ColorTypes`
66
7- using CodeTracking: line_is_decl
7+ using CodeTracking: line_is_decl, MethodInfoKey
88
99if ! isempty (ARGS ) && " revise" ∈ ARGS
1010 # For running tests with and without Revise
@@ -101,7 +101,7 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
101101
102102 # Test a method marked as missing
103103 m = @which sum (1 : 5 )
104- CodeTracking. method_info[m. sig] = missing
104+ CodeTracking. method_info[MethodInfoKey ( nothing , m. sig) ] = missing
105105 @test whereis (m) == (CodeTracking. maybe_fix_path (String (m. file)), m. line)
106106 @test definition (m) === nothing
107107
297297@testset " With Revise" begin
298298 if isdefined (Main, :Revise )
299299 m = @which gcd (10 , 20 )
300- sigs = signatures_at (Base. find_source_file (String (m. file)), m. line)
301- @test ! isempty (sigs )
300+ mt_sigs = signatures_at (Base. find_source_file (String (m. file)), m. line)
301+ @test ! isempty (mt_sigs )
302302 ex = @code_expr (gcd (10 , 20 ))
303303 @test ex isa Expr
304304 body = ex. args[2 ]
@@ -308,10 +308,10 @@ end
308308
309309 if Base. VERSION < v " 1.11.0-0"
310310 m = first (methods (edit))
311- sigs = signatures_at (String (m. file), m. line)
312- @test ! isempty (sigs )
313- sigs = signatures_at (Base. find_source_file (String (m. file)), m. line)
314- @test ! isempty (sigs )
311+ mt_sigs = signatures_at (String (m. file), m. line)
312+ @test ! isempty (mt_sigs )
313+ mt_sigs = signatures_at (Base. find_source_file (String (m. file)), m. line)
314+ @test ! isempty (mt_sigs )
315315 end
316316
317317 # issue #23
321321
322322 if isdefined (Revise, :add_revise_deps )
323323 Revise. add_revise_deps ()
324- sigs = signatures_at (CodeTracking, " src/utils.jl" , 5 )
325- @test length (sigs) == 1 # only isn't available on julia 1.0
326- @test first (sigs) == Tuple{typeof (CodeTracking. checkname), Expr, Any}
324+ mt_sigs = signatures_at (CodeTracking, " src/utils.jl" , 5 )
325+ @test length (mt_sigs) == 1 # only isn't available on julia 1.0
326+ (mt, sig) = first (mt_sigs)
327+ @test sig == Tuple{typeof (CodeTracking. checkname), Expr, Any}
327328 @test pkgfiles (CodeTracking). id == Base. PkgId (CodeTracking)
328329 end
329330
454455 @test CodeTracking. strip_gensym (" #𝓔′#90" ) == :𝓔′
455456 @test CodeTracking. strip_gensym (" 𝓔′##kw" ) == :𝓔′
456457end
458+
459+ @testset " External method tables" begin
460+ mod = @eval module $ (gensym (:ExternalMT ))
461+ Base. Experimental. @MethodTable method_table
462+ end
463+ ex = :(Base. Experimental. @overlay method_table + (x:: String , y:: String ) = x * y)
464+ if VERSION ≥ v " 1.13-"
465+ method = Core. eval (mod, ex)
466+ else
467+ Core. eval (mod, ex)
468+ method = only (Base. MethodList (mod. method_table). ms)
469+ end
470+ lnn = LineNumberNode (Int (method. line), method. file)
471+ @test CodeTracking. definition (Expr, method) === nothing
472+ CodeTracking. method_info[MethodInfoKey (method)] = [(lnn, ex)]
473+ @test CodeTracking. definition (Expr, method) == ex
474+ end
0 commit comments