Skip to content

Commit 5c7496f

Browse files
committed
improve tests
1 parent b43e907 commit 5c7496f

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

test/bitarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,7 @@ timesofar("datamove")
12201220
@check_bit_operation findall(bitrand(t)) ret_type
12211221
end
12221222

1223-
@test count(trues(2, 2), init=0x00) isa UInt8
1223+
@test count(trues(2, 2), init=0x03) === 0x07
12241224
end
12251225

12261226
timesofar("find")

test/reduce.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,11 @@ struct NonFunctionIsZero end
520520
@test count(NonFunctionIsZero(), [0]) == 1
521521
@test count(NonFunctionIsZero(), [1]) == 0
522522

523-
@test count(Iterators.repeated(true, 3), init=0x00) isa UInt8
524-
@test count(!=(2), Iterators.take(1:7, 3), init=Int32(0)) isa Int32
525-
@test count(identity, [true, false], init=Int8(0)) isa Int8
526-
@test count(!, [true false; false true], dims=:, init=Int16(0)) isa Int16
527-
@test count(identity, [true false; false true], dims=2, init=UInt(0)) isa Matrix{UInt}
523+
@test count(Iterators.repeated(true, 3), init=0x04) === 0x07
524+
@test count(!=(2), Iterators.take(1:7, 3), init=Int32(0)) === Int32(2)
525+
@test count(identity, [true, false], init=Int8(5)) === Int8(6)
526+
@test count(!, [true false; false true], dims=:, init=Int16(0)) === Int16(2)
527+
@test isequal(count(identity, [true false; false true], dims=2, init=UInt(4)), reshape(UInt[5, 5], 2, 1))
528528

529529
## cumsum, cummin, cummax
530530

test/reducedim.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,14 @@ safe_minabs(A::Array{T}, region) where {T} = safe_mapslices(minimum, abs.(A), re
7878
@test @inferred(minimum(abs, Areduc, dims=region)) safe_minabs(Areduc, region)
7979
@test @inferred(count(!, Breduc, dims=region)) safe_count(.!Breduc, region)
8080

81-
@test eltype(@inferred(count(Breduc, dims=region, init=0x00))) == UInt8
82-
@test eltype(@inferred(count(!, Breduc, dims=region, init=Int16(0)))) == Int16
81+
@test isequal(
82+
@inferred(count(Breduc, dims=region, init=0x02)),
83+
safe_count(Breduc, region) .% UInt8 .+ 0x02,
84+
)
85+
@test isequal(
86+
@inferred(count(!, Breduc, dims=region, init=Int16(0))),
87+
safe_count(.!Breduc, region) .% Int16,
88+
)
8389
end
8490

8591
# Combining dims and init
@@ -450,5 +456,5 @@ end
450456
@test_throws TypeError count!([1], [1])
451457
end
452458

453-
@test @inferred(count(false:true, dims=:, init=0x0000)) isa UInt16
454-
@test @inferred(count(isodd, reshape(1:9, 3, 3), dims=:, init=Int128(0))) isa Int128
459+
@test @inferred(count(false:true, dims=:, init=0x0004)) === 0x0005
460+
@test @inferred(count(isodd, reshape(1:9, 3, 3), dims=:, init=Int128(0))) === Int128(5)

0 commit comments

Comments
 (0)