Skip to content

Commit

Permalink
Enable "Emul" J2cl JRE tests for J2kt
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 585928911
  • Loading branch information
stefanhaustein authored and copybara-github committed Nov 28, 2023
1 parent 11160d1 commit 01f73b6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
14 changes: 13 additions & 1 deletion jre/javatests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,21 @@ j2kt_native_library(
srcs = [
"com/google/j2cl/jre/BigDecimalSuite.java",
"com/google/j2cl/jre/BigIntegerSuite.java",
"com/google/j2cl/jre/EmulSuite.java",
"com/google/j2cl/jre/java/util/ComparatorTest.java",
"com/google/j2cl/jre/java/util/EmulTestBase.java",
"com/google/j2cl/jre/java/util/ObjectsTest.java",
"com/google/j2cl/jre/java/util/RandomTest.java",
"com/google/j2cl/jre/java/util/TestComparator.java",
"com/google/j2cl/jre/java/util/TestObject.java",
"com/google/j2cl/jre/testing/J2ktIncompatible.java",
"com/google/j2cl/jre/testing/TestUtils.java",
] + glob(["com/google/j2cl/jre/java/math/Big*.java"]),
] + glob([
"com/google/j2cl/jre/java/io/*.java",
"com/google/j2cl/jre/java/math/*.java",
"com/google/j2cl/jre/java/nio/charset/*.java",
"com/google/j2cl/jre/java/security/*.java",
]),
deps = [
"//jre/java:javaemul_internal_annotations-j2kt-native",
"//third_party:junit-j2kt-native",
Expand Down Expand Up @@ -118,6 +129,7 @@ j2cl_multi_test(

j2cl_multi_test(
name = "Emul",
enable_kt_native = True,
shard_count = 8,
test_class = "com.google.j2cl.jre.EmulSuite",
deps = [":emul_tests_lib"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.j2cl.jre.java.io;

import com.google.j2cl.jre.testing.J2ktIncompatible;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;
Expand All @@ -39,6 +40,7 @@ public abstract class OutputStreamBaseTest extends TestCase {
*/
protected abstract byte[] getBytesWritten();

@J2ktIncompatible // Not nullable according to jspecify.
public void testWriteArrayUsingNullArrayObject() throws IOException {
final OutputStream outputStream = createDefaultOutputStream();
try {
Expand Down Expand Up @@ -111,6 +113,7 @@ public void testWriteArrayMiddleBytesOnly() throws IOException {
assertTrue(Arrays.equals(expected, getBytesWritten()));
}

@J2ktIncompatible // Not nullable according to Jspecify
public void testWriteArrayUsingNullArrayObjectAndNoOffset() throws IOException {
final OutputStream outputStream = createDefaultOutputStream();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.j2cl.jre.java.math;

import com.google.j2cl.jre.java.util.EmulTestBase;
import com.google.j2cl.jre.testing.J2ktIncompatible;
import java.math.MathContext;
import java.math.RoundingMode;

Expand Down Expand Up @@ -99,7 +100,10 @@ public void testMathContextSingleArgConstructor() {
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}

}

@J2ktIncompatible // Not nullable according to Jspecify
public void testMathContextSingleArgConstructorNull() {
try {
new MathContext(null);
fail("Expected NullPointerException");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.google.j2cl.jre.java.nio.charset;

import com.google.j2cl.jre.java.util.EmulTestBase;
import com.google.j2cl.jre.testing.J2ktIncompatible;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
Expand All @@ -36,6 +37,7 @@ public void testUtf8() {
assertEquals("UTF-8", Charset.forName("utf-8").name());
}

@J2ktIncompatible // Not nullable according to Jspecify
public void testForName_null() {
try {
Charset.forName(null);
Expand Down

0 comments on commit 01f73b6

Please sign in to comment.