From c6cbec376dc9c8cc88bfcd134deb7676a7a790ab Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 Sep 2021 21:18:57 -0400 Subject: [PATCH 1/2] Factor out `@testset` loops --- test/ConcurrentCollectionsTests/src/test_msqueue.jl | 7 +++++-- test/ConcurrentCollectionsTests/src/test_tsstack.jl | 7 +++++-- .../src/test_work_stealing_deque.jl | 8 +++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/test/ConcurrentCollectionsTests/src/test_msqueue.jl b/test/ConcurrentCollectionsTests/src/test_msqueue.jl index 5b8d683..1e42c24 100644 --- a/test/ConcurrentCollectionsTests/src/test_msqueue.jl +++ b/test/ConcurrentCollectionsTests/src/test_msqueue.jl @@ -44,7 +44,11 @@ end function test_push_pop() @testset for T in [Int, Any, Int, Any] - xs = 1:2^10 + test_random_push_pop(T) + end +end + +function test_random_push_pop(T::Type, xs = 1:2^10) if T !== eltype(xs) xs = collect(T, xs) end @@ -54,7 +58,6 @@ function test_push_pop() ys = sort!(foldl(append!, yss; init = T[])) @debug "pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) @test ys == xs - end end end # module diff --git a/test/ConcurrentCollectionsTests/src/test_tsstack.jl b/test/ConcurrentCollectionsTests/src/test_tsstack.jl index 14574a7..2e30135 100644 --- a/test/ConcurrentCollectionsTests/src/test_tsstack.jl +++ b/test/ConcurrentCollectionsTests/src/test_tsstack.jl @@ -44,7 +44,11 @@ end function test_push_pop() @testset for T in [Int, Any, Int, Any] - xs = 1:2^10 + test_random_push_pop(T) + end +end + +function test_random_push_pop(T::Type, xs = 1:2^10) if T !== eltype(xs) xs = collect(T, xs) end @@ -54,7 +58,6 @@ function test_push_pop() ys = sort!(foldl(append!, yss; init = T[])) @debug "pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) @test ys == xs - end end end # module diff --git a/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl b/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl index 280dd17..83f4641 100644 --- a/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl +++ b/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl @@ -64,8 +64,11 @@ end function test_random_push_pop() @testset for T in [Int, Any, Int, Any] - # xs = 1:2^20 - xs = 1:2^10 + test_random_push_pop(T) + end +end + +function test_random_push_pop(T::Type, xs = 1:2^10) if T !== eltype(xs) xs = collect(T, xs) end @@ -76,7 +79,6 @@ function test_random_push_pop() ys = sort!(foldl(append!, yss; init = copy(zs))) @debug "random_pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) @test ys == xs - end end end # module From c166fc033036ef161be69e01d421465952814b98 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 19 Sep 2021 21:28:36 -0400 Subject: [PATCH 2/2] Fix indentation --- .../src/test_msqueue.jl | 18 ++++++++--------- .../src/test_tsstack.jl | 18 ++++++++--------- .../src/test_work_stealing_deque.jl | 20 +++++++++---------- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/test/ConcurrentCollectionsTests/src/test_msqueue.jl b/test/ConcurrentCollectionsTests/src/test_msqueue.jl index 1e42c24..53b07ce 100644 --- a/test/ConcurrentCollectionsTests/src/test_msqueue.jl +++ b/test/ConcurrentCollectionsTests/src/test_msqueue.jl @@ -49,15 +49,15 @@ function test_push_pop() end function test_random_push_pop(T::Type, xs = 1:2^10) - if T !== eltype(xs) - xs = collect(T, xs) - end - yss, _ = pushpop(xs) - @test all(allunique, yss) - @debug "pushpop(xs)" length.(yss) - ys = sort!(foldl(append!, yss; init = T[])) - @debug "pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) - @test ys == xs + if T !== eltype(xs) + xs = collect(T, xs) + end + yss, _ = pushpop(xs) + @test all(allunique, yss) + @debug "pushpop(xs)" length.(yss) + ys = sort!(foldl(append!, yss; init = T[])) + @debug "pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) + @test ys == xs end end # module diff --git a/test/ConcurrentCollectionsTests/src/test_tsstack.jl b/test/ConcurrentCollectionsTests/src/test_tsstack.jl index 2e30135..b8d6bf6 100644 --- a/test/ConcurrentCollectionsTests/src/test_tsstack.jl +++ b/test/ConcurrentCollectionsTests/src/test_tsstack.jl @@ -49,15 +49,15 @@ function test_push_pop() end function test_random_push_pop(T::Type, xs = 1:2^10) - if T !== eltype(xs) - xs = collect(T, xs) - end - yss, _ = pushpop(xs) - @test all(allunique, yss) - @debug "pushpop(xs)" length.(yss) - ys = sort!(foldl(append!, yss; init = T[])) - @debug "pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) - @test ys == xs + if T !== eltype(xs) + xs = collect(T, xs) + end + yss, _ = pushpop(xs) + @test all(allunique, yss) + @debug "pushpop(xs)" length.(yss) + ys = sort!(foldl(append!, yss; init = T[])) + @debug "pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) + @test ys == xs end end # module diff --git a/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl b/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl index 83f4641..c737c90 100644 --- a/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl +++ b/test/ConcurrentCollectionsTests/src/test_work_stealing_deque.jl @@ -69,16 +69,16 @@ function test_random_push_pop() end function test_random_push_pop(T::Type, xs = 1:2^10) - if T !== eltype(xs) - xs = collect(T, xs) - end - zs, yss = random_pushpop(xs) - @test allunique(zs) - @test all(allunique, yss) - @debug "random_pushpop(xs)" length(zs) length.(yss) - ys = sort!(foldl(append!, yss; init = copy(zs))) - @debug "random_pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) - @test ys == xs + if T !== eltype(xs) + xs = collect(T, xs) + end + zs, yss = random_pushpop(xs) + @test allunique(zs) + @test all(allunique, yss) + @debug "random_pushpop(xs)" length(zs) length.(yss) + ys = sort!(foldl(append!, yss; init = copy(zs))) + @debug "random_pushpop(xs)" setdiff(ys, xs) setdiff(xs, ys) length(xs) length(ys) + @test ys == xs end end # module