Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2531)

Delta Between Two Patch Sets: test/mjsunit/harmony/string-fromcodepoint.js

Issue 13816046: Implement `String.prototype.codePointAt` and `String.fromCodePoint` Base URL: git://github.com/v8/v8.git@master
Left Patch Set: Updated as per Erik’s feedback Created 10 years, 9 months ago
Right Patch Set: Updated as per Yang’s feedback Created 10 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/mjsunit/harmony/string-codepointat.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 5 // Flags: --harmony-strings
6 6
7 // Tests taken from: 7 // Tests taken from:
8 // https://github.com/mathiasbynens/String.fromCodePoint/blob/master/tests/tests .js 8 // https://github.com/mathiasbynens/String.fromCodePoint
9 9
10 assertEquals(String.fromCodePoint.length, 0); 10 assertEquals(String.fromCodePoint.length, 1);
11 assertEquals(String.propertyIsEnumerable("fromCodePoint"), false); 11 assertEquals(String.propertyIsEnumerable("fromCodePoint"), false);
12 12
13 assertEquals(String.fromCodePoint(""), "\0"); 13 assertEquals(String.fromCodePoint(""), "\0");
14 assertEquals(String.fromCodePoint(), ""); 14 assertEquals(String.fromCodePoint(), "");
15 assertEquals(String.fromCodePoint(-0), "\0"); 15 assertEquals(String.fromCodePoint(-0), "\0");
16 assertEquals(String.fromCodePoint(0), "\0"); 16 assertEquals(String.fromCodePoint(0), "\0");
17 assertEquals(String.fromCodePoint(0x1D306), "\uD834\uDF06"); 17 assertEquals(String.fromCodePoint(0x1D306), "\uD834\uDF06");
18 assertEquals( 18 assertEquals(
19 String.fromCodePoint(0x1D306, 0x61, 0x1D307), 19 String.fromCodePoint(0x1D306, 0x61, 0x1D307),
20 "\uD834\uDF06a\uD834\uDF07"); 20 "\uD834\uDF06a\uD834\uDF07");
(...skipping 16 matching lines...) Expand all
37 assertThrows(function() { String.fromCodePoint(/./); }, RangeError); 37 assertThrows(function() { String.fromCodePoint(/./); }, RangeError);
38 assertThrows(function() { String.fromCodePoint({ 38 assertThrows(function() { String.fromCodePoint({
39 valueOf: function() { throw Error(); } }); 39 valueOf: function() { throw Error(); } });
40 }, Error); 40 }, Error);
41 assertThrows(function() { String.fromCodePoint({ 41 assertThrows(function() { String.fromCodePoint({
42 valueOf: function() { throw Error(); } }); 42 valueOf: function() { throw Error(); } });
43 }, Error); 43 }, Error);
44 var tmp = 0x60; 44 var tmp = 0x60;
45 assertEquals(String.fromCodePoint({ 45 assertEquals(String.fromCodePoint({
46 valueOf: function() { ++tmp; return tmp; } 46 valueOf: function() { ++tmp; return tmp; }
47 }), "a"); 47 }), "a");
arv 2014/06/19 22:24:44 Assert tmp here too (and in the other file)
48 assertEquals(tmp, 0x61);
48 49
49 var counter = Math.pow(2, 15) * 3 / 2; 50 var counter = Math.pow(2, 15) * 3 / 2;
50 var result = []; 51 var result = [];
51 while (--counter >= 0) { 52 while (--counter >= 0) {
52 result.push(0); // one code unit per symbol 53 result.push(0); // one code unit per symbol
53 } 54 }
54 String.fromCodePoint.apply(null, result); // must not throw 55 String.fromCodePoint.apply(null, result); // must not throw
55 56
56 var counter = Math.pow(2, 15) * 3 / 2; 57 var counter = Math.pow(2, 15) * 3 / 2;
57 var result = []; 58 var result = [];
58 while (--counter >= 0) { 59 while (--counter >= 0) {
59 result.push(0xFFFF + 1); // two code units per symbol 60 result.push(0xFFFF + 1); // two code units per symbol
60 } 61 }
61 String.fromCodePoint.apply(null, result); // must not throw 62 String.fromCodePoint.apply(null, result); // must not throw
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b