| 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 assertEquals("", ascii.substring(16) + utf.substring(16)); | 170 assertEquals("", ascii.substring(16) + utf.substring(16)); |
| 171 assertEquals("bcdef\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9", | 171 assertEquals("bcdef\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9", |
| 172 ascii.substring(1,6) + utf.substring(3,9)); | 172 ascii.substring(1,6) + utf.substring(3,9)); |
| 173 assertEquals("\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9abcdefghijklmnop", | 173 assertEquals("\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9abcdefghijklmnop", |
| 174 utf.substring(3,9) + ascii); | 174 utf.substring(3,9) + ascii); |
| 175 assertEquals("\u03B2\u03B3\u03B4\u03B5\u03B4\u03B5\u03B6\u03B7", | 175 assertEquals("\u03B2\u03B3\u03B4\u03B5\u03B4\u03B5\u03B6\u03B7", |
| 176 utf.substring(5,1) + utf.substring(3,7)); | 176 utf.substring(5,1) + utf.substring(3,7)); |
| 177 | 177 |
| 178 // Externalizing strings. | 178 // Externalizing strings. |
| 179 var a = "123456789" + "qwertyuiopasdfghjklzxcvbnm"; | 179 var a = "123456789" + "qwertyuiopasdfghjklzxcvbnm"; |
| 180 var b = "23456789qwertyuiopasdfghjklzxcvbn" | 180 var b = "23456789qwertyuiopasdfghjklzxcvbn"; |
| 181 assertEquals(a.slice(1,-1), b); | 181 assertEquals(a.slice(1,-1), b); |
| 182 | 182 |
| 183 assertTrue(isAsciiString(a)); | 183 assertTrue(isAsciiString(a)); |
| 184 externalizeString(a, true); | 184 externalizeString(a, true); |
| 185 assertFalse(isAsciiString(a)); | 185 assertFalse(isAsciiString(a)); |
| 186 | 186 |
| 187 assertEquals(a.slice(1,-1), b); | 187 assertEquals(a.slice(1,-1), b); |
| 188 assertTrue(/3456789qwe/.test(a)); | 188 assertTrue(/3456789qwe/.test(a)); |
| 189 assertEquals(5, a.indexOf("678")); | 189 assertEquals(5, a.indexOf("678")); |
| 190 assertEquals("12345", a.split("6")[0]); | 190 assertEquals("12345", a.split("6")[0]); |
| 191 | 191 |
| 192 // Create a slice with an external string as parent string. | 192 // Create a slice with an external string as parent string. |
| 193 var c = a.slice(1,-1); | 193 var c = a.slice(1,-1); |
| 194 | 194 |
| 195 function test_crankshaft() { | 195 function test_crankshaft() { |
| 196 for (var i = 0; i < 20; i++) { | 196 for (var i = 0; i < 20; i++) { |
| 197 assertEquals(b.charAt(i), a.charAt(i + 1)); | 197 assertEquals(b.charAt(i), a.charAt(i + 1)); |
| 198 assertEquals(b.charAt(i), c.charAt(i)); | 198 assertEquals(b.charAt(i), c.charAt(i)); |
| 199 assertEquals(b.charAt(4), c.charAt(4)); | 199 assertEquals(b.charAt(4), c.charAt(4)); |
| 200 assertTrue(/3456789qwe/.test(c)); | 200 assertTrue(/3456789qwe/.test(c)); |
| 201 assertEquals(4, c.indexOf("678")); | 201 assertEquals(4, c.indexOf("678")); |
| 202 assertEquals("2345", c.split("6")[0]); | 202 assertEquals("2345", c.split("6")[0]); |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 test_crankshaft(); | 206 test_crankshaft(); |
| 207 %OptimizeFunctionOnNextCall(test_crankshaft); | 207 %OptimizeFunctionOnNextCall(test_crankshaft); |
| 208 test_crankshaft(); | 208 test_crankshaft(); |
| OLD | NEW |