diff --git a/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonAnalyserTest.kt b/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonAnalyserTest.kt index 8976c8c4..aa32478b 100644 --- a/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonAnalyserTest.kt +++ b/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonAnalyserTest.kt @@ -3,5 +3,8 @@ package chapi.ast.pythonast import org.junit.jupiter.api.Test internal class PythonAnalyserTest { + @Test + internal fun shouldIdentBuilderPattern() { + } } diff --git a/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonFullIdentListenerTest.kt b/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonFullIdentListenerTest.kt index 1b08a231..d6160522 100644 --- a/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonFullIdentListenerTest.kt +++ b/chapi-ast-python/src/test/kotlin/chapi/ast/pythonast/PythonFullIdentListenerTest.kt @@ -9,13 +9,15 @@ internal class PythonFullIdentListenerTest { internal fun shouldAnalysisPython2() { val python2HelloWorld = """print("Hello, World!")""" - PythonAnalyser().analysis(python2HelloWorld, "") + val codeContainer = PythonAnalyser().analysis(python2HelloWorld, "py2.py") + assertEquals(codeContainer.FullName, "py2.py") } @Test internal fun shouldAnalysisPython3() { val py3HelloWorld = """print "Hello, World!"""" - PythonAnalyser().analysis(py3HelloWorld, "") + val codeContainer = PythonAnalyser().analysis(py3HelloWorld, "py3.py") + assertEquals(codeContainer.FullName, "py3.py") } @Test diff --git a/chapi-ast-python/src/test/resources/call/builder_pattern_call.py b/chapi-ast-python/src/test/resources/call/builder_pattern_call.py new file mode 100644 index 00000000..29c4e307 --- /dev/null +++ b/chapi-ast-python/src/test/resources/call/builder_pattern_call.py @@ -0,0 +1,18 @@ +## https://stackoverflow.com/questions/17321167/calling-chains-methods-with-intermediate-results + +class Person: + def setName(self, name): + self.name = name + return self ## this is what makes this work + + def setAge(self, age): + self.age = age; + return self; + + def setSSN(self, ssn): + self.ssn = ssn + return self + + +p = Person() +p.setName("Hunter").setAge(24).setSSN("111-22-3333")