Skip to content

Commit

Permalink
Complex substitution test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
projekter committed May 8, 2024
1 parent f9337ff commit e0ad44d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,26 @@
)
@test_throws err t(y => 1)
@test_throws err p(y => 1)

@complex_polyvar z
pc = z^3 + 2real(z) - 7imag(z^4)
@test pc(z => 2 + 3im) == 798 + 9im
@test pc(conj(z) => 2 - 3im) == 798 + 9im
@test real(pc)(z => 2 + 3im) == 798
err = ArgumentError(
"Variable `zᵢ` was not assigned a value. Use `subs` to substitute only a subset of the variables.",
)
@test_throws err real(pc)(real(z) => 2)
@test subs(real(pc), real(z) => 2) ==
12 - 224imag(z) - 6imag(z)^2 + 56imag(z)^3
@test real(pc)([real(z), imag(z)] => [2, 3]) == 798
err = ErrorException(
"Found complex variable with substitution of real part - not implemented",
)
@test_throws err subs(pc, real(z) => 2)
err = ErrorException(
"Found complex variable with substitution of imaginary part - not implemented",
)
@test_throws err subs(pc, imag(z) => 3)
end
end

0 comments on commit e0ad44d

Please sign in to comment.