Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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, [])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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])
Exemplo n.º 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)
Exemplo n.º 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])
Exemplo n.º 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])