Backport OptionalInt/OptionalLong/OptionalDouble.stream()
Test: tools/test.py --dex_vm all --no-internal -v *Backport*Test*
Test: tools/test.py --no-internal -v *GenerateBackportMethods*
Change-Id: I85714b4ce8fc06c9c2656cf82532ea6803d09ce1
diff --git a/src/test/examplesJava9/backport/OptionalLongBackportJava9Main.java b/src/test/examplesJava9/backport/OptionalLongBackportJava9Main.java
new file mode 100644
index 0000000..07438e1
--- /dev/null
+++ b/src/test/examplesJava9/backport/OptionalLongBackportJava9Main.java
@@ -0,0 +1,35 @@
+// Copyright (c) 2019, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package backport;
+
+import java.util.OptionalLong;
+
+public final class OptionalLongBackportJava9Main {
+
+ public static void main(String[] args) {
+ testIfPresentOrElseLong();
+ testStreamLong();
+ }
+
+ private static void testIfPresentOrElseLong() {
+ OptionalLong value = OptionalLong.of(1L);
+ OptionalLong emptyValue = OptionalLong.empty();
+ value.ifPresentOrElse(val -> {}, () -> assertTrue(false));
+ emptyValue.ifPresentOrElse(val -> assertTrue(false), () -> {});
+ }
+
+ private static void testStreamLong() {
+ OptionalLong value = OptionalLong.of(2L);
+ OptionalLong emptyValue = OptionalLong.empty();
+ assertTrue(value.stream().count() == 1);
+ assertTrue(emptyValue.stream().count() == 0);
+ }
+
+ private static void assertTrue(boolean value) {
+ if (!value) {
+ throw new AssertionError("Expected <true> but was <false>");
+ }
+ }
+}