OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 10 matching lines...) Expand all Loading... |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 /** | 28 /** |
29 * @fileoverview Check all sorts of borderline cases for charCodeAt. | 29 * @fileoverview Check all sorts of borderline cases for charCodeAt. |
30 */ | 30 */ |
31 | |
32 function Cons() { | 31 function Cons() { |
33 return "Te" + "st testing 123"; | 32 return "Te" + "st testing 123"; |
34 } | 33 } |
35 | 34 |
36 | 35 |
37 function Deep() { | 36 function Deep() { |
38 var a = "T"; | 37 var a = "T"; |
39 a += "e"; | 38 a += "e"; |
40 a += "s"; | 39 a += "s"; |
41 a += "ting testing 123"; | 40 a += "ting testing 123"; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 197 |
199 assertTrue(isNaN(medium.charCodeAt(-1)), 31); | 198 assertTrue(isNaN(medium.charCodeAt(-1)), 31); |
200 assertEquals(49, medium.charCodeAt(0), 32); | 199 assertEquals(49, medium.charCodeAt(0), 32); |
201 assertEquals(56, medium.charCodeAt(255), 33); | 200 assertEquals(56, medium.charCodeAt(255), 33); |
202 assertTrue(isNaN(medium.charCodeAt(256)), 34); | 201 assertTrue(isNaN(medium.charCodeAt(256)), 34); |
203 | 202 |
204 assertTrue(isNaN(long.charCodeAt(-1)), 35); | 203 assertTrue(isNaN(long.charCodeAt(-1)), 35); |
205 assertEquals(49, long.charCodeAt(0), 36); | 204 assertEquals(49, long.charCodeAt(0), 36); |
206 assertEquals(56, long.charCodeAt(65535), 37); | 205 assertEquals(56, long.charCodeAt(65535), 37); |
207 assertTrue(isNaN(long.charCodeAt(65536)), 38); | 206 assertTrue(isNaN(long.charCodeAt(65536)), 38); |
| 207 |
| 208 |
| 209 // Test crankshaft code when the function is set directly on the |
| 210 // string prototype object instead of the hidden prototype object. |
| 211 // See http://code.google.com/p/v8/issues/detail?id=1070 |
| 212 |
| 213 String.prototype.x = String.prototype.charCodeAt; |
| 214 |
| 215 function directlyOnPrototype() { |
| 216 assertEquals(97, "a".x(0)); |
| 217 assertEquals(98, "b".x(0)); |
| 218 assertEquals(99, "c".x(0)); |
| 219 } |
| 220 |
| 221 for (var i = 0; i < 10000; i++) { |
| 222 directlyOnPrototype(); |
| 223 } |
OLD | NEW |