Skip to content

Commit f101b14

Browse files
committed
Add basic test for f64 negation
1 parent e952015 commit f101b14

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

python/tests/test_high_level.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,24 @@ def from_numeric(n: Numeric) -> OtherNumeric: # type: ignore[empty-body]
221221

222222
egraph.register(rewrite(OtherNumeric(1)).to(from_numeric(Numeric.ONE)))
223223
assert expr_parts(egraph.simplify(OtherNumeric(i64(1)), 10)) == expr_parts(from_numeric(Numeric.ONE))
224+
225+
226+
def test_f64_negation() -> None:
227+
egraph = EGraph()
228+
# expr1 = -2.0
229+
expr1 = egraph.define("expr1", -f64(2.0))
230+
231+
# expr2 = 2.0
232+
expr2 = egraph.define("expr2", f64(2.0))
233+
234+
# expr3 = -(-2.0)
235+
expr3 = egraph.define("expr3", -(-f64(2.0)))
236+
237+
x, y = vars_("x y", f64)
238+
239+
egraph.register(rewrite(-(-x)).to(x))
240+
241+
egraph.run(10)
242+
243+
egraph.check(eq(expr1).to(-expr2))
244+
egraph.check(eq(expr3).to(expr2))

0 commit comments

Comments
 (0)