From 89dddc87ebcc9efdb191f230087d4701d14a6c26 Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Mon, 22 Jul 2024 12:10:31 -0400 Subject: [PATCH] Add tests for https://github.com/wala/ML/issues/210. --- .../python/ml/test/TestTensorflow2Model.java | 70 +++++++++++++++++++ com.ibm.wala.cast.python.test/.pydevproject | 5 ++ .../data/proj65/client.py | 6 ++ .../data/proj65/src/__init__.py | 1 + .../data/proj65/src/module.py | 7 ++ .../data/proj67/client.py | 6 ++ .../data/proj67/src/__init__.py | 1 + .../data/proj67/src/module.py | 7 ++ .../data/proj68/client.py | 6 ++ .../data/proj68/src/__init__.py | 1 + .../data/proj68/src/module.py | 7 ++ .../data/proj69/client.py | 6 ++ .../data/proj69/src/__init__.py | 1 + .../data/proj69/src/module.py | 7 ++ .../data/proj70/client.py | 6 ++ .../data/proj70/src/__init__.py | 1 + .../data/proj70/src/module.py | 7 ++ 17 files changed, 145 insertions(+) create mode 100644 com.ibm.wala.cast.python.test/data/proj65/client.py create mode 100644 com.ibm.wala.cast.python.test/data/proj65/src/__init__.py create mode 100644 com.ibm.wala.cast.python.test/data/proj65/src/module.py create mode 100644 com.ibm.wala.cast.python.test/data/proj67/client.py create mode 100644 com.ibm.wala.cast.python.test/data/proj67/src/__init__.py create mode 100644 com.ibm.wala.cast.python.test/data/proj67/src/module.py create mode 100644 com.ibm.wala.cast.python.test/data/proj68/client.py create mode 100644 com.ibm.wala.cast.python.test/data/proj68/src/__init__.py create mode 100644 com.ibm.wala.cast.python.test/data/proj68/src/module.py create mode 100644 com.ibm.wala.cast.python.test/data/proj69/client.py create mode 100644 com.ibm.wala.cast.python.test/data/proj69/src/__init__.py create mode 100644 com.ibm.wala.cast.python.test/data/proj69/src/module.py create mode 100644 com.ibm.wala.cast.python.test/data/proj70/client.py create mode 100644 com.ibm.wala.cast.python.test/data/proj70/src/__init__.py create mode 100644 com.ibm.wala.cast.python.test/data/proj70/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 6f62c786..87a48194 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 @@ -2865,6 +2865,76 @@ public void testModule69() new int[] {2}); } + /** Test https://github.com/wala/ML/issues/210. */ + @Test(expected = AssertionError.class) + public void testModule70() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj65/src/__init__.py", "proj65/src/module.py", "proj65/client.py"}, + "src/module.py", + "f", + "proj65", + 1, + 1, + new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/210. */ + @Test(expected = AssertionError.class) + public void testModule71() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj67/src/__init__.py", "proj67/src/module.py", "proj67/client.py"}, + "src/module.py", + "f", + "proj67", + 1, + 1, + new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/210. */ + @Test + public void testModule72() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj68/src/__init__.py", "proj68/src/module.py", "proj68/client.py"}, + "src/module.py", + "f", + "proj68", + 1, + 1, + new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/210. */ + @Test + public void testModule73() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj69/src/__init__.py", "proj69/src/module.py", "proj69/client.py"}, + "src/module.py", + "f", + "proj69", + 1, + 1, + new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/210. */ + @Test + public void testModule74() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj70/src/__init__.py", "proj70/src/module.py", "proj70/client.py"}, + "src/module.py", + "f", + "proj70", + 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 eeda77de..8352fdd6 100644 --- a/com.ibm.wala.cast.python.test/.pydevproject +++ b/com.ibm.wala.cast.python.test/.pydevproject @@ -21,5 +21,10 @@ /${PROJECT_DIR_NAME}/data/proj55 /${PROJECT_DIR_NAME}/data/proj56 /${PROJECT_DIR_NAME}/data/proj66 + /${PROJECT_DIR_NAME}/data/proj65 + /${PROJECT_DIR_NAME}/data/proj67 + /${PROJECT_DIR_NAME}/data/proj68 + /${PROJECT_DIR_NAME}/data/proj69 + /${PROJECT_DIR_NAME}/data/proj70 diff --git a/com.ibm.wala.cast.python.test/data/proj65/client.py b/com.ibm.wala.cast.python.test/data/proj65/client.py new file mode 100644 index 00000000..94f776af --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj65/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/210. + +from tensorflow import ones +import src + +src.f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj65/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj65/src/__init__.py new file mode 100644 index 00000000..26769240 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj65/src/__init__.py @@ -0,0 +1 @@ +from .module import * diff --git a/com.ibm.wala.cast.python.test/data/proj65/src/module.py b/com.ibm.wala.cast.python.test/data/proj65/src/module.py new file mode 100644 index 00000000..b2364395 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj65/src/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/210. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj67/client.py b/com.ibm.wala.cast.python.test/data/proj67/client.py new file mode 100644 index 00000000..94f776af --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj67/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/210. + +from tensorflow import ones +import src + +src.f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj67/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj67/src/__init__.py new file mode 100644 index 00000000..9c32fb32 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj67/src/__init__.py @@ -0,0 +1 @@ +from .module import f diff --git a/com.ibm.wala.cast.python.test/data/proj67/src/module.py b/com.ibm.wala.cast.python.test/data/proj67/src/module.py new file mode 100644 index 00000000..b2364395 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj67/src/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/210. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj68/client.py b/com.ibm.wala.cast.python.test/data/proj68/client.py new file mode 100644 index 00000000..6734bed4 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj68/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/210. + +from tensorflow import ones +from src import f + +f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj68/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj68/src/__init__.py new file mode 100644 index 00000000..26769240 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj68/src/__init__.py @@ -0,0 +1 @@ +from .module import * diff --git a/com.ibm.wala.cast.python.test/data/proj68/src/module.py b/com.ibm.wala.cast.python.test/data/proj68/src/module.py new file mode 100644 index 00000000..b2364395 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj68/src/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/210. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj69/client.py b/com.ibm.wala.cast.python.test/data/proj69/client.py new file mode 100644 index 00000000..6734bed4 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj69/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/210. + +from tensorflow import ones +from src import f + +f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj69/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj69/src/__init__.py new file mode 100644 index 00000000..9c32fb32 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj69/src/__init__.py @@ -0,0 +1 @@ +from .module import f diff --git a/com.ibm.wala.cast.python.test/data/proj69/src/module.py b/com.ibm.wala.cast.python.test/data/proj69/src/module.py new file mode 100644 index 00000000..b2364395 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj69/src/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/210. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj70/client.py b/com.ibm.wala.cast.python.test/data/proj70/client.py new file mode 100644 index 00000000..4ba66104 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj70/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/210. + +from tensorflow import ones +import src.module + +src.module.f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj70/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj70/src/__init__.py new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj70/src/__init__.py @@ -0,0 +1 @@ + diff --git a/com.ibm.wala.cast.python.test/data/proj70/src/module.py b/com.ibm.wala.cast.python.test/data/proj70/src/module.py new file mode 100644 index 00000000..b2364395 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj70/src/module.py @@ -0,0 +1,7 @@ +# Test https://github.com/wala/ML/issues/210. + +import tensorflow as tf + + +def f(a): + assert isinstance(a, tf.Tensor)