From b2efebf2a1ceded060fbe5274076c7119db923bb Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Fri, 10 Feb 2023 10:58:20 -0600 Subject: [PATCH 1/3] Add unit tests for WithoutMissingVector --- test/sorting.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/sorting.jl b/test/sorting.jl index 691f0a0e2bc39..440300994cfe8 100644 --- a/test/sorting.jl +++ b/test/sorting.jl @@ -764,6 +764,13 @@ end @testset "Unions with missing" begin @test issorted(sort(shuffle!(vcat(fill(missing, 10), rand(Int, 100))))) @test issorted(sort(vcat(rand(Int8, 600), [missing]))) + a = [1,7,missing,4] + @test_throws ArgumentError Base.Sort.WithoutMissingVector(a) + @test eltype(a[[1,2,4]]) == eltype(a) + @test eltype(Base.Sort.WithoutMissingVector(a[[1,2,4]])) == Int + am = Base.Sort.WithoutMissingVector(a, unsafe=true) + @test am[2] == 7 + @test eltype(am) == Int end @testset "Specific algorithms" begin From d35a2153088dc81b0a5f9f147262f49f7df02f28 Mon Sep 17 00:00:00 2001 From: Lilith Orion Hafner Date: Fri, 10 Feb 2023 14:52:34 -0600 Subject: [PATCH 2/3] Also test all missing vectors and add comments --- test/sorting.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/sorting.jl b/test/sorting.jl index 440300994cfe8..aa4810e9d078e 100644 --- a/test/sorting.jl +++ b/test/sorting.jl @@ -764,6 +764,11 @@ end @testset "Unions with missing" begin @test issorted(sort(shuffle!(vcat(fill(missing, 10), rand(Int, 100))))) @test issorted(sort(vcat(rand(Int8, 600), [missing]))) + + # Because we define defalg(::AbstractArray{Missing}) + @test all(fill(missing, 10) .=== sort(fill(missing, 10))) + + # Unit tests for WithoutMissingVector a = [1,7,missing,4] @test_throws ArgumentError Base.Sort.WithoutMissingVector(a) @test eltype(a[[1,2,4]]) == eltype(a) From ca93a5f830c3665b446c837c91bc822f33e6d480 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Mon, 13 Feb 2023 10:01:28 +0100 Subject: [PATCH 3/3] whitespace --- test/sorting.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sorting.jl b/test/sorting.jl index aa4810e9d078e..a7d172cdaf952 100644 --- a/test/sorting.jl +++ b/test/sorting.jl @@ -764,9 +764,9 @@ end @testset "Unions with missing" begin @test issorted(sort(shuffle!(vcat(fill(missing, 10), rand(Int, 100))))) @test issorted(sort(vcat(rand(Int8, 600), [missing]))) - + # Because we define defalg(::AbstractArray{Missing}) - @test all(fill(missing, 10) .=== sort(fill(missing, 10))) + @test all(fill(missing, 10) .=== sort(fill(missing, 10))) # Unit tests for WithoutMissingVector a = [1,7,missing,4]