| 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 var s = "test"; | 28 var s = "test"; |
| 29 | 29 |
| 30 function getTwoByteString() { return "\u1234t"; } | 30 function getTwoByteString() { return "\u1234t"; } |
| 31 function getCons() { return "testtesttesttest" + getTwoByteString() } | 31 function getCons() { return "testtesttesttest" + getTwoByteString(); } |
| 32 | 32 |
| 33 var slowIndex1 = { valueOf: function() { return 1; } }; | 33 var slowIndex1 = { valueOf: function() { return 1; } }; |
| 34 var slowIndex2 = { toString: function() { return "2"; } }; | 34 var slowIndex2 = { toString: function() { return "2"; } }; |
| 35 var slowIndexOutOfRange = { valueOf: function() { return -1; } }; | 35 var slowIndexOutOfRange = { valueOf: function() { return -1; } }; |
| 36 | 36 |
| 37 function basicTest(s, len) { | 37 function basicTest(s, len) { |
| 38 assertEquals("t", s().charAt()); | 38 assertEquals("t", s().charAt()); |
| 39 assertEquals("t", s().charAt("string")); | 39 assertEquals("t", s().charAt("string")); |
| 40 assertEquals("t", s().charAt(null)); | 40 assertEquals("t", s().charAt(null)); |
| 41 assertEquals("t", s().charAt(void 0)); | 41 assertEquals("t", s().charAt(void 0)); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 oldResult = result; | 246 oldResult = result; |
| 247 String.prototype.charCodeAt = function() { return 42; }; | 247 String.prototype.charCodeAt = function() { return 42; }; |
| 248 } | 248 } |
| 249 result = s.charCodeAt(1); | 249 result = s.charCodeAt(1); |
| 250 } | 250 } |
| 251 assertEquals(42, result); | 251 assertEquals(42, result); |
| 252 assertEquals(101, oldResult); | 252 assertEquals(101, oldResult); |
| 253 delete String.prototype.charCodeAt; // Restore the default. | 253 delete String.prototype.charCodeAt; // Restore the default. |
| 254 } | 254 } |
| 255 testPrototypeChange_charCodeAt(); | 255 testPrototypeChange_charCodeAt(); |
| OLD | NEW |