OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 assertEquals("\u03B1\u03B4\u03B5", utf.substring(0,1) + utf.substring(5,3)); | 183 assertEquals("\u03B1\u03B4\u03B5", utf.substring(0,1) + utf.substring(5,3)); |
184 assertEquals("", ascii.substring(16) + utf.substring(16)); | 184 assertEquals("", ascii.substring(16) + utf.substring(16)); |
185 assertEquals("bcdef\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9", | 185 assertEquals("bcdef\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9", |
186 ascii.substring(1,6) + utf.substring(3,9)); | 186 ascii.substring(1,6) + utf.substring(3,9)); |
187 assertEquals("\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9abcdefghijklmnop", | 187 assertEquals("\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9abcdefghijklmnop", |
188 utf.substring(3,9) + ascii); | 188 utf.substring(3,9) + ascii); |
189 assertEquals("\u03B2\u03B3\u03B4\u03B5\u03B4\u03B5\u03B6\u03B7", | 189 assertEquals("\u03B2\u03B3\u03B4\u03B5\u03B4\u03B5\u03B6\u03B7", |
190 utf.substring(5,1) + utf.substring(3,7)); | 190 utf.substring(5,1) + utf.substring(3,7)); |
191 | 191 |
192 // Externalizing strings. | 192 // Externalizing strings. |
193 var a = "123456789" + "qwertyuiopasdfghjklzxcvbnm"; | 193 seq = "123456789qwertyuiopasdfghjklzxcvbnm"; |
194 var b = "23456789qwertyuiopasdfghjklzxcvbn" | 194 cons = "123456789" + "qwertyuiopasdfghjklzxcvbnm"; |
195 assertEquals(a.slice(1,-1), b); | 195 check = "23456789qwertyuiopasdfghjklzxcvbn"; |
196 | 196 |
197 assertTrue(isAsciiString(a)); | 197 // Externalizing a sequential string changes its encoding from ascii to |
198 externalizeString(a, true); | 198 // two-byte. The encoding of the sliced string must reflect this change too. |
199 assertFalse(isAsciiString(a)); | 199 slice = seq.slice(1,-1); |
| 200 assertEquals(check, slice); |
200 | 201 |
201 assertEquals(a.slice(1,-1), b); | 202 // Seq strings can only be externalized once across multiple stress-opt runs. |
202 assertTrue(/3456789qwe/.test(a)); | 203 if (isAsciiString(seq)) externalizeString(seq, true); |
203 assertEquals(5, a.indexOf("678")); | 204 assertFalse(isAsciiString(seq)); |
204 assertEquals("12345", a.split("6")[0]); | 205 assertFalse(isAsciiString(slice)); |
| 206 |
| 207 assertEquals(check, seq.slice(1,-1)); |
| 208 assertEquals(check, slice); |
| 209 assertTrue(/3456789qwe/.test(seq)); |
| 210 assertEquals(5, seq.indexOf("678")); |
| 211 assertEquals("12345", seq.split("6")[0]); |
| 212 |
| 213 // Externalizing a cons string changes its encoding from ascii to two-byte, |
| 214 // but the slice depending on the cons string does not, as it still points to |
| 215 // the original cons string. |
| 216 slice = cons.slice(1,-1); |
| 217 assertEquals(check, slice); |
| 218 |
| 219 assertTrue(isAsciiString(cons)); |
| 220 externalizeString(cons, true); |
| 221 assertFalse(isAsciiString(cons)); |
| 222 assertTrue(isAsciiString(slice)); |
OLD | NEW |