<?xml version="1.0" encoding="UTF-8"?>
<test-data>
    <test-code>
        <description><![CDATA[
failure case
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 void bar(Object x) {
  if (x != null && x instanceof String) {}
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 void bar(Object x) {
  if (x instanceof String) {}
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
transpose x and null, still bad
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 void bar(Object x) {
  if (null != x && x instanceof String) {}
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
conditional or and !(instanceof)
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 void bar(Object x) {
  if (x == null || !(x instanceof String)) {}
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
indexing into array is ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 void bar(Object x) {
  if (x != null && x[0] instanceof String) {}
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
test for null on unrelated object is ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 void bar(Object x) {
  if (x instanceof String && ((String)x).substring(2) != null) {}
 }
}
     ]]></code>
    </test-code>
        <test-code>
        <description><![CDATA[
Bug [1843273] False -
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Bug1843273
{
	public boolean isTrue(Boolean value)
	   {
	       boolean result = true;

	       if (value.booleanValue())
	       {
	           return result;
	       }
	       else
	       {
	           return ! result;
	       }
	   }
   }
     ]]></code>
    </test-code>

     <test-code>
        <description><![CDATA[
Bug 2317099 : False + in SimplifyConditional
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Bug2317099
{
  public void method(Env env) {
    if (env != null && env.getContext() != null &&
      env.getContext().getContextObject() instanceof PageContext) {
    }
 }
}
     ]]></code>
    </test-code>

    <test-code>
        <description>#1165 SimplifyConditional false positive</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public void bar(Object[] arguments) {
        if (
        arguments == null ||
        arguments.length < 3 || arguments.length > 4 ||
        !(arguments[0] instanceof String ) ||
        !(arguments[1] instanceof Boolean ) ||
        !(arguments[2] instanceof String ) ||
        arguments.length == 4 && !(arguments[3] instanceof String )
        ) {
            throw new IllegalArgumentException( "" );
        }
    }
}
        ]]></code>
    </test-code>
</test-data>
