Skip to content

Commit

Permalink
Fix all warnings in test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
twizmwazin committed Jul 15, 2024
1 parent 1009da1 commit b146980
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions tests/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def test_associativity(self):
assert (x * y * z * w).shallow_repr() == "<BV8 x * y * z * w>"
assert (x + y - z - w).shallow_repr() == "<BV8 x + y - z - w>"
assert (x + (y - (z - w))).shallow_repr() == "<BV8 x + (y - (z - w))>"
assert (x * y / z % w).shallow_repr() == "<BV8 x * y / z % w>"
assert (x * (y / (z % w))).shallow_repr() == "<BV8 x * (y / (z % w))>"
assert (x * y // z % w).shallow_repr() == "<BV8 x * y / z % w>"
assert (x * (y // (z % w))).shallow_repr() == "<BV8 x * (y / (z % w))>"


if __name__ == "__main__":
Expand Down
18 changes: 9 additions & 9 deletions tests/test_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def raw_ite(self, solver_type):
ss = s.branch()
ss.add(z == itz)
ss.add(itz != 0)
self.assertEqual(ss.eval(y / x, 100), (2,))
self.assertEqual(ss.eval(y // x, 100), (2,))
self.assertEqual(sorted(ss.eval(x, 100)), [1, 10, 100])
self.assertEqual(sorted(ss.eval(y, 100)), [2, 20, 200])

Expand Down Expand Up @@ -447,10 +447,10 @@ def test_signed_concrete(self):
d = claripy.BVV(-3, 32)

# test unsigned
assert bc.convert(a / c) == 1
assert bc.convert(a / d) == 0
assert bc.convert(b / c) == 0x55555553
assert bc.convert(b / d) == 0
assert bc.convert(a // c) == 1
assert bc.convert(a // d) == 0
assert bc.convert(b // c) == 0x55555553
assert bc.convert(b // d) == 0
assert bc.convert(a % c) == 2
assert bc.convert(a % d) == 5
assert bc.convert(b % c) == 2
Expand Down Expand Up @@ -478,10 +478,10 @@ def test_signed_symbolic(self):
solver.add(d == -3)

# test unsigned
assert list(solver.eval(a / c, 2)) == [1]
assert list(solver.eval(a / d, 2)) == [0]
assert list(solver.eval(b / c, 2)) == [0x55555553]
assert list(solver.eval(b / d, 2)) == [0]
assert list(solver.eval(a // c, 2)) == [1]
assert list(solver.eval(a // d, 2)) == [0]
assert list(solver.eval(b // c, 2)) == [0x55555553]
assert list(solver.eval(b // d, 2)) == [0]
assert list(solver.eval(a % c, 2)) == [2]
assert list(solver.eval(a % d, 2)) == [5]
assert list(solver.eval(b % c, 2)) == [2]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def assert_correct(a, b):

# make sure the division simplification works
assert_correct(2 + x, claripy.backends.z3.simplify(1 + x + 1))
assert_correct(x / y, claripy.backends.z3.simplify(x / y))
assert_correct(x // y, claripy.backends.z3.simplify(x // y))
assert_correct(x % y, claripy.backends.z3.simplify(x % y))

def test_rotate_shift_mask_simplification(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def test_zero_division_in_cache_mixin(self):
s = claripy.Solver()
s.add(e == 8)
assert s.satisfiable()
s.add(claripy.If(denum == 0, 0, num / denum) == e)
s.add(claripy.If(denum == 0, 0, num // denum) == e)
assert s.satisfiable()
# As a bonus:
s.add(num == 16)
Expand Down
12 changes: 6 additions & 6 deletions tests/test_vsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,16 @@ def test_wrapped_intervals(self):
si1 = claripy.SI(bits=32, to_conv=10)
si2 = claripy.SI(bits=32, to_conv=5)
si3 = claripy.SI(bits=32, to_conv=2)
assert claripy.backends.vsa.identical(si1 / si2, si3)
assert claripy.backends.vsa.identical(si1 // si2, si3)

si3 = claripy.SI(bits=32, to_conv=0)
assert claripy.backends.vsa.identical(si2 / si1, si3)
assert claripy.backends.vsa.identical(si2 // si1, si3)

# intervals division
si1 = claripy.SI(bits=32, stride=1, lower_bound=10, upper_bound=100)
si2 = claripy.SI(bits=32, stride=1, lower_bound=10, upper_bound=20)
si3 = claripy.SI(bits=32, stride=1, lower_bound=0, upper_bound=10)
assert claripy.backends.vsa.identical(si1 / si2, si3)
assert claripy.backends.vsa.identical(si1 // si2, si3)

#
# Extension
Expand Down Expand Up @@ -381,10 +381,10 @@ def is_equal(ast_0, ast_1):
assert si_mul_3.size() == 32
assert is_equal(si_mul_3, claripy.SI(bits=32, stride=2, lower_bound=-2000, upper_bound=4000))
# Division
si_div_1 = si1 / 3
si_div_1 = si1 // 3
assert si_div_1.size() == 32
assert is_equal(si_div_1, claripy.SI(bits=32, stride=0, lower_bound=3, upper_bound=3))
si_div_2 = si_a / 3
si_div_2 = si_a // 3
assert si_div_2.size() == 32
assert is_equal(si_div_2, claripy.SI(bits=32, stride=1, lower_bound=3, upper_bound=6))
# Modulo
Expand Down Expand Up @@ -566,7 +566,7 @@ def is_equal(ast_0, ast_1):
# ValueSet
#

def VS(name=None, bits=None, region=None, val=None):
def VS(name=None, bits=None, region=None, val=None): # noqa: F811
region = "foobar" if region is None else region
return claripy.ValueSet(bits, region=region, region_base_addr=0, value=val, name=name)

Expand Down

0 comments on commit b146980

Please sign in to comment.