Fix failing tests for precondition checks in java8 classes.
Fixes test regressions introduced in f7c7e5
Change-Id: I0b049247078a21e90e066c135a5689db73f18d1f
diff --git a/user/super/com/google/gwt/emul/java/util/StringJoiner.java b/user/super/com/google/gwt/emul/java/util/StringJoiner.java
index 6f26084..6071c03 100644
--- a/user/super/com/google/gwt/emul/java/util/StringJoiner.java
+++ b/user/super/com/google/gwt/emul/java/util/StringJoiner.java
@@ -15,6 +15,8 @@
*/
package java.util;
+import static javaemul.internal.InternalPreconditions.checkCriticalNotNull;
+
/**
* See <a href="https://docs.oracle.com/javase/8/docs/api/java/util/StringJoiner.html">
* the official Java API doc</a> for details.
@@ -33,6 +35,11 @@
}
public StringJoiner(CharSequence delimiter, CharSequence prefix, CharSequence suffix) {
+ // TODO: null.toString() does not throw exception
+ checkCriticalNotNull(delimiter, "delimiter");
+ checkCriticalNotNull(prefix, "prefix");
+ checkCriticalNotNull(suffix, "suffix");
+
this.delimiter = delimiter.toString();
this.prefix = prefix.toString();
this.suffix = suffix.toString();
@@ -64,6 +71,9 @@
}
public StringJoiner setEmptyValue(CharSequence emptyValue) {
+ // TODO: null.toString() does not throw exception
+ checkCriticalNotNull(emptyValue);
+
this.emptyValue = emptyValue.toString();
return this;
}
diff --git a/user/test/com/google/gwt/emultest/java8/util/PrimitiveIteratorTest.java b/user/test/com/google/gwt/emultest/java8/util/PrimitiveIteratorTest.java
index 0c02cdd2f..8a8e0dc 100644
--- a/user/test/com/google/gwt/emultest/java8/util/PrimitiveIteratorTest.java
+++ b/user/test/com/google/gwt/emultest/java8/util/PrimitiveIteratorTest.java
@@ -15,6 +15,7 @@
*/
package com.google.gwt.emultest.java8.util;
+import com.google.gwt.core.client.JavaScriptException;
import com.google.gwt.junit.client.GWTTestCase;
import java.util.Collections;
@@ -49,15 +50,17 @@
});
try {
+ it = createTestPrimitiveDoubleIterator();
it.forEachRemaining((Consumer<Double>) null);
fail();
- } catch (NullPointerException expected) {
+ } catch (JavaScriptException | NullPointerException expected) {
}
try {
+ it = createTestPrimitiveDoubleIterator();
it.forEachRemaining((DoubleConsumer) null);
fail();
- } catch (NullPointerException expected) {
+ } catch (JavaScriptException | NullPointerException expected) {
}
}
@@ -75,15 +78,17 @@
});
try {
+ it = createTestPrimitiveIntIterator();
it.forEachRemaining((Consumer<Integer>) null);
fail();
- } catch (NullPointerException expected) {
+ } catch (JavaScriptException | NullPointerException expected) {
}
try {
+ it = createTestPrimitiveIntIterator();
it.forEachRemaining((IntConsumer) null);
fail();
- } catch (NullPointerException expected) {
+ } catch (JavaScriptException | NullPointerException expected) {
}
}
@@ -101,15 +106,17 @@
});
try {
+ it = createTestPrimitiveLongIterator();
it.forEachRemaining((Consumer<Long>) null);
fail();
- } catch (NullPointerException expected) {
+ } catch (JavaScriptException | NullPointerException expected) {
}
try {
+ it = createTestPrimitiveLongIterator();
it.forEachRemaining((LongConsumer) null);
fail();
- } catch (NullPointerException expected) {
+ } catch (JavaScriptException | NullPointerException expected) {
}
}