| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 TestStringType(Flat, false); | 146 TestStringType(Flat, false); |
| 147 TestStringType(NotAString, false); | 147 TestStringType(NotAString, false); |
| 148 TestStringType(Cons16, true); | 148 TestStringType(Cons16, true); |
| 149 TestStringType(Deep16, true); | 149 TestStringType(Deep16, true); |
| 150 TestStringType(Slice16Beginning, true); | 150 TestStringType(Slice16Beginning, true); |
| 151 TestStringType(Slice16Middle, true); | 151 TestStringType(Slice16Middle, true); |
| 152 TestStringType(Slice16End, true); | 152 TestStringType(Slice16End, true); |
| 153 TestStringType(Flat16, true); | 153 TestStringType(Flat16, true); |
| 154 TestStringType(NotAString16, true); | 154 TestStringType(NotAString16, true); |
| 155 | 155 |
| 156 |
| 157 function ConsNotSmiIndex() { |
| 158 var str = Cons(); |
| 159 assertTrue(isNaN(str.charCodeAt(0x7fffffff))); |
| 160 } |
| 161 |
| 162 for (var i = 0; i < 100000; i++) { |
| 163 ConsNotSmiIndex(); |
| 164 } |
| 165 |
| 166 |
| 156 for (var i = 0; i != 10; i++) { | 167 for (var i = 0; i != 10; i++) { |
| 157 assertEquals(101, Cons16().charCodeAt(1.1)); | 168 assertEquals(101, Cons16().charCodeAt(1.1)); |
| 158 assertEquals('e', Cons16().charAt(1.1)); | 169 assertEquals('e', Cons16().charAt(1.1)); |
| 159 } | 170 } |
| 160 | 171 |
| 161 function StupidThing() { | 172 function StupidThing() { |
| 162 // Doesn't return a string from toString! | 173 // Doesn't return a string from toString! |
| 163 this.toString = function() { return 42; } | 174 this.toString = function() { return 42; } |
| 164 this.charCodeAt = String.prototype.charCodeAt; | 175 this.charCodeAt = String.prototype.charCodeAt; |
| 165 } | 176 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 187 | 198 |
| 188 assertTrue(isNaN(medium.charCodeAt(-1)), 31); | 199 assertTrue(isNaN(medium.charCodeAt(-1)), 31); |
| 189 assertEquals(49, medium.charCodeAt(0), 32); | 200 assertEquals(49, medium.charCodeAt(0), 32); |
| 190 assertEquals(56, medium.charCodeAt(255), 33); | 201 assertEquals(56, medium.charCodeAt(255), 33); |
| 191 assertTrue(isNaN(medium.charCodeAt(256)), 34); | 202 assertTrue(isNaN(medium.charCodeAt(256)), 34); |
| 192 | 203 |
| 193 assertTrue(isNaN(long.charCodeAt(-1)), 35); | 204 assertTrue(isNaN(long.charCodeAt(-1)), 35); |
| 194 assertEquals(49, long.charCodeAt(0), 36); | 205 assertEquals(49, long.charCodeAt(0), 36); |
| 195 assertEquals(56, long.charCodeAt(65535), 37); | 206 assertEquals(56, long.charCodeAt(65535), 37); |
| 196 assertTrue(isNaN(long.charCodeAt(65536)), 38); | 207 assertTrue(isNaN(long.charCodeAt(65536)), 38); |
| 208 |
| 209 |
| 210 // Test crankshaft code when the function is set directly on the |
| 211 // string prototype object instead of the hidden prototype object. |
| 212 // See http://code.google.com/p/v8/issues/detail?id=1070 |
| 213 |
| 214 String.prototype.x = String.prototype.charCodeAt; |
| 215 |
| 216 function directlyOnPrototype() { |
| 217 assertEquals(97, "a".x(0)); |
| 218 assertEquals(98, "b".x(0)); |
| 219 assertEquals(99, "c".x(0)); |
| 220 assertEquals(97, "a".x(0)); |
| 221 assertEquals(98, "b".x(0)); |
| 222 assertEquals(99, "c".x(0)); |
| 223 } |
| 224 |
| 225 for (var i = 0; i < 10000; i++) { |
| 226 directlyOnPrototype(); |
| 227 } |
| OLD | NEW |