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 2a9ddb94..2e58b906 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 @@ -2760,6 +2760,48 @@ public void testModule64() new int[] {3}); } + /** Test https://github.com/wala/ML/issues/202. */ + @Test + public void testModule65() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj60/src/__init__.py", "proj60/src/module.py", "proj60/client.py"}, + "src/module.py", + "f", + "proj60", + 1, + 1, + new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/202. */ + @Test + public void testModule66() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj61/src/__init__.py", "proj61/src/module.py", "proj61/client.py"}, + "src/module.py", + "f", + "proj61", + 1, + 1, + new int[] {2}); + } + + /** Test https://github.com/wala/ML/issues/202. */ + @Test + public void testModule67() + throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { + test( + new String[] {"proj62/src/__init__.py", "proj62/src/B.py", "proj62/A.py"}, + "src/B.py", + "C.__call__", + "proj62", + 1, + 1, + new int[] {3}); + } + @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/.settings/org.eclipse.core.resources.prefs b/com.ibm.wala.cast.python.test/.settings/org.eclipse.core.resources.prefs index c0d8a789..600a2642 100644 --- a/com.ibm.wala.cast.python.test/.settings/org.eclipse.core.resources.prefs +++ b/com.ibm.wala.cast.python.test/.settings/org.eclipse.core.resources.prefs @@ -1,4 +1,6 @@ eclipse.preferences.version=1 +encoding//data/proj61/src/module.py=utf-8 +encoding//data/proj62/src/B.py=utf-8 encoding/=UTF-8 encoding/data=UTF-8 encoding/source=UTF-8 diff --git a/com.ibm.wala.cast.python.test/data/proj60/client.py b/com.ibm.wala.cast.python.test/data/proj60/client.py new file mode 100644 index 00000000..8590a685 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj60/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/163. + +from tensorflow import ones +from src import f + +f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj60/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj60/src/__init__.py new file mode 100644 index 00000000..9c32fb32 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj60/src/__init__.py @@ -0,0 +1 @@ +from .module import f diff --git a/com.ibm.wala.cast.python.test/data/proj60/src/module.py b/com.ibm.wala.cast.python.test/data/proj60/src/module.py new file mode 100644 index 00000000..ffce8f8c --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj60/src/module.py @@ -0,0 +1,9 @@ +""" +@Author:Kaiyin Zhou +""" + +from tensorflow import Tensor + + +def f(a): + assert isinstance(a, Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj61/client.py b/com.ibm.wala.cast.python.test/data/proj61/client.py new file mode 100644 index 00000000..8590a685 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj61/client.py @@ -0,0 +1,6 @@ +# Test https://github.com/wala/ML/issues/163. + +from tensorflow import ones +from src import f + +f(ones([1, 2])) diff --git a/com.ibm.wala.cast.python.test/data/proj61/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj61/src/__init__.py new file mode 100644 index 00000000..26769240 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj61/src/__init__.py @@ -0,0 +1 @@ +from .module import * diff --git a/com.ibm.wala.cast.python.test/data/proj61/src/module.py b/com.ibm.wala.cast.python.test/data/proj61/src/module.py new file mode 100644 index 00000000..1067686a --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj61/src/module.py @@ -0,0 +1,10 @@ +#! usr/bin/env python3 +# -*- coding:utf-8 -*- +""" +@Author:Kaiyin Zhou +""" +from tensorflow import Tensor + + +def f(a): + assert isinstance(a, Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj62/A.py b/com.ibm.wala.cast.python.test/data/proj62/A.py new file mode 100644 index 00000000..ce0028ae --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj62/A.py @@ -0,0 +1,16 @@ +# Test https://github.com/wala/ML/issues/163. + +from tensorflow import ones +from src import C + + +class D: + + def __init__(self): + self._c = C() + + def __call__(self): + self._c(ones([1, 2])) + + +D()() diff --git a/com.ibm.wala.cast.python.test/data/proj62/src/B.py b/com.ibm.wala.cast.python.test/data/proj62/src/B.py new file mode 100644 index 00000000..e2e53acf --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj62/src/B.py @@ -0,0 +1,15 @@ +#! usr/bin/env python3 +# -*- coding:utf-8 -*- +""" +@Author:Kaiyin Zhou +""" +from tensorflow import Tensor + + +class C: + + def __init__(self): + pass + + def __call__(self, a): + assert isinstance(a, Tensor) diff --git a/com.ibm.wala.cast.python.test/data/proj62/src/__init__.py b/com.ibm.wala.cast.python.test/data/proj62/src/__init__.py new file mode 100644 index 00000000..4338dce0 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/proj62/src/__init__.py @@ -0,0 +1 @@ +from .B import *