Skip to content

Commit

Permalink
Merge pull request #122 from ponder-lab/210-missing-cases-for-importi…
Browse files Browse the repository at this point in the history
…ng-scripts-from-package-initialization-code

Add tests for wala#210.
  • Loading branch information
khatchad authored Jul 22, 2024
2 parents 190f1ab + 89dddc8 commit aefcf44
Show file tree
Hide file tree
Showing 17 changed files with 145 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions com.ibm.wala.cast.python.test/.pydevproject
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@
<path>/${PROJECT_DIR_NAME}/data/proj55</path>
<path>/${PROJECT_DIR_NAME}/data/proj56</path>
<path>/${PROJECT_DIR_NAME}/data/proj66</path>
<path>/${PROJECT_DIR_NAME}/data/proj65</path>
<path>/${PROJECT_DIR_NAME}/data/proj67</path>
<path>/${PROJECT_DIR_NAME}/data/proj68</path>
<path>/${PROJECT_DIR_NAME}/data/proj69</path>
<path>/${PROJECT_DIR_NAME}/data/proj70</path>
</pydev_pathproperty>
</pydev_project>
6 changes: 6 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj65/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Test https://github.com/wala/ML/issues/210.

from tensorflow import ones
import src

src.f(ones([1, 2]))
1 change: 1 addition & 0 deletions com.ibm.wala.cast.python.test/data/proj65/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .module import *
7 changes: 7 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj65/src/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test https://github.com/wala/ML/issues/210.

import tensorflow as tf


def f(a):
assert isinstance(a, tf.Tensor)
6 changes: 6 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj67/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Test https://github.com/wala/ML/issues/210.

from tensorflow import ones
import src

src.f(ones([1, 2]))
1 change: 1 addition & 0 deletions com.ibm.wala.cast.python.test/data/proj67/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .module import f
7 changes: 7 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj67/src/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test https://github.com/wala/ML/issues/210.

import tensorflow as tf


def f(a):
assert isinstance(a, tf.Tensor)
6 changes: 6 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj68/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Test https://github.com/wala/ML/issues/210.

from tensorflow import ones
from src import f

f(ones([1, 2]))
1 change: 1 addition & 0 deletions com.ibm.wala.cast.python.test/data/proj68/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .module import *
7 changes: 7 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj68/src/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test https://github.com/wala/ML/issues/210.

import tensorflow as tf


def f(a):
assert isinstance(a, tf.Tensor)
6 changes: 6 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj69/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Test https://github.com/wala/ML/issues/210.

from tensorflow import ones
from src import f

f(ones([1, 2]))
1 change: 1 addition & 0 deletions com.ibm.wala.cast.python.test/data/proj69/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .module import f
7 changes: 7 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj69/src/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test https://github.com/wala/ML/issues/210.

import tensorflow as tf


def f(a):
assert isinstance(a, tf.Tensor)
6 changes: 6 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj70/client.py
Original file line number Diff line number Diff line change
@@ -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]))
1 change: 1 addition & 0 deletions com.ibm.wala.cast.python.test/data/proj70/src/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

7 changes: 7 additions & 0 deletions com.ibm.wala.cast.python.test/data/proj70/src/module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test https://github.com/wala/ML/issues/210.

import tensorflow as tf


def f(a):
assert isinstance(a, tf.Tensor)

0 comments on commit aefcf44

Please sign in to comment.