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])
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])
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])
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])
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, [])
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])
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])
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, [])
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, [])
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, [])
def test_catch_with_functions(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/CatchWithFunctions.java') self.assertEqual(lines, [6])
def test_multiple_catch(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/MultipleCatch.java') self.assertEqual(lines, [3])
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])
def test_fake(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/TrickyFake.java') self.assertEqual(lines, [])
def test_both_catches(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/BothCatches.java') self.assertEqual(lines, [3])
def test_simple(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/Simple.java') self.assertEqual(lines, [3])
def test_try_without_throws(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/ExcelReader.java') self.assertEqual(lines, [])
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])
def test_try_in_constructor(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/ExcelAnalyserImpl.java') self.assertEqual(lines, [43])
def test_try_inside_try(self): pattern = RedundantCatch() lines = pattern.value( os.path.dirname(os.path.realpath(__file__)) + '/TryInsideTry.java') self.assertEqual(lines, [5])
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])