Skip to content

Commit ad632f2

Browse files
committed
Add tests "all and any", & "map"
1 parent 7245a87 commit ad632f2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/Poly.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,23 @@ fit(Poly, xx,yy,2)
421421
## Issue with overflow and polyder Issue #159
422422
@test !iszero(polyder(Poly(BigInt[0, 1])^100, 100))
423423

424+
@testset "`all` and `any`" begin
425+
@test all(x -> x > 1, Polynomial([2 // 1, 3, Int8(4), 5.0]))
426+
@test any(x -> x > 1, Polynomial([2 // 1, 3, Int8(4), 5.0]))
427+
@test any(isnan, Polynomial([2 // 1, NaN, Int8(4), 5.0]))
428+
@test any(!isfinite, Polynomial([2 // 1, NaN, Int8(4), 5.0]))
429+
@test any(isinf, Polynomial([2 // 1, Inf64, Int8(4), 5.0]))
430+
@test any(iszero, Polynomial([1, 0, 2.0, 3 // 1]))
431+
end
432+
433+
@testset "`map`" begin
434+
@test map(sqrt, Polynomial([1, 2, 3, 4.0])) == Polynomial([1, 2, 3, 4])
435+
@test map(x -> x + 1, Polynomial([1, 2, 3, 4.0])) == Polynomial([2, 3, 4.0, 5 // 1])
436+
@test map(zero, Polynomial([1, 2, 3, 4.0])) == Polynomial(0)
437+
@test map(one, Polynomial([1, 2, 3, 4.0])) == Polynomial([1, 1, 1, 1])
438+
@test map(float, Polynomial([1, 2, 3, 4])) == Polynomial([1.0, 2.0, 3.0, 4.0])
439+
end
440+
424441
@testset "`isreal` and `real`" begin
425442
x = Polynomial([1 // 2, 2 + 0im, 3.0, 4.0 + 0.0im])
426443
y = Polynomial([1 // 2, 2 + 0im, 3.0, 4.0 + 0.1im])

0 commit comments

Comments
 (0)