Skip to content

Commit

Permalink
Fix the tests to respect expected orderings
Browse files Browse the repository at this point in the history
  • Loading branch information
andyferris committed Jun 12, 2020
1 parent dd7934e commit 135e02c
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions test/group.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@testset "group" begin
@test group(identity, 11:20)::Dictionary == Dictionary(11:20, (x->[x]).(11:20))
@test group(iseven, 1:10)::Dictionary == dictionary(true => [2,4,6,8,10], false => [1,3,5,7,9])
@test group(iseven, 1:10)::Dictionary == dictionary([false => [1,3,5,7,9], true => [2,4,6,8,10]])

@test group(iseven, x -> x*2, 1:10)::Dictionary == dictionary(true => [4,8,12,16,20], false => [2,6,10,14,18])
@test group(iseven, x -> x*2, 1:10)::Dictionary == dictionary([false => [2,6,10,14,18], true => [4,8,12,16,20]])

@test group((x,y) -> iseven(x+y), (x,y) -> x, 1:10, [1,3,4,2,5,6,4,2,3,9])::Dictionary == dictionary(true => [1,4,5,6,8,9], false => [2,3,7,10])
@test group((x,y) -> iseven(x+y), (x,y) -> x, 1:10, [1,3,4,2,5,6,4,2,3,9])::Dictionary == dictionary([true => [1,4,5,6,8,9], false => [2,3,7,10]])
end

@testset "grouponly" begin
Expand All @@ -14,12 +14,12 @@ end

@testset "groupunique" begin
@test groupunique(identity, 11:20)::Dictionary{Int, Indices{Int}} == Dictionary(11:20, map(x -> Indices([x]), 11:20))
@test groupunique(iseven, 11:20)::Dictionary{Bool, Indices{Int}} == dictionary(true => Indices([12,14,16,18,20]), false => Indices([11,13,15,17,19]))
@test groupunique(iseven, 11:20)::Dictionary{Bool, Indices{Int}} == dictionary([false => Indices([11,13,15,17,19]), true => Indices([12,14,16,18,20])])
end

@testset "groupfind" begin
@test groupfind(identity, 11:20) == Dictionary(11:20, (x->[x]).(1:10))
@test groupfind(iseven, 11:20) == dictionary(true => [2,4,6,8,10], false => [1,3,5,7,9])
@test groupfind(iseven, 11:20) == dictionary([false => [1,3,5,7,9], true => [2,4,6,8,10]])
end

@testset "groupview" begin
Expand All @@ -29,18 +29,18 @@ end

@testset "groupreduce" begin
@test groupreduce(identity, +, 1:10) == Dictionary(1:10, 1:10)
@test groupreduce(iseven, +, 1:10) == dictionary(true => 30, false => 25)
@test groupreduce(iseven, +, 1:10) == dictionary([false => 25, true => 30])

@test groupreduce(iseven, x -> x*2, +, 1:10) == dictionary(true => 60, false => 50)
@test groupreduce(iseven, x -> x*2, +, 1:10) == dictionary([false => 50, true => 60])

@test groupreduce(iseven, x -> x*2, +, 1:10; init=10) == dictionary(true => 70, false => 60)
@test groupreduce(iseven, x -> x*2, +, 1:10; init=10) == dictionary([false => 60, true => 70])

@test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, 1:10; init=10) == dictionary(true => 120)
@test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, [1,3,4,2,5,6,4,2,3,9]; init=10) == dictionary(true => 62, false => 52)
@test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, 1:10; init=10) == dictionary([true => 120])
@test groupreduce((x,y) -> iseven(x+y), (x,y) -> x+y, +, 1:10, [1,3,4,2,5,6,4,2,3,9]; init=10) == dictionary([true => 62, false => 52])

@test groupcount(iseven, 1:10) == dictionary(true => 5, false => 5)
@test groupsum(iseven, 1:10) == dictionary(true => 30, false => 25)
@test groupprod(iseven, 1:10) == dictionary(true => 2*4*6*8*10, false => 1*3*5*7*9)
@test groupfirst(iseven, 1:10) == dictionary(true => 2, false => 1)
@test grouplast(iseven, 1:10) == dictionary(true => 10, false => 9)
@test groupcount(iseven, 1:10) == dictionary([false => 5, true => 5])
@test groupsum(iseven, 1:10) == dictionary([false => 25, true => 30])
@test groupprod(iseven, 1:10) == dictionary([false => 1*3*5*7*9, true => 2*4*6*8*10])
@test groupfirst(iseven, 1:10) == dictionary([false => 1, true => 2])
@test grouplast(iseven, 1:10) == dictionary([false => 9, true => 10])
end

2 comments on commit 135e02c

@andyferris
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/16232

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" 135e02c41421042094c5753f032b3ba21a1aa31d
git push origin v1.1.0

Please sign in to comment.