Ejemplo n.º 1
0
 def test_multiple_catch(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/MultipleCatch.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [3])
Ejemplo n.º 2
0
 def test_try_inside_finally(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/TryInsideFinally.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [8])
Ejemplo n.º 3
0
 def test_try_in_constructor(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/ExcelAnalyserImpl.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [43])
Ejemplo n.º 4
0
 def test_catch_with_similar_name(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/NotThrow.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [256])
Ejemplo n.º 5
0
 def test_try_without_throws(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/ExcelReader.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [])
Ejemplo n.º 6
0
 def test_sequential_catch_try(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/SequentialCatchTry.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [3, 10])
Ejemplo n.º 7
0
 def test_catch_with_functions(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/CatchWithFunctions.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [6])
Ejemplo n.º 8
0
 def test_fake(self):
     pattern = RedundantCatch()
     filepath = os.path.dirname(
         os.path.realpath(__file__)) + "/TrickyFake.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [])
Ejemplo n.º 9
0
 def test_fake_try_in_lambda(self):
     """
     If function has throws, the pattern shouldn't be recognized
     if the same exception is caught in anonymous lambda
     """
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) + '/Cache.java')
     self.assertEqual(lines, [])
Ejemplo n.º 10
0
 def test_fake_try_in_lambda(self):
     """
     If function has throws, the pattern shouldn't be recognized
     if the same exception is caught in anonymous lambda
     """
     pattern = RedundantCatch()
     filepath = os.path.dirname(os.path.realpath(__file__)) + "/Cache.java"
     ast = AST.build_from_javalang(build_ast(filepath))
     lines = pattern.value(ast)
     self.assertEqual(lines, [])
Ejemplo n.º 11
0
 def test_catch_with_functions(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) +
         '/CatchWithFunctions.java')
     self.assertEqual(lines, [6])
Ejemplo n.º 12
0
 def test_multiple_catch(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) +
         '/MultipleCatch.java')
     self.assertEqual(lines, [3])
Ejemplo n.º 13
0
 def test_try_inside_anonymous(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) +
         '/TryInsideAnonymous.java')
     self.assertEqual(lines, [6, 14])
Ejemplo n.º 14
0
 def test_fake(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) + '/TrickyFake.java')
     self.assertEqual(lines, [])
Ejemplo n.º 15
0
 def test_both_catches(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) + '/BothCatches.java')
     self.assertEqual(lines, [3])
Ejemplo n.º 16
0
 def test_simple(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) + '/Simple.java')
     self.assertEqual(lines, [3])
Ejemplo n.º 17
0
 def test_try_without_throws(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) + '/ExcelReader.java')
     self.assertEqual(lines, [])
Ejemplo n.º 18
0
 def test_sequential_catch_try(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) +
         '/SequentialCatchTry.java')
     self.assertEqual(lines, [3, 10])
Ejemplo n.º 19
0
 def test_try_in_constructor(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) +
         '/ExcelAnalyserImpl.java')
     self.assertEqual(lines, [43])
Ejemplo n.º 20
0
 def test_try_inside_try(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) + '/TryInsideTry.java')
     self.assertEqual(lines, [5])
Ejemplo n.º 21
0
 def test_catch_with_similar_name(self):
     pattern = RedundantCatch()
     lines = pattern.value(
         os.path.dirname(os.path.realpath(__file__)) + '/NotThrow.java')
     self.assertEqual(lines, [256])