-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e246433
commit d82197f
Showing
19 changed files
with
2,224 additions
and
2,393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
import claripy | ||
|
||
|
||
def test_lite_repr(): | ||
one = claripy.BVV(1, 8) | ||
two = claripy.BVV(2, 8) | ||
a = claripy.BVS("a", 8, explicit_name=True) | ||
b = claripy.BVS("b", 8, explicit_name=True) | ||
|
||
assert (a + one * b + two).shallow_repr() == "<BV8 a + 1 * b + 2>" | ||
assert ((a + one) * (b + two)).shallow_repr() == "<BV8 (a + 1) * (b + 2)>" | ||
assert (a * one + b * two).shallow_repr() == "<BV8 a * 1 + b * 2>" | ||
assert ( | ||
(one + a) * (two + b) + (two + a) * (one + b) | ||
).shallow_repr() == "<BV8 (1 + a) * (2 + b) + (2 + a) * (1 + b)>" | ||
import unittest | ||
|
||
import claripy | ||
|
||
def test_associativity(): | ||
x = claripy.BVS("x", 8, explicit_name=True) | ||
y = claripy.BVS("y", 8, explicit_name=True) | ||
z = claripy.BVS("z", 8, explicit_name=True) | ||
w = claripy.BVS("w", 8, explicit_name=True) | ||
|
||
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() == (x * y * z * w).shallow_repr() | ||
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))>" | ||
class TestAST(unittest.TestCase): | ||
def test_lite_repr(self): | ||
one = claripy.BVV(1, 8) | ||
two = claripy.BVV(2, 8) | ||
a = claripy.BVS("a", 8, explicit_name=True) | ||
b = claripy.BVS("b", 8, explicit_name=True) | ||
|
||
assert (a + one * b + two).shallow_repr() == "<BV8 a + 1 * b + 2>" | ||
assert ((a + one) * (b + two)).shallow_repr() == "<BV8 (a + 1) * (b + 2)>" | ||
assert (a * one + b * two).shallow_repr() == "<BV8 a * 1 + b * 2>" | ||
assert ( | ||
(one + a) * (two + b) + (two + a) * (one + b) | ||
).shallow_repr() == "<BV8 (1 + a) * (2 + b) + (2 + a) * (1 + b)>" | ||
|
||
def test_associativity(self): | ||
x = claripy.BVS("x", 8, explicit_name=True) | ||
y = claripy.BVS("y", 8, explicit_name=True) | ||
z = claripy.BVS("z", 8, explicit_name=True) | ||
w = claripy.BVS("w", 8, explicit_name=True) | ||
|
||
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() == (x * y * z * w).shallow_repr() | ||
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__": | ||
test_lite_repr() | ||
test_associativity() | ||
unittest.main() |
Oops, something went wrong.