Fixes null captured parameters
[jpf-core.git] / src / tests / java8 / LambdaTest.java
index b6ec69533c166181b2dd41333ea86787e09a9983..910876db8effa8b5da95df91172e5d41e2e35c88 100644 (file)
@@ -19,6 +19,8 @@ package java8;
 
 import gov.nasa.jpf.util.test.TestJPF;
 
+import java.util.function.Supplier;
+
 import org.junit.Test;
 
 /**
@@ -294,4 +296,16 @@ public class LambdaTest extends TestJPF{
       assertSame(fi1,fi2);
     }
   }
+  
+  @Test
+  public void testNullCaptureValues() {
+    if(verifyNoPropertyViolation()) {
+      Supplier<String> provider = getStringProvider(null);
+      assertEquals(provider.get(), "It was null");
+    }
+  }
+
+  private Supplier<String> getStringProvider(String object) {
+    return () -> object == null ? "It was null" : object;
+  }
 }