Skip to content

Commit

Permalink
follow up #46799, add test case for CachedMethodTable
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Sep 18, 2022
1 parent 86e0c6a commit e704d63
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
5 changes: 3 additions & 2 deletions test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ function choosetests(choices = [])
"strings/io", "strings/types"])
# do subarray before sparse but after linalg
filtertests!(tests, "subarray")
filtertests!(tests, "compiler", ["compiler/inference", "compiler/effects",
"compiler/validation", "compiler/heap", "compiler/ssair", "compiler/irpasses",
filtertests!(tests, "compiler", [
"compiler/datastructures", "compiler/inference", "compiler/effects",
"compiler/validation", "compiler/ssair", "compiler/irpasses",
"compiler/codegen", "compiler/inline", "compiler/contextual",
"compiler/AbstractInterpreter", "compiler/EscapeAnalysis/local",
"compiler/EscapeAnalysis/interprocedural"])
Expand Down
24 changes: 24 additions & 0 deletions test/compiler/heap.jl → test/compiler/datastructures.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
using Test

@testset "CachedMethodTable" begin
# cache result should be separated per `limit` and `sig`
# https://github.com/JuliaLang/julia/pull/46799
interp = Core.Compiler.NativeInterpreter()
table = Core.Compiler.method_table(interp)
sig = Tuple{typeof(*), Any, Any}
result1 = Core.Compiler.findall(sig, table; limit=-1)
result2 = Core.Compiler.findall(sig, table; limit=Core.Compiler.get_max_methods(*, @__MODULE__, interp))
@test result1 !== Core.Compiler.missing && !Core.Compiler.isempty(result1.matches)
@test result2 === Core.Compiler.missing
end

@testset "BitSetBoundedMinPrioritySet" begin
bsbmp = Core.Compiler.BitSetBoundedMinPrioritySet(5)
Core.Compiler.push!(bsbmp, 2)
Core.Compiler.push!(bsbmp, 2)
@test Core.Compiler.popfirst!(bsbmp) == 2
Core.Compiler.push!(bsbmp, 1)
@test Core.Compiler.popfirst!(bsbmp) == 1
@test Core.Compiler.isempty(bsbmp)
end

@testset "basic heap functionality" begin
v = [2,3,1]
@test Core.Compiler.heapify!(v, Core.Compiler.Forward) === v
Expand Down
10 changes: 0 additions & 10 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4078,16 +4078,6 @@ g_max_methods(x) = f_max_methods(x)
@test Core.Compiler.return_type(g_max_methods, Tuple{Int}) === Int
@test Core.Compiler.return_type(g_max_methods, Tuple{Any}) === Any

# Unit tests for BitSetBoundedMinPrioritySet
let bsbmp = Core.Compiler.BitSetBoundedMinPrioritySet(5)
Core.Compiler.push!(bsbmp, 2)
Core.Compiler.push!(bsbmp, 2)
@test Core.Compiler.popfirst!(bsbmp) == 2
Core.Compiler.push!(bsbmp, 1)
@test Core.Compiler.popfirst!(bsbmp) == 1
@test Core.Compiler.isempty(bsbmp)
end

# Make sure return_type_tfunc doesn't accidentally cause bad inference if used
# at top level.
@test let
Expand Down

0 comments on commit e704d63

Please sign in to comment.