| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 assertEquals('A', charat_str[i].charAt(3*16 + 10)); | 52 assertEquals('A', charat_str[i].charAt(3*16 + 10)); |
| 53 assertEquals('B', charat_str[i].charAt(3*16 + 11)); | 53 assertEquals('B', charat_str[i].charAt(3*16 + 11)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 charat_short = "012"; | 56 charat_short = "012"; |
| 57 try { // String can only be externalized once | 57 try { // String can only be externalized once |
| 58 externalizeString(charat_short, true); | 58 externalizeString(charat_short, true); |
| 59 } catch (ex) { } | 59 } catch (ex) { } |
| 60 assertEquals("1", charat_short.charAt(1)); | 60 assertEquals("1", charat_short.charAt(1)); |
| 61 | 61 |
| 62 // Test regexp. | 62 // Test regexp and short substring. |
| 63 var re = /(A|B)/; | 63 var re = /(A|B)/; |
| 64 var rere = /(T.{1,2}B)/; | 64 var rere = /(T.{1,2}B)/; |
| 65 var ascii = "ABCDEFGHIJKLMNOPQRST"; | 65 var ascii = "ABCDEFGHIJKLMNOPQRST"; |
| 66 var twobyte = "_ABCDEFGHIJKLMNOPQRST"; | 66 var twobyte = "_ABCDEFGHIJKLMNOPQRST"; |
| 67 try { | 67 try { |
| 68 externalizeString(ascii, false); | 68 externalizeString(ascii, false); |
| 69 externalizeString(twobyte, true); | 69 externalizeString(twobyte, true); |
| 70 } catch (ex) { } | 70 } catch (ex) { } |
| 71 assertTrue(isAsciiString(ascii)); | 71 assertTrue(isAsciiString(ascii)); |
| 72 assertFalse(isAsciiString(twobyte)); | 72 assertFalse(isAsciiString(twobyte)); |
| 73 var ascii_slice = ascii.slice(1,-1); | 73 var ascii_slice = ascii.slice(1,-1); |
| 74 var twobyte_slice = twobyte.slice(2,-1); | 74 var twobyte_slice = twobyte.slice(2,-1); |
| 75 var ascii_cons = ascii + ascii; | 75 var ascii_cons = ascii + ascii; |
| 76 var twobyte_cons = twobyte + twobyte; | 76 var twobyte_cons = twobyte + twobyte; |
| 77 for (var i = 0; i < 2; i++) { | 77 for (var i = 0; i < 2; i++) { |
| 78 assertEquals(["A", "A"], re.exec(ascii)); | 78 assertEquals(["A", "A"], re.exec(ascii)); |
| 79 assertEquals(["B", "B"], re.exec(ascii_slice)); | 79 assertEquals(["B", "B"], re.exec(ascii_slice)); |
| 80 assertEquals(["TAB", "TAB"], rere.exec(ascii_cons)); | 80 assertEquals(["TAB", "TAB"], rere.exec(ascii_cons)); |
| 81 assertEquals(["A", "A"], re.exec(twobyte)); | 81 assertEquals(["A", "A"], re.exec(twobyte)); |
| 82 assertEquals(["B", "B"], re.exec(twobyte_slice)); | 82 assertEquals(["B", "B"], re.exec(twobyte_slice)); |
| 83 assertEquals(["T_AB", "T_AB"], rere.exec(twobyte_cons)); | 83 assertEquals(["T_AB", "T_AB"], rere.exec(twobyte_cons)); |
| 84 assertEquals("DEFG", ascii_slice.substr(2, 4)); |
| 85 assertEquals("DEFG", twobyte_slice.substr(2, 4)); |
| 86 assertEquals("DEFG", ascii_cons.substr(3, 4)); |
| 87 assertEquals("DEFG", twobyte_cons.substr(4, 4)); |
| 84 } | 88 } |
| 85 } | 89 } |
| 86 | 90 |
| 87 // Run the test many times to ensure IC-s don't break things. | 91 // Run the test many times to ensure IC-s don't break things. |
| 88 for (var i = 0; i < 10; i++) { | 92 for (var i = 0; i < 10; i++) { |
| 89 test(); | 93 test(); |
| 90 } | 94 } |
| 91 | 95 |
| 92 // Clean up string to make Valgrind happy. | 96 // Clean up string to make Valgrind happy. |
| 93 gc(); | 97 gc(); |
| 94 gc(); | 98 gc(); |
| OLD | NEW |