From 63227be277eead28a4d1a1281a2e435b88fd6c31 Mon Sep 17 00:00:00 2001 From: Danila Ponomarenko Date: Fri, 29 Jun 2012 17:09:10 +0400 Subject: [PATCH] IDEA-87966 tests added --- .../PointlessBooleanExpression.java | 22 ++++++++++++++ .../expected.xml | 9 ++++++ ...ntlessBooleanExpressionInspectionTest.java | 30 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/PointlessBooleanExpression.java create mode 100644 plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/expected.xml create mode 100644 plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/PointlessBooleanExpressionInspectionTest.java diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/PointlessBooleanExpression.java b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/PointlessBooleanExpression.java new file mode 100644 index 000000000000..42fe05e4140a --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/PointlessBooleanExpression.java @@ -0,0 +1,22 @@ +public class Bug { + interface I1{} + interface I2{} + class C1 {} + class C2 extends C1 implements I1, I2{} + class C3 extends C1 implements I1, I2{} + + public static void x(C1 c1) { + if (c1 instanceof I1 && c1 instanceof I2) { + + } + + if (1 > Math.random() && Math.random()==Math.random()) { + + } + + boolean b = true; + if (!b){ + + } + } +} \ No newline at end of file diff --git a/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/expected.xml b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/expected.xml new file mode 100644 index 000000000000..d08633679fcc --- /dev/null +++ b/plugins/InspectionGadgets/test/com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const/expected.xml @@ -0,0 +1,9 @@ + + + + PointlessBooleanExpression.java + 18 + Pointless boolean expression + Condition '!b' is always 'false' + + diff --git a/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/PointlessBooleanExpressionInspectionTest.java b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/PointlessBooleanExpressionInspectionTest.java new file mode 100644 index 000000000000..2a55875af1a8 --- /dev/null +++ b/plugins/InspectionGadgets/testsrc/com/siyeh/ig/controlflow/PointlessBooleanExpressionInspectionTest.java @@ -0,0 +1,30 @@ +/* + * Copyright 2000-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.siyeh.ig.controlflow; + +import com.siyeh.ig.IGInspectionTestCase; + +/** + * @author Danila Ponomarenko + */ +public class PointlessBooleanExpressionInspectionTest extends IGInspectionTestCase { + + public void testIgnoreExpressionsContainingConstants() throws Exception { + final PointlessBooleanExpressionInspection inspection = new PointlessBooleanExpressionInspection(); + inspection.m_ignoreExpressionsContainingConstants = true; + doTest("com/siyeh/igtest/controlflow/pointless_boolean_expression_ignore_cont_const", inspection); + } +} \ No newline at end of file