Skip to content

Commit 28842e6

Browse files
test: update tests according to new Rewriter wrapping
1 parent 4ff161f commit 28842e6

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

test/basics.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ end
180180

181181
@testset "substitute" begin
182182
@syms a b
183-
@test substitute(a, Dict(a=>1)) == 1
183+
@test unwrap_const(substitute(a, Dict(a=>1))) == 1
184184
@test isequal(substitute(sin(a+b), Dict(a=>1)), sin(b+1))
185185
@test substitute(a+b, Dict(a=>1, b=>3)) == 4
186186
@test substitute(exp(a), Dict(a=>2)) exp(2)
@@ -231,7 +231,7 @@ end
231231

232232
# test that the "x^2 + y^-1 + sin(a)^3.5 + 2t + 1//1" expression from Symbolics.jl/build_targets.jl is properly sorted
233233
@syms x1 y1 a1 t1
234-
@test repr(x1^2 + y1^-1 + sin(a1)^3.5 + 2t1 + 1//1) == "(1//1) + 2t1 + 1 / y1 + x1^2 + sin(a1)^3.5"
234+
@test repr(x1^2 + y1^-1 + sin(a1)^3.5 + 2t1 + 1//1) == "1//1 + 2t1 + 1 / y1 + x1^2 + sin(a1)^3.5"
235235
end
236236

237237
@testset "inspect" begin

test/polyform.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ end
2020
@test expand(term(*, 0, a)) == 0
2121
@test expand(a * (b + -1 * c) + -1 * (b * a + -1 * c * a)) == 0
2222
@eqtest simplify(expand(sin((a+b)^2)^2)) == simplify(sin(a^2+2*(b*a)+b^2)^2)
23-
@test simplify(expand(sin((a+b)^2)^2 + cos((a+b)^2)^2)) == 1
23+
@test unwrap_const(simplify(expand(sin((a+b)^2)^2 + cos((a+b)^2)^2))) == 1
2424
@syms x1::Real f(::Real)::Real
2525

2626
# issue 193

test/rulesets.jl

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Random: shuffle, seed!
22
using SymbolicUtils
3-
using SymbolicUtils: getdepth, Rewriters, Term
3+
using SymbolicUtils: getdepth, Rewriters, Term, unwrap_const
44

55
include("utils.jl")
66

@@ -23,7 +23,7 @@ end
2323
@syms a::Integer b c d x::Real y::Number
2424
@eqtest simplify(Term{Real}(conj, [x])) == x
2525
@eqtest simplify(Term{Real}(real, [x])) == x
26-
@eqtest simplify(Term{Real}(imag, [x])) == 0
26+
@eqtest unwrap_const(simplify(Term{Real}(imag, [x]))) == 0
2727
@eqtest simplify(Term{Real}(imag, [y])) == imag(y)
2828
@eqtest simplify(x - y) == x + -1 * y
2929
@eqtest simplify(x - sin(y)) == x + -1 * sin(y)
@@ -47,14 +47,14 @@ end
4747
@eqtest simplify(a * b * 1 * c * d) == simplify(a * b * c * d)
4848
@eqtest simplify_fractions(x^2.0 / (x * y)^2.0) == simplify_fractions(1 / (y^2.0))
4949

50-
@test simplify(Term(one, [a])) == 1
51-
@test simplify(Term(one, [b + 1])) == 1
52-
@test simplify(Term(one, [x + 2])) == 1
50+
@test unwrap_const(simplify(Term(one, [a]))) == 1
51+
@test unwrap_const(simplify(Term(one, [b + 1]))) == 1
52+
@test unwrap_const(simplify(Term(one, [x + 2]))) == 1
5353

5454

55-
@test simplify(Term(zero, [a])) == 0
56-
@test simplify(Term(zero, [b + 1])) == 0
57-
@test simplify(Term(zero, [x + 2])) == 0
55+
@test unwrap_const(simplify(Term(zero, [a]))) == 0
56+
@test unwrap_const(simplify(Term(zero, [b + 1]))) == 0
57+
@test unwrap_const(simplify(Term(zero, [x + 2]))) == 0
5858
end
5959

6060
@testset "LiteralReal" begin
@@ -74,14 +74,14 @@ end
7474

7575
@eqtest simplify(a < 0) == (a < 0)
7676
@eqtest simplify(0 < a) == (0 < a)
77-
@eqtest simplify((0 < a) | true) == true
78-
@eqtest simplify(true | (0 < a)) == true
77+
@eqtest unwrap_const(simplify((0 < a) | true)) == true
78+
@eqtest unwrap_const(simplify(true | (0 < a))) == true
7979
@eqtest simplify((0 < a) & true) == (0 < a)
8080
@eqtest simplify(true & (0 < a)) == (0 < a)
81-
@eqtest simplify(false & (0 < a)) == false
82-
@eqtest simplify((0 < a) & false) == false
83-
@eqtest simplify(Term{Bool}(!, [true])) == false
84-
@eqtest simplify(Term{Bool}(|, [false, true])) == true
81+
@eqtest unwrap_const(simplify(false & (0 < a))) == false
82+
@eqtest unwrap_const(simplify((0 < a) & false)) == false
83+
@eqtest unwrap_const(simplify(Term{Bool}(!, [true]))) == false
84+
@eqtest unwrap_const(simplify(Term{Bool}(|, [false, true]))) == true
8585
@eqtest simplify(ifelse(true, a, b)) == a
8686
@eqtest simplify(ifelse(false, a, b)) == b
8787

@@ -95,18 +95,18 @@ end
9595
@testset "Pythagorean Identities" begin
9696
@syms a::Integer x::Real y::Number
9797

98-
@test simplify(cos(x)^2 + 1 + sin(x)^2) == 2
99-
@test simplify(cos(y)^2 + 1 + sin(y)^2) == 2
100-
@test simplify(sin(y)^2 + cos(y)^2 + 1) == 2
98+
@test unwrap_const(simplify(cos(x)^2 + 1 + sin(x)^2)) == 2
99+
@test unwrap_const(simplify(cos(y)^2 + 1 + sin(y)^2)) == 2
100+
@test unwrap_const(simplify(sin(y)^2 + cos(y)^2 + 1)) == 2
101101

102102
@eqtest simplify(1 + y + tan(x)^2) == sec(x)^2 + y
103103
@eqtest simplify(1 + y + cot(x)^2) == csc(x)^2 + y
104104
@eqtest simplify(cos(x)^2 - 1) == -sin(x)^2
105105
@eqtest simplify(sin(x)^2 - 1) == -cos(x)^2
106106

107-
@eqtest simplify(cosh(x)^2 + 1 - sinh(x)^2) == 2
108-
@eqtest simplify(cosh(y)^2 + 1 - sinh(y)^2) == 2
109-
@eqtest simplify(-sinh(y)^2 + cosh(y)^2 + 1) == 2
107+
@eqtest unwrap_const(simplify(cosh(x)^2 + 1 - sinh(x)^2)) == 2
108+
@eqtest unwrap_const(simplify(cosh(y)^2 + 1 - sinh(y)^2)) == 2
109+
@eqtest unwrap_const(simplify(-sinh(y)^2 + cosh(y)^2 + 1)) == 2
110110

111111
@eqtest simplify(cosh(x)^2 - 1) == sinh(x)^2
112112
@eqtest simplify(sinh(x)^2 + 1) == cosh(x)^2
@@ -128,17 +128,17 @@ end
128128
@syms a::Real b::Real
129129
@eqtest simplify(exp(a) * exp(b)) == simplify(exp(a + b))
130130
@eqtest simplify(exp(a) * exp(a)) == simplify(exp(2a))
131-
@test simplify(exp(a) * exp(-a)) == 1
131+
@test unwrap_const(simplify(exp(a) * exp(-a))) == 1
132132
@eqtest simplify(exp(a)^2) == simplify(exp(2a))
133133
@eqtest simplify(exp(a) * a * exp(b)) == simplify(a * exp(a + b))
134-
@eqtest simplify(one(Int)^a) == 1
135-
@eqtest simplify(one(Complex{Float64})^a) == 1
134+
@eqtest unwrap_const(simplify(one(Int)^a)) == 1
135+
@eqtest unwrap_const(simplify(one(Complex{Float64})^a)) == 1
136136
@eqtest simplify(a^b * 1^a) == a^b
137137
end
138138

139139
@testset "simplify_fractions" begin
140140
@syms x y z
141-
@eqtest simplify(2 * ((y + z) / x) - 2 * y / x - z / x * 2) == 0
141+
@eqtest unwrap_const(simplify(2 * ((y + z) / x) - 2 * y / x - z / x * 2)) == 0
142142
end
143143

144144
@testset "Depth" begin

0 commit comments

Comments
 (0)