Backport Optional/OptionalInt/OptionalLong/OptionalDouble.isEmpty()
Test: tools/test.py --dex_vm all --no-internal -v *Backport*Test*
Test: tools/test.py --no-internal -v *GenerateBackportMethods*
Change-Id: I2c575b9ab62f5817a513ec9e9a15c1a2aac9c91a
diff --git a/src/test/examplesJava11/backport/OptionalIntBackportJava11Main.java b/src/test/examplesJava11/backport/OptionalIntBackportJava11Main.java
new file mode 100644
index 0000000..9d1a09a
--- /dev/null
+++ b/src/test/examplesJava11/backport/OptionalIntBackportJava11Main.java
@@ -0,0 +1,34 @@
+// 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.OptionalInt;
+
+public final class OptionalIntBackportJava11Main {
+
+ public static void main(String[] args) {
+ testIsEmpty();
+ }
+
+ private static void testIsEmpty() {
+ OptionalInt present = OptionalInt.of(2);
+ assertFalse(present.isEmpty());
+
+ OptionalInt absent = OptionalInt.empty();
+ assertTrue(absent.isEmpty());
+ }
+
+ private static void assertTrue(boolean value) {
+ if (!value) {
+ throw new AssertionError("Expected <true> but was <false>");
+ }
+ }
+
+ private static void assertFalse(boolean value) {
+ if (value) {
+ throw new AssertionError("Expected <false> but was <true>");
+ }
+ }
+}