<?xml version="1.0" encoding="UTF-8"?>
<test-data>
    <test-code>
        <description><![CDATA[
bad
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  int x = 2;
  if ((x = getX()) == 3) {
   System.out.println("3!");
  }
 }
 private int getX() {
  return 3;
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (false) {}
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
assignment in if conditional expression
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  if (false) {
   int x =2;
  }
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
assignment in while conditional expression
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  int x = 2;
  while ( (x = getX()) != 0 ) {}
 }
 private int getX() {return 2;}
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
ok
     ]]></description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  for (int i = 0; i < 10; i++) {
     int x = i;
  }
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
assignment in for conditional expression
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  for (int i = 0; (i = i + 1) < 10; i++) {
     int x = i;
  }
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
increment in if conditional expression
     ]]></description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
 public void bar() {
  int x = 0;
  if (x++ > 0) {
     x = 2;
  }
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
assignment in while conditional expression, allowed
     ]]></description>
        <expected-problems>0</expected-problems>
        <rule-property name="allowWhile">true</rule-property>
        <code><![CDATA[
public class Foo {
 public void bar() {
  int x = 2;
  while ( (x = getX()) != 0 ) {}
 }
 private int getX() {return 2;}
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
assignment in if conditional expression, allowed
     ]]></description>
        <expected-problems>0</expected-problems>
        <rule-property name="allowIf">true</rule-property>
        <code><![CDATA[
public class Foo {
 public void bar() {
  int x = 2;
  if ((x = getX()) == 3) {
   System.out.println("3!");
  }
 }
 private int getX() {
  return 3;
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
assignment in for conditional expression, allowed
     ]]></description>
        <expected-problems>0</expected-problems>
        <rule-property name="allowFor">true</rule-property>
        <code><![CDATA[
public class Foo {
 public void bar() {
  for (int i = 0; (i = i + 1) < 10; i++) {
     int x = i;
  }
 }
}
     ]]></code>
    </test-code>
    <test-code>
        <description><![CDATA[
increment in if conditional expression, allowed
     ]]></description>
        <expected-problems>0</expected-problems>
        <rule-property name="allowIncrementDecrement">true</rule-property>
        <code><![CDATA[
public class Foo {
 public void bar() {
  int x = 0;
  if (x++ > 0) {
     x = 2;
  }
 }
}
     ]]></code>
    </test-code>
</test-data>
