// Copyright © 2013 Esko Luontola <www.orfjackal.net>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package net.orfjackal.retrolambda.test;

import org.junit.Test;

import java.util.concurrent.Callable;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class LambdaTest {

    @Test
    public void lambda_returning_value() throws Exception {
        Callable<String> lambda = () -> "some value";

        assertThat(lambda.call(), is("some value"));
    }

    @Test
    public void lambda_returning_nothing() {
        Runnable lambda = () -> {
        };

        lambda.run();
    }

    private int instanceVar = 0;

    @Test
    public void lambda_using_instance_variables() {
        Runnable lambda = () -> {
            instanceVar = 42;
        };
        lambda.run();

        assertThat(instanceVar, is(42));
    }
}

@@ -956,11 +956,253 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void lambda_using_local_variables() %7B%0A        int%5B%5D localVar = new int%5B1%5D;%0A        Runnable lambda = () -%3E %7B%0A            localVar%5B0%5D = 42;%0A        %7D;%0A        lambda.run();%0A%0A        assertThat(localVar%5B0%5D, is(42));%0A    %7D
 %0A%7D%0A

Test for using local variables