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 seq = "123456789qwertyuiopasdfghjklzxcvbnm"; | 193 var a = "123456789" + "qwertyuiopasdfghjklzxcvbnm"; |
194 cons = "123456789" + "qwertyuiopasdfghjklzxcvbnm"; | 194 var b = "23456789qwertyuiopasdfghjklzxcvbn" |
195 check = "23456789qwertyuiopasdfghjklzxcvbn"; | 195 assertEquals(a.slice(1,-1), b); |
196 | 196 |
197 // Externalizing a sequential string changes its encoding from ascii to | 197 assertTrue(isAsciiString(a)); |
198 // two-byte. The encoding of the sliced string must reflect this change too. | 198 externalizeString(a, true); |
199 slice = seq.slice(1,-1); | 199 assertFalse(isAsciiString(a)); |
200 assertEquals(check, slice); | |
201 | 200 |
202 // Seq strings can only be externalized once across multiple stress-opt runs. | 201 assertEquals(a.slice(1,-1), b); |
203 if (isAsciiString(seq)) externalizeString(seq, true); | 202 assertTrue(/3456789qwe/.test(a)); |
204 assertFalse(isAsciiString(seq)); | 203 assertEquals(5, a.indexOf("678")); |
205 assertFalse(isAsciiString(slice)); | 204 assertEquals("12345", a.split("6")[0]); |
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 |