From 3eeebb57c88a3ed59d1b7c8ba39ec7346822829f Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Mon, 22 Jul 2024 13:17:20 -0400 Subject: [PATCH] Test https://github.com/wala/ML/issues/211. --- .../python/ml/test/TestTensorflow2Model.java | 35 +++++++++++++++++++ com.ibm.wala.cast.python.test/.pydevproject | 2 ++ com.ibm.wala.cast.python.test/data/client.py | 6 ++++ com.ibm.wala.cast.python.test/data/module.py | 7 ++++ .../data/proj71/src/__init__.py | 1 + .../data/proj71/src/client.py | 6 ++++ .../data/proj71/src/module.py | 7 ++++ .../data/proj72/src/__init__.py | 1 + .../data/proj72/src/client.py | 6 ++++ .../data/proj72/src/module.py | 7 ++++ 10 files changed, 78 insertions(+) create mode 100644 com.ibm.wala.cast.python.test/data/client.py create mode 100644 com.ibm.wala.cast.python.test/data/module.py create mode 100644 com.ibm.wala.cast.python.test/data/proj71/src/__init__.py create mode 100644 com.ibm.wala.cast.python.test/data/proj71/src/client.py create mode 100644 com.ibm.wala.cast.python.test/data/proj71/src/module.py create mode 100644 com.ibm.wala.cast.python.test/data/proj72/src/__init__.py create mode 100644 com.ibm.wala.cast.python.test/data/proj72/src/client.py create mode 100644 com.ibm.wala.cast.python.test/data/proj72/src/module.py diff --git a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java index 61ba34da..c971aa96 100644 --- a/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java +++ b/com.ibm.wala.cast.python.ml.test/source/com/ibm/wala/cast/python/ml/test/TestTensorflow2Model.java @@ -2934,6 +2934,41 @@ public void testModule74() new int[] {2}); } + /** Test https://github.com/wala/ML/issues/211. */ + @Test(expected = AssertionError.class) + public void testModule75() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj71/src/__init__.py", "proj71/src/module.py", "proj71/src/client.py"}, + "src/module.py", + "f", + "proj71", + 1, + 1, + new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/211. */ + @Test + public void testModule76() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test(new String[] {"module.py", "client.py"}, "module.py", "f", "", 1, 1, new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/211. */ + @Test + public void testModule77() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj72/src/__init__.py", "proj72/src/module.py", "proj72/src/client.py"}, + "src/module.py", + "f", + "proj72", + 1, + 1, + new int[] {2}); + } + @Test public void testStaticMethod() throws ClassHierarchyException, CancelException, IOException { test("tf2_test_static_method.py", "MyClass.the_static_method", 1, 1, 2); diff --git a/com.ibm.wala.cast.python.test/.pydevproject b/com.ibm.wala.cast.python.test/.pydevproject index 8352fdd6..3fb070e5 100644 --- a/com.ibm.wala.cast.python.test/.pydevproject +++ b/com.ibm.wala.cast.python.test/.pydevproject @@ -26,5 +26,7 @@ /${PROJECT_DIR_NAME}/data/proj68 /${PROJECT_DIR_NAME}/data/proj69 /${PROJECT_DIR_NAME}/data/proj70 + /${PROJECT_DIR_NAME}/data/proj71 + /${PROJECT_DIR_NAME}/data/proj72 diff --git a/com.ibm.wala.cast.python.test/data/client.py b/com.ibm.wala.cast.python.test/data/client.py new file mode 100644 index 00000000..85bf4e38 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/211. + +from tensorflow import ones +import module + +module.f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/module.py b/com.ibm.wala.cast.python.test/data/module.py new file mode 100644 index 00000000..c729ed3f --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/211. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj71/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj71/src/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj71/src/__init__.py @@ -0,0 +1 @@ + diff --git a/com.ibm.wala.cast.python.test/data/proj71/src/client.py b/com.ibm.wala.cast.python.test/data/proj71/src/client.py new file mode 100644 index 00000000..85bf4e38 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj71/src/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/211. + +from tensorflow import ones +import module + +module.f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj71/src/module.py b/com.ibm.wala.cast.python.test/data/proj71/src/module.py new file mode 100644 index 00000000..c729ed3f --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj71/src/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/211. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj72/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj72/src/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj72/src/__init__.py @@ -0,0 +1 @@ + diff --git a/com.ibm.wala.cast.python.test/data/proj72/src/client.py b/com.ibm.wala.cast.python.test/data/proj72/src/client.py new file mode 100644 index 00000000..02346a3f --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj72/src/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/211. + +from tensorflow import ones +from module import f + +f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj72/src/module.py b/com.ibm.wala.cast.python.test/data/proj72/src/module.py new file mode 100644 index 00000000..c729ed3f --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj72/src/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/211. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor)