OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Flags: --harmony-strings | |
6 | |
7 // Tests taken from: | 5 // Tests taken from: |
8 // https://github.com/mathiasbynens/String.prototype.codePointAt | 6 // https://github.com/mathiasbynens/String.prototype.codePointAt |
9 | 7 |
10 assertEquals(String.prototype.codePointAt.length, 1); | 8 assertEquals(String.prototype.codePointAt.length, 1); |
11 assertEquals(String.prototype.propertyIsEnumerable("codePointAt"), false); | 9 assertEquals(String.prototype.propertyIsEnumerable("codePointAt"), false); |
12 | 10 |
13 // String that starts with a BMP symbol | 11 // String that starts with a BMP symbol |
14 assertEquals("abc\uD834\uDF06def".codePointAt(""), 0x61); | 12 assertEquals("abc\uD834\uDF06def".codePointAt(""), 0x61); |
15 assertEquals("abc\uD834\uDF06def".codePointAt("_"), 0x61); | 13 assertEquals("abc\uD834\uDF06def".codePointAt("_"), 0x61); |
16 assertEquals("abc\uD834\uDF06def".codePointAt(), 0x61); | 14 assertEquals("abc\uD834\uDF06def".codePointAt(), 0x61); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 assertEquals(String.prototype.codePointAt.call(42, 0), 0x34); | 80 assertEquals(String.prototype.codePointAt.call(42, 0), 0x34); |
83 assertEquals(String.prototype.codePointAt.call(42, 1), 0x32); | 81 assertEquals(String.prototype.codePointAt.call(42, 1), 0x32); |
84 assertEquals(String.prototype.codePointAt.call({ | 82 assertEquals(String.prototype.codePointAt.call({ |
85 toString: function() { return "abc"; } | 83 toString: function() { return "abc"; } |
86 }, 2), 0x63); | 84 }, 2), 0x63); |
87 var tmp = 0; | 85 var tmp = 0; |
88 assertEquals(String.prototype.codePointAt.call({ | 86 assertEquals(String.prototype.codePointAt.call({ |
89 toString: function() { ++tmp; return String(tmp); } | 87 toString: function() { ++tmp; return String(tmp); } |
90 }, 0), 0x31); | 88 }, 0), 0x31); |
91 assertEquals(tmp, 1); | 89 assertEquals(tmp, 1); |
OLD | NEW |