Skip to content

Commit 1d71dd4

Browse files
test: test values of solved roots
1 parent bbcacd3 commit 1d71dd4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

test/solver.jl

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,16 +476,25 @@ end
476476
expr = sec(x ^ 2 + 4x + 4) ^ 3 - 3
477477
roots = ia_solve(expr, x)
478478
@test length(roots) == 6 # 2 quadratic roots * 3 roots from cbrt(3)
479+
@test length(Symbolics.get_variables(roots[1])) == 1
480+
_n = only(Symbolics.get_variables(roots[1]))
481+
vals = substitute.(roots, (Dict(_n => 0),))
482+
@test all(x -> isapprox(norm(sec(x^2 + 4x + 4) ^ 3 - 3), 0.0, atol = 1e-14), vals)
483+
479484
roots = ia_solve(expr, x; complex_roots = false)
480485
@test length(roots) == 2
481486
# the `n` in `θ + n * 2π`
482487
@test length(Symbolics.get_variables(roots[1])) == 1
483-
@test length(Symbolics.get_variables(roots[2])) == 1
488+
_n = only(Symbolics.get_variables(roots[1]))
489+
vals = substitute.(roots, (Dict(_n => 0),))
490+
@test all(x -> isapprox(norm(sec(x^2 + 4x + 4) ^ 3 - 3), 0.0, atol = 1e-14), vals)
491+
484492
roots = ia_solve(expr, x; complex_roots = false, periodic_roots = false)
485493
@test length(roots) == 2
486494
@test length(Symbolics.get_variables(roots[1])) == 0
487-
@test length(Symbolics.get_variables(roots[2])) ==0
488-
@test_nowarn eval.(Symbolics.toexpr.(roots))
495+
@test length(Symbolics.get_variables(roots[2])) == 0
496+
vals = eval.(Symbolics.toexpr.(roots))
497+
@test all(x -> isapprox(norm(sec(x^2 + 4x + 4) ^ 3 - 3), 0.0, atol = 1e-14), vals)
489498
end
490499
end
491500

0 commit comments

Comments
 (0)