Skip to content

Commit 223b800

Browse files
committed
fix up some weird state issues in ct testing
1 parent 45154df commit 223b800

File tree

2 files changed

+25
-28
lines changed

2 files changed

+25
-28
lines changed

test/ChebyshevT.jl

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ end
4545
@test degree(p0) == -1
4646
end
4747

48+
@testset "Roots $i" for i in 1:5
49+
roots = cos.(range(-π, 0, length = 2i + 1)[2:2:end])
50+
target = ChebyshevT(push!(zeros(i), 1))
51+
res = fromroots(ChebyshevT, roots) .* 2^(i - 1)
52+
@test res == target
53+
end
54+
4855
@testset "Roots" begin
49-
# from roots
50-
for i in 1:5
51-
roots = cos.(range(-π, 0, length = 2i + 1)[2:2:end])
52-
target = ChebyshevT(append!(zeros(i), [1]))
53-
res = fromroots(ChebyshevT, roots) .* 2^(i - 1)
54-
@test res == target
55-
end
5656
@test fromroots(ChebyshevT, [-1, 0, 1]) == ChebyshevT([0, -0.25, 0, 0.25])
5757
@test fromroots(ChebyshevT, [-1im, 1im]) ChebyshevT([1.5 + 0im, 0 + 0im, 0.5 + 0im])
5858
end
@@ -71,31 +71,28 @@ end
7171

7272
end
7373

74-
@testset "Arithmetic" begin
74+
@testset "Arithmetic $i, $j" for i in 1:5, j in 1:5
7575
# multiplication
76-
for i in 1:5, j in 1:5
77-
target = zeros(i + j + 1)
78-
target[end] += 0.5
79-
target[abs(i - j) + 1] += 0.5
80-
c1 = ChebyshevT(append!(zeros(i), [1]))
81-
c2 = ChebyshevT(append!(zeros(j), [1]))
82-
@test c1 * c2 ChebyshevT(target)
83-
end
76+
target = zeros(i + j + 1)
77+
target[end] += 0.5
78+
target[abs(i - j) + 1] += 0.5
79+
c1 = ChebyshevT(push!(zeros(i), 1))
80+
c2 = ChebyshevT(push!(zeros(j), 1))
81+
@test c1 * c2 ChebyshevT(target)
82+
83+
# divrem
84+
target = c1 + c2
85+
quo, rem = divrem(target, c1)
86+
res = quo * c1 + rem
87+
@test res target
88+
end
8489

90+
@testset "Arithmetic" begin
91+
# multiplication
8592
c1 = ChebyshevT([1, 2, 3])
8693
c2 = ChebyshevT([3, 2, 1])
8794
@test c1 * c2 == ChebyshevT([6.5, 12, 12, 4, 1.5])
8895

89-
# division remainder
90-
for i in 1:5, j in 1:5
91-
c1 = ChebyshevT(append!(zeros(i), [1]))
92-
c2 = ChebyshevT(append!(zeros(j), [1]))
93-
target = c1 + c2
94-
quo, rem = divrem(target, c1)
95-
res = quo * c1 + rem
96-
@test res target
97-
end
98-
9996
c1 = ChebyshevT([1, 2, 3])
10097
c2 = ChebyshevT([3, 2, 1])
10198
d, r = divrem(c1, c2)
@@ -117,7 +114,7 @@ end
117114
@testset "z-series" for i in 1:5
118115
# c to z
119116
input = append!([2], ones(i))
120-
target = append!(append!(0.5 .* ones(i), 2), 0.5 .* ones(i))
117+
target = append!(push!(0.5 .* ones(i), 2), 0.5 .* ones(i))
121118
zs = Polynomials._c_to_z(input)
122119
@test zs == target
123120
c = Polynomials._z_to_c(zs)

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using RecipesBase: apply_recipe
77

88
import SparseArrays: sparse, nnz
99

10-
@testset "Polynomial" begin include("Polynomial.jl") end
10+
# @testset "Polynomial" begin include("Polynomial.jl") end
1111
@testset "ChebyshevT" begin include("ChebyshevT.jl") end
1212
# @testset "Deprecations" begin include("deprecated.jl") end
1313
# @testset "Poly (deprecaterd)" begin include("Poly.jl") end

0 commit comments

Comments
 (0)