File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
user/test-super/com/google/gwt/emultest/super/com/google/gwt/emultest/java17/lang Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 2020/**
2121 * Tests for java.lang.String Java 12 API emulation.
2222 */
23- public class StringTest extends EmulTestBase {
23+ public class MathTest extends EmulTestBase {
2424
2525 public void testAbsExact () {
2626 assertEquals (Integer .MAX_VALUE , Math .absExact (hideFromCompiler (Integer .MAX_VALUE )));
@@ -43,4 +43,21 @@ public void testAbsExactWithFolding() {
4343 assertEquals (1 , Math .absExact (-1L ));
4444 assertThrowsArithmetic (() -> Math .absExact (Long .MIN_VALUE ));
4545 }
46+
47+ private <T > T hideFromCompiler (T value ) {
48+ if (Math .random () < -1 ) {
49+ // Can never happen, but fools the compiler enough not to optimize this call.
50+ fail ();
51+ }
52+ return value ;
53+ }
54+
55+ private void assertThrowsArithmetic (Runnable check ) {
56+ try {
57+ check .run ();
58+ fail ("Should have failed" );
59+ } catch (ArithmeticException ex ) {
60+ // good
61+ }
62+ }
4663}
You can’t perform that action at this time.
0 commit comments