diff options
| author | 2015-01-26 16:08:22 +0000 | |
|---|---|---|
| committer | 2015-01-26 16:08:23 +0000 | |
| commit | bbacb3db1f453a51453efc17779bf421883d4dba (patch) | |
| tree | b017034f8f0aec7a13551c107d79ab7cbbf879d9 /test/082-inline-execute/src/Main.java | |
| parent | 60430803a7964b68269e42f04acadb070b25c58c (diff) | |
| parent | 00ca84730a21578dcc6b47bd8e08b78ab9b2dded (diff) | |
Merge "Quick: Fix range check for intrinsic String.charAt() on x86."
Diffstat (limited to 'test/082-inline-execute/src/Main.java')
| -rw-r--r-- | test/082-inline-execute/src/Main.java | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/test/082-inline-execute/src/Main.java b/test/082-inline-execute/src/Main.java index a737ccdb79..5561a09c88 100644 --- a/test/082-inline-execute/src/Main.java +++ b/test/082-inline-execute/src/Main.java @@ -130,7 +130,11 @@ public class Main { Assert.assertEquals('N', testStr.charAt(0)); Assert.assertEquals('o', testStr.charAt(1)); Assert.assertEquals(' ', testStr.charAt(10)); - Assert.assertEquals('e', testStr.charAt(testStr.length()-1)); + Assert.assertEquals('e', testStr.charAt(14)); // 14 = testStr.length()-1 as a constant. + Assert.assertEquals('N', test_String_charAt_inner(testStr, 0)); + Assert.assertEquals('o', test_String_charAt_inner(testStr, 1)); + Assert.assertEquals(' ', test_String_charAt_inner(testStr, 10)); + Assert.assertEquals('e', test_String_charAt_inner(testStr, testStr.length()-1)); test_String_charAtExc(); test_String_charAtExc2(); @@ -148,6 +152,33 @@ public class Main { Assert.fail(); } catch (StringIndexOutOfBoundsException expected) { } + try { + testStr.charAt(15); // 15 = "Now is the time".length() + Assert.fail(); + } catch (StringIndexOutOfBoundsException expected) { + } + try { + test_String_charAt_inner(testStr, -1); + Assert.fail(); + } catch (StringIndexOutOfBoundsException expected) { + } + try { + test_String_charAt_inner(testStr, 80); + Assert.fail(); + } catch (StringIndexOutOfBoundsException expected) { + } + try { + test_String_charAt_inner(testStr, 15); // 15 = "Now is the time".length() + Assert.fail(); + } catch (StringIndexOutOfBoundsException expected) { + } + + String strEmpty = ""; + try { + strEmpty.charAt(0); + Assert.fail(); + } catch (StringIndexOutOfBoundsException expected) { + } String strNull = null; try { @@ -157,6 +188,11 @@ public class Main { } } + private static char test_String_charAt_inner(String s, int index) { + // Using non-constant index here (assuming that this method wasn't inlined). + return s.charAt(index); + } + private static void test_String_charAtExc2() { try { test_String_charAtExc3(); |