Exemple #1
0
 def test_nested_chain_complicated_structure(self):
     """
     Several nested structures are checked: nested method chaining
     with nested anonymous classes
     """
     filepath = self.current_directory / "HolyMolyNestedChain.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [60, 67, 77])
Exemple #2
0
 def test_nested_chain_with_this(self):
     filepath = self.current_directory / "NestedChainWIthThis.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [14, 15])
Exemple #3
0
 def test_chain_without_object_creating(self):
     filepath = self.current_directory / "WithoutObjectCreating.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [14])
Exemple #4
0
 def test_several_chains(self):
     filepath = self.current_directory / "MethodChainSeveral.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [13, 34, 48])
Exemple #5
0
 def test_chain_in_anonymous_class_empty(self):
     filepath = self.current_directory / "MethodChainAnonymousClassEmpty.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [])
Exemple #6
0
 def test_chain_in_nested_class(self):
     filepath = self.current_directory / "MethodChainNestedClass.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [19])
Exemple #7
0
 def test_method_chain_in_different_methods(self):
     filepath = self.current_directory / "MethodChainInDifferentMethods.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [22, 34])
Exemple #8
0
 def test_chain_with_new_object(self):
     filepath = self.current_directory / "MethodChainNewObjectMethods.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [23, 34])
Exemple #9
0
 def test_empty_method_chain(self):
     filepath = self.current_directory / "EmptyMethodChain.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [21])
Exemple #10
0
 def test_many_chains(self):
     filepath = self.current_directory / "MachineLearningGetResultsIT.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertGreater(len(lines), 300)
Exemple #11
0
 def test_smallest_chain(self):
     filepath = self.current_directory / "SmallestChain.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [31, 83, 84])
Exemple #12
0
 def test_nested_chain_with_simple_method_invocation(self):
     filepath = self.current_directory / "NestedChainWithSimpleMethodInvocation.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     pattern = MethodChainFind()
     lines = pattern.value(ast)
     self.assertEqual(lines, [15, 16])