Skip to content

Commit

Permalink
Add test for issue #3340 which exposed upstream issues with the use o…
Browse files Browse the repository at this point in the history
…f TimSort (#3341)
  • Loading branch information
LilithHafner committed Jun 15, 2023
1 parent 09c1793 commit 9634e22
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/sort.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module TestSort

using DataFrames, Random, Test, CategoricalArrays
using DataFrames, Random, Test, CategoricalArrays, InlineStrings

@testset "standard tests" begin
dv1 = [9, 1, 8, missing, 3, 3, 7, missing]
Expand Down Expand Up @@ -403,4 +403,22 @@ end
@test issorted(df[1:5, :])
end

@testset "issue #3340, mostly downstream testing for SortingAlgorithms.jl and Base.Sort" begin
Random.seed!(1234)
for i in 1:10
df = DataFrame(units = round.(Int, 1 ./ rand(2000)),
sku = [rand() < .084 ? missing : String31(randstring(8)) for _ in 1:2000])
@test issorted(sort(select(df, [:sku, :units]), :sku).sku)
@test issorted(sort(select(df, [:sku, :units]), :units).units)
@test issorted(sort(select(df, [:sku, :units]).sku))
@test issorted(sort(df, :sku).sku)

o = Base.Order.Perm(Base.Order.ForwardOrdering(), df.sku)
a = DataFrames.SortingAlgorithms.TimSortAlg()
x = collect(1:nrow(df))
sort!(x, a, o)
@test issorted(df[x, :sku])
end
end

end # module

0 comments on commit 9634e22

Please sign in to comment.