-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
2 changed files
with
56 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pyObjectManager.Int import Int | ||
|
||
def handle(state,call,obj): | ||
""" | ||
Simulate len funcion | ||
""" | ||
# Resolve the object | ||
obj = state.resolveObject(obj) | ||
|
||
# Just calling the length function on the object.. | ||
l = obj.length() | ||
|
||
i = state.getVar("tmpLenValue",ctx=1, varType=Int) | ||
i.increment() | ||
|
||
# Tell Z3 about our value | ||
state.addConstraint(i.getZ3Object() == l) | ||
|
||
return i.copy() |
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,37 @@ | ||
import sys, os | ||
myPath = os.path.dirname(os.path.abspath(__file__)) | ||
sys.path.insert(0, myPath + '/../') | ||
|
||
import logging | ||
import Colorer | ||
logging.basicConfig(level=logging.DEBUG,format='%(name)s - %(levelname)s - %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') | ||
|
||
import ast | ||
import z3 | ||
from pyPath import Path | ||
from pyPathGroup import PathGroup | ||
import pytest | ||
from pyObjectManager.Int import Int | ||
from pyObjectManager.Real import Real | ||
from pyObjectManager.BitVec import BitVec | ||
from pyObjectManager.List import List | ||
|
||
test1 = """ | ||
s = "abcd" | ||
l = [x for x in s] + [1,2] | ||
x = len(s) | ||
y = len(l) | ||
""" | ||
|
||
|
||
def test_function_len(): | ||
b = ast.parse(test1).body | ||
p = Path(b,source=test1) | ||
pg = PathGroup(p) | ||
|
||
pg.explore() | ||
assert len(pg.completed) == 1 | ||
|
||
assert pg.completed[0].state.any_int('x') == 4 | ||
assert pg.completed[0].state.any_int('y') == 6 | ||
|