<?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>ok, calls super.clone</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void clone() {
        super.clone();
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>bad, Foo.clone() calls new Foo();</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>2</expected-linenumbers>
        <code><![CDATA[
public class Foo {
    void clone() {
        Foo f = new Foo();
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>clone([whatever]) is fine</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void clone(String fiddle) {
        Foo f = new Foo();
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>bad, Foo.clone() calls new Foo();</description>
        <expected-problems>1</expected-problems>
        <expected-linenumbers>3</expected-linenumbers>
        <code><![CDATA[
public class Bar {
    class Foo {
        void clone() {
            Foo f = new Foo();
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>ok, should not throw NullPointerException while processing primitive array allocation</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    void clone() {
        super.clone();
        byte[] array = new byte[6];
    }
}
        ]]></code>
    </test-code>
    
    <test-code>
        <description>ok, final class false-positive</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
final class Foo {
    Foo clone() {
        return new Foo();
    }
}
        ]]></code>
    </test-code>
</test-data>
