Skip to content

Commit 522079d

Browse files
committed
Add tests "isreal and real" & "isintegerpoly and asintegerpoly"
1 parent bd4a41e commit 522079d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/Poly.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,26 @@ 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 "`isreal` and `real`" begin
425+
x = Polynomial([1 // 2, 2 + 0im, 3.0, 4.0 + 0.0im])
426+
y = Polynomial([1 // 2, 2 + 0im, 3.0, 4.0 + 0.1im])
427+
@test isreal(x) === true
428+
@test isequal(x, real(x)) === true
429+
@test eltype(real(x)) === Float64
430+
@test real(x) == Polynomial([1 // 2, 2, 3, 4.0])
431+
@test isreal(y) === false
432+
@test real(y) == real(x)
433+
end
424434

435+
@testset "`isintegerpoly` and `asintegerpoly`" begin
436+
x = Polynomial([1 // 1, Int8(2) + 0im, 3.0, Int16(4) + 0im])
437+
y = Polynomial([1 // 2, Int8(2) + 0im, 3.0, Int16(4) + 0im])
438+
@test isintegerpoly(x) === true
439+
@test eltype(asintegerpoly(x)) === Int
440+
@test asintegerpoly(x) == Polynomial([1, 2, 3, 4])
441+
@test isintegerpoly(y) === false
442+
@test_throws InexactError asintegerpoly(y)
443+
end
425444

426445

427446

0 commit comments

Comments
 (0)