Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases. #120

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3139,6 +3139,26 @@ public void testReshape3() throws ClassHierarchyException, CancelException, IOEx
test("tf2_test_reshape3.py", "f", 1, 1, 2);
}

@Test
public void testCalls() throws ClassHierarchyException, CancelException, IOException {
test(
new String[] {"tf2_test_calls.py", "tf2_test_calls2.py", "tf2_test_calls3.py"},
"tf2_test_calls.py",
"C.call",
"",
1,
1,
3);
test(
new String[] {"tf2_test_calls.py", "tf2_test_calls2.py", "tf2_test_calls3.py"},
"tf2_test_calls2.py",
"C.call",
"",
1,
1,
3);
}

private void test(
String filename,
String functionName,
Expand Down
11 changes: 11 additions & 0 deletions com.ibm.wala.cast.python.test/data/tf2_test_calls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import tensorflow as tf
from tf2_test_calls3 import g


class C(tf.keras.Model):

def call(self, a):
assert isinstance(a, tf.Tensor)


g(C())
11 changes: 11 additions & 0 deletions com.ibm.wala.cast.python.test/data/tf2_test_calls2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import tensorflow as tf
from tf2_test_calls3 import g


class C(tf.keras.Model):

def call(self, a):
assert isinstance(a, tf.Tensor)


g(C())
5 changes: 5 additions & 0 deletions com.ibm.wala.cast.python.test/data/tf2_test_calls3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import tensorflow as tf


def g(b):
b(tf.constant(1))
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ private IClass getCallable(CGNode caller, IClassHierarchy cha, PythonInvokeInstr
PointerKey receiver = pkf.getPointerKeyForLocal(caller, call.getUse(0));
OrdinalSet<InstanceKey> objs = builder.getPointerAnalysis().getPointsToSet(receiver);

LOGGER.fine(() -> receiver + " points to " + objs.size() + " instance(s).");

for (InstanceKey o : objs) {
AllocationSiteInNode instanceKey = getAllocationSiteInNode(o);
if (instanceKey != null) {
Expand Down
Loading