<?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>two returns</description>
        <expected-problems>1</expected-problems>
        <code><![CDATA[
public class Foo {
    public int foo(int x) {
        if (x > 0) {
            return 3;
        }
        return 2;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>one</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public int foo(int x) {
        return 2;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>none</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public void foo(int x) {
        int y =2;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>void</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public void foo(int x) {
        if (x>2) {
            return;
        }
        int y =2;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>finally</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    public int foo(int x) {
        try {
            x += 2;
            return x;
        } finally {
            int y;
        }
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>return inside anonymous inner class</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    interface Filter { boolean accept(Object o); }
    public int foo() {
        Filter f = new Filter() {
            public boolean accept(Object o) {
                return false;
            }
        };
        return 2;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>#1353 return inside lambda</description>
        <expected-problems>0</expected-problems>
        <code><![CDATA[
public class Foo {
    interface Filter { boolean accept(Object o); }
    public int foo() {
        Filter f = o -> {
            return false;
        };
        return 2;
    }
}
        ]]></code>
    </test-code>

    <test-code>
        <description>False negative with anonymous class #3274</description>
        <expected-problems>2</expected-problems>
        <expected-linenumbers>6,7</expected-linenumbers>
        <code><![CDATA[
public class OnlyOneReturn {
    void foo() {
        Object o = new Object() {
            void method(int i) {
                switch (i) {
                    case 1: return;
                    case 2: return;
                }
                return;
            }
        };
    }
}
        ]]></code>
    </test-code>
</test-data>
