From 663e94ba94ad0cfd735cb1198927b72f3a5f5e9d Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Mon, 29 Jan 2024 12:49:32 +0900 Subject: [PATCH] 1.10: REPL: fix intermittent REPL test failure The earlier test relied on the order of the method match list returned by `_methods_by_ftype`. However, particularly in cases where the `ambig=true` option is used, the match list isn't deterministic. This commit modifies it, similar to other pieces of code, so that it `any` to ensure the code does not depend on the implementation details of `ml_matches`. Fixes #52739. --- stdlib/REPL/test/replcompletions.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 0c0ff08f2c3f1..56a96b5a1534c 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -646,7 +646,7 @@ let s = "CompletionFoo.?([1,2,3], 2.0)" c, r, res = test_complete(s) @test !res @test length(c) == 1 - @test occursin("test(x::AbstractArray{T}, y) where T<:Real", c[1]) + @test occursin("test(x::AbstractArray{T}, y) where T<:Real", only(c)) # In particular, this checks that test(args...) is not a valid completion # since it is strictly less specific than test(x::AbstractArray{T}, y) end @@ -680,15 +680,15 @@ let s = "CompletionFoo.?(false, \"a\", 3, " c, r, res = test_complete(s) @test !res @test length(c) == 2 - @test occursin("test(args...)", c[1]) - @test occursin("test11(a::Integer, b, c)", c[2]) + @test any(s->occursin("test(args...)", s), c) + @test any(s->occursin("test11(a::Integer, b, c)", s), c) end let s = "CompletionFoo.?(false, \"a\", 3, " c, r, res = test_complete_noshift(s) @test !res @test length(c) == 1 - @test occursin("test11(a::Integer, b, c)", c[1]) + @test occursin("test11(a::Integer, b, c)", only(c)) end let s = "CompletionFoo.?(\"a\", 3, " @@ -711,7 +711,7 @@ let s = "CompletionFoo.?()" c, r, res = test_complete_noshift(s) @test !res @test length(c) == 1 - @test occursin("test10(s::String...)", c[1]) + @test occursin("test10(s::String...)", only(c)) end #= TODO: restrict the number of completions when a semicolon is present in ".?(" syntax