示例#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])
示例#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])
示例#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])
示例#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])
示例#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, [])
示例#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])
示例#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])
示例#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])
示例#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])
示例#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)
示例#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])
示例#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])