-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Phi._hash_core: Fix crashes caused by None in src_and_vvars. (#259)
- Loading branch information
Showing
2 changed files
with
33 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# pylint: disable=missing-class-docstring,no-self-use | ||
import unittest | ||
|
||
import ailment | ||
|
||
|
||
class TestExpression(unittest.TestCase): | ||
|
||
def test_phi_hashing(self): | ||
vvar_0 = ailment.expression.VirtualVariable(100, 0, 32, ailment.expression.VirtualVariableCategory.REGISTER, 16) | ||
vvar_1 = ailment.expression.VirtualVariable(101, 1, 32, ailment.expression.VirtualVariableCategory.REGISTER, 16) | ||
vvar_2 = ailment.expression.VirtualVariable(102, 2, 32, ailment.expression.VirtualVariableCategory.REGISTER, 16) | ||
phi_expr = ailment.expression.Phi( | ||
0, 32, [((0, None), vvar_0), ((0, 0), vvar_2), ((1, None), vvar_1), ((4, None), None)] | ||
) | ||
h = hash(phi_expr) # should not crash | ||
assert h is not None | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |