Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: test/mjsunit/harmony/harmony-string-pad-end.js

Issue 1926773003: [esnext] implement StringPad spec changes from March TC39 meeting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/js/harmony-string-padding.js ('k') | test/mjsunit/harmony/harmony-string-pad-start.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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-string-padding 5 // Flags: --harmony-string-padding
6 6
7 (function TestMeta() { 7 (function TestMeta() {
8 assertEquals(1, String.prototype.padEnd.length); 8 assertEquals(1, String.prototype.padEnd.length);
9 assertEquals("function", typeof String.prototype.padEnd); 9 assertEquals("function", typeof String.prototype.padEnd);
10 assertEquals(Object.getPrototypeOf(Function), 10 assertEquals(Object.getPrototypeOf(Function),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 assertEquals("123", "123".padEnd(+0)); 60 assertEquals("123", "123".padEnd(+0));
61 assertEquals("123", "123".padEnd({ toString() { return +0; } })); 61 assertEquals("123", "123".padEnd({ toString() { return +0; } }));
62 assertEquals("123", "123".padEnd(NaN)); 62 assertEquals("123", "123".padEnd(NaN));
63 assertEquals("123", "123".padEnd({ toString() { return NaN; } })); 63 assertEquals("123", "123".padEnd({ toString() { return NaN; } }));
64 })(); 64 })();
65 65
66 66
67 (function TestFillerToString() { 67 (function TestFillerToString() {
68 assertEquals(". ", ".".padEnd(10)); 68 assertEquals(". ", ".".padEnd(10));
69 assertEquals(". ", ".".padEnd(10, undefined)); 69 assertEquals(". ", ".".padEnd(10, undefined));
70 assertEquals(". ", ".".padEnd(10, { toString() { return ""; } }));
71 assertEquals(".nullnulln", ".".padEnd(10, null)); 70 assertEquals(".nullnulln", ".".padEnd(10, null));
71 assertEquals(".XXXXXXXXX", ".".padEnd(10, { toString() { return "X"; } }));
72 assertEquals(
73 ".111111111",
74 ".".padEnd(10, { toString: undefined, valueOf() { return 1; } }));
72 })(); 75 })();
73 76
74 77
78 (function TestFillerEmptyString() {
79 assertEquals(".", ".".padEnd(10, ""));
80 assertEquals(".", ".".padEnd(10, { toString() { return ""; } }));
81 assertEquals(
82 ".", ".".padEnd(10, { toString: undefined, valueOf() { return ""; } }));
83 })();
84
85
75 (function TestFillerRepetition() { 86 (function TestFillerRepetition() {
76 for (var i = 2000; i > 0; --i) { 87 for (var i = 2000; i > 0; --i) {
77 var expected = "123" + "xoxo".repeat(i / 4).slice(0, i - 3); 88 var expected = "123" + "xoxo".repeat(i / 4).slice(0, i - 3);
78 var actual = "123".padEnd(i, "xoxo"); 89 var actual = "123".padEnd(i, "xoxo");
79 assertEquals(expected, actual); 90 assertEquals(expected, actual);
80 assertEquals(i > "123".length ? i : 3, actual.length); 91 assertEquals(i > "123".length ? i : 3, actual.length);
81 } 92 }
82 })(); 93 })();
83 94
84 95
85 (function TestTruncation() { 96 (function TestTruncation() {
86 assertEquals("ab", "a".padEnd(2, "bc")); 97 assertEquals("ab", "a".padEnd(2, "bc"));
87 })(); 98 })();
OLDNEW
« no previous file with comments | « src/js/harmony-string-padding.js ('k') | test/mjsunit/harmony/harmony-string-pad-start.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698