From 5a479586f3833952e3f71d863e866bb93f90483d Mon Sep 17 00:00:00 2001 From: Raffi Khatchadourian Date: Thu, 30 Nov 2023 12:24:08 -0500 Subject: [PATCH] Add user-defined superclass. --- com.ibm.wala.cast.python.test/data/callables5.py | 13 +++++++++++++ com.ibm.wala.cast.python.test/data/callables6.py | 13 +++++++++++++ .../ibm/wala/cast/python/test/TestCallables.java | 2 +- 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 com.ibm.wala.cast.python.test/data/callables5.py create mode 100644 com.ibm.wala.cast.python.test/data/callables6.py diff --git a/com.ibm.wala.cast.python.test/data/callables5.py b/com.ibm.wala.cast.python.test/data/callables5.py new file mode 100644 index 000000000..e29d03592 --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/callables5.py @@ -0,0 +1,13 @@ +class D: + pass + + +class C(D): + + def __call__(self, x): + return x * x + + +c = C() +a = c.__call__(5) +assert a == 25 diff --git a/com.ibm.wala.cast.python.test/data/callables6.py b/com.ibm.wala.cast.python.test/data/callables6.py new file mode 100644 index 000000000..0040d95ec --- /dev/null +++ b/com.ibm.wala.cast.python.test/data/callables6.py @@ -0,0 +1,13 @@ +class D: + pass + + +class C(D): + + def __call__(self, x): + return x * x + + +c = C() +a = c(5) +assert a == 25 diff --git a/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCallables.java b/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCallables.java index 65628414a..1af03fdfd 100644 --- a/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCallables.java +++ b/com.ibm.wala.cast.python.test/source/com/ibm/wala/cast/python/test/TestCallables.java @@ -19,7 +19,7 @@ public class TestCallables extends TestPythonCallGraphShape { @Test public void testCallables() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException { - final String[] testFileNames = {"callables.py", "callables2.py", "callables3.py", "callables4.py"}; + final String[] testFileNames = {"callables.py", "callables2.py", "callables3.py", "callables4.py", "callables5.py", "callables6.py"}; for (String fileName : testFileNames) { PythonAnalysisEngine E = makeEngine(fileName);