| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 var n = new Thing(); | 104 var n = new Thing(); |
| 105 n.toString = function() { return "Te\u1234t"; }; | 105 n.toString = function() { return "Te\u1234t"; }; |
| 106 n.charCodeAt = String.prototype.charCodeAt; | 106 n.charCodeAt = String.prototype.charCodeAt; |
| 107 return n; | 107 return n; |
| 108 } | 108 } |
| 109 | 109 |
| 110 | 110 |
| 111 function TestStringType(generator, sixteen) { | 111 function TestStringType(generator, sixteen) { |
| 112 var g = generator; | 112 var g = generator; |
| 113 var len = g().toString().length; | 113 var len = g().toString().length; |
| 114 var t = sixteen ? "t" : "f" | 114 var t = sixteen ? "t" : "f"; |
| 115 t += generator.name; | 115 t += generator.name; |
| 116 assertTrue(isNaN(g().charCodeAt(-1e19)), 1 + t); | 116 assertTrue(isNaN(g().charCodeAt(-1e19)), 1 + t); |
| 117 assertTrue(isNaN(g().charCodeAt(-0x80000001)), 2 + t); | 117 assertTrue(isNaN(g().charCodeAt(-0x80000001)), 2 + t); |
| 118 assertTrue(isNaN(g().charCodeAt(-0x80000000)), 3 + t); | 118 assertTrue(isNaN(g().charCodeAt(-0x80000000)), 3 + t); |
| 119 assertTrue(isNaN(g().charCodeAt(-0x40000000)), 4 + t); | 119 assertTrue(isNaN(g().charCodeAt(-0x40000000)), 4 + t); |
| 120 assertTrue(isNaN(g().charCodeAt(-1)), 5 + t); | 120 assertTrue(isNaN(g().charCodeAt(-1)), 5 + t); |
| 121 assertTrue(isNaN(g().charCodeAt(len)), 6 + t); | 121 assertTrue(isNaN(g().charCodeAt(len)), 6 + t); |
| 122 assertTrue(isNaN(g().charCodeAt(len + 1)), 7 + t); | 122 assertTrue(isNaN(g().charCodeAt(len + 1)), 7 + t); |
| 123 assertTrue(isNaN(g().charCodeAt(0x3fffffff)), 8 + t); | 123 assertTrue(isNaN(g().charCodeAt(0x3fffffff)), 8 + t); |
| 124 assertTrue(isNaN(g().charCodeAt(0x7fffffff)), 9 + t); | 124 assertTrue(isNaN(g().charCodeAt(0x7fffffff)), 9 + t); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 ConsNotSmiIndex(); | 168 ConsNotSmiIndex(); |
| 169 | 169 |
| 170 | 170 |
| 171 for (var i = 0; i != 10; i++) { | 171 for (var i = 0; i != 10; i++) { |
| 172 assertEquals(101, Cons16().charCodeAt(1.1)); | 172 assertEquals(101, Cons16().charCodeAt(1.1)); |
| 173 assertEquals('e', Cons16().charAt(1.1)); | 173 assertEquals('e', Cons16().charAt(1.1)); |
| 174 } | 174 } |
| 175 | 175 |
| 176 function StupidThing() { | 176 function StupidThing() { |
| 177 // Doesn't return a string from toString! | 177 // Doesn't return a string from toString! |
| 178 this.toString = function() { return 42; } | 178 this.toString = function() { return 42; }; |
| 179 this.charCodeAt = String.prototype.charCodeAt; | 179 this.charCodeAt = String.prototype.charCodeAt; |
| 180 } | 180 } |
| 181 | 181 |
| 182 assertEquals(52, new StupidThing().charCodeAt(0), 27); | 182 assertEquals(52, new StupidThing().charCodeAt(0), 27); |
| 183 assertEquals(50, new StupidThing().charCodeAt(1), 28); | 183 assertEquals(50, new StupidThing().charCodeAt(1), 28); |
| 184 assertTrue(isNaN(new StupidThing().charCodeAt(2)), 29); | 184 assertTrue(isNaN(new StupidThing().charCodeAt(2)), 29); |
| 185 assertTrue(isNaN(new StupidThing().charCodeAt(-1)), 30); | 185 assertTrue(isNaN(new StupidThing().charCodeAt(-1)), 30); |
| 186 | 186 |
| 187 | 187 |
| 188 // Medium (>255) and long (>65535) strings. | 188 // Medium (>255) and long (>65535) strings. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 assertEquals(97, "a".x(0)); | 224 assertEquals(97, "a".x(0)); |
| 225 assertEquals(98, "b".x(0)); | 225 assertEquals(98, "b".x(0)); |
| 226 assertEquals(99, "c".x(0)); | 226 assertEquals(99, "c".x(0)); |
| 227 } | 227 } |
| 228 | 228 |
| 229 for (var i = 0; i < 5; i++) { | 229 for (var i = 0; i < 5; i++) { |
| 230 directlyOnPrototype(); | 230 directlyOnPrototype(); |
| 231 } | 231 } |
| 232 %OptimizeFunctionOnNextCall(directlyOnPrototype); | 232 %OptimizeFunctionOnNextCall(directlyOnPrototype); |
| 233 directlyOnPrototype(); | 233 directlyOnPrototype(); |
| OLD | NEW |