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 for (var i = 0; i != 10; i++) { |
| 157 assertEquals(101, Cons16().charCodeAt(1.1)); |
| 158 assertEquals('e', Cons16().charAt(1.1)); |
| 159 } |
156 | 160 |
157 function StupidThing() { | 161 function StupidThing() { |
158 // Doesn't return a string from toString! | 162 // Doesn't return a string from toString! |
159 this.toString = function() { return 42; } | 163 this.toString = function() { return 42; } |
160 this.charCodeAt = String.prototype.charCodeAt; | 164 this.charCodeAt = String.prototype.charCodeAt; |
161 } | 165 } |
162 | 166 |
163 assertEquals(52, new StupidThing().charCodeAt(0), 27); | 167 assertEquals(52, new StupidThing().charCodeAt(0), 27); |
164 assertEquals(50, new StupidThing().charCodeAt(1), 28); | 168 assertEquals(50, new StupidThing().charCodeAt(1), 28); |
165 assertTrue(isNaN(new StupidThing().charCodeAt(2)), 29); | 169 assertTrue(isNaN(new StupidThing().charCodeAt(2)), 29); |
(...skipping 17 matching lines...) Expand all Loading... |
183 | 187 |
184 assertTrue(isNaN(medium.charCodeAt(-1)), 31); | 188 assertTrue(isNaN(medium.charCodeAt(-1)), 31); |
185 assertEquals(49, medium.charCodeAt(0), 32); | 189 assertEquals(49, medium.charCodeAt(0), 32); |
186 assertEquals(56, medium.charCodeAt(255), 33); | 190 assertEquals(56, medium.charCodeAt(255), 33); |
187 assertTrue(isNaN(medium.charCodeAt(256)), 34); | 191 assertTrue(isNaN(medium.charCodeAt(256)), 34); |
188 | 192 |
189 assertTrue(isNaN(long.charCodeAt(-1)), 35); | 193 assertTrue(isNaN(long.charCodeAt(-1)), 35); |
190 assertEquals(49, long.charCodeAt(0), 36); | 194 assertEquals(49, long.charCodeAt(0), 36); |
191 assertEquals(56, long.charCodeAt(65535), 37); | 195 assertEquals(56, long.charCodeAt(65535), 37); |
192 assertTrue(isNaN(long.charCodeAt(65536)), 38); | 196 assertTrue(isNaN(long.charCodeAt(65536)), 38); |
OLD | NEW |