<?xml version="1.0" encoding="UTF-8"?>
<test-data
    xmlns="http://pmd.sourceforge.net/rule-tests"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">

    <test-code>
        <description>assignment of a variable (field) to itself</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    int x;
    private void bar() {
        x = x;
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>assignment of a variable (local) to itself</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    private void bar() {
        int x;
        x = x;
    }
}
        ]]></code>
    </test-code>
    <test-code>
        <description>no fp for unknown reference</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    private void bar() {
        x = x;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>assignment of one array element to another</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    private void bar() {
        int[] x = {2,3};
        x = x[1];
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>qualified names causing NPE troubleshooting</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    Foo x;
    Foo foo;
    void bar() {this.x = foo;}
    void buz() {foo = this.x;}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>check for method calls</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar() {x = x();}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>compound assignments are OK</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void bar() {x += x;}
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#1104 IdempotentOperation false positive</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
// uncompilable
public class Foo {
    void bar() {
        SignDelayer.this.sign = SignDelayer.this.arg.sign();
        MMultiplexer.this.lastEvent = MMultiplexer.this.firstEvent;
    }
}
class MMultiplexer {}
class SignDelayer {}
        ]]></code>
    </test-code>
    <test-code>
        <description>#1104 IdempotentOperation false positive (compilable)</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
            class MMultiplexer {
                SignDelayer lastEvent, firstEvent;

                class SignDelayer {
                    int sign;
                    Foo arg;

                    public class Foo {
                        void bar() {
                            SignDelayer.this.sign = SignDelayer.this.arg.sign();
                            MMultiplexer.this.lastEvent = MMultiplexer.this.firstEvent;
                        }
                        int sign() {return 0;}
                    }
                }
            }
            ]]></code>
    </test-code>
</test-data>
