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

Side by Side Diff: test/mjsunit/es6/typedarray-tostring.js

Issue 2164923002: Make toLocaleString on arrays always call toLocaleString on its elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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 | « test/mjsunit/array-tostring.js ('k') | test/test262/test262.status » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 // Array's toString should call the object's own join method, if one exists and 5 // Array's toString should call the object's own join method, if one exists and
6 // is callable. Otherwise, just use the original Object.toString function. 6 // is callable. Otherwise, just use the original Object.toString function.
7 7
8 var typedArrayConstructors = [ 8 var typedArrayConstructors = [
9 Uint8Array, 9 Uint8Array,
10 Int8Array, 10 Int8Array,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 // Redefining length does not change result 77 // Redefining length does not change result
78 var a5 = new constructor([1, 2, 3]) 78 var a5 = new constructor([1, 2, 3])
79 Object.defineProperty(a5, 'length', { value: 2 }); 79 Object.defineProperty(a5, 'length', { value: 2 });
80 assertEquals("1,2,3", a5.join()); 80 assertEquals("1,2,3", a5.join());
81 assertEquals("1,2,3", a5.toString()); 81 assertEquals("1,2,3", a5.toString());
82 assertEquals("1,2,3", a5.toLocaleString()); 82 assertEquals("1,2,3", a5.toLocaleString());
83 assertEquals("1,2", Array.prototype.join.call(a5)); 83 assertEquals("1,2", Array.prototype.join.call(a5));
84 assertEquals("1,2,3", Array.prototype.toString.call(a5)); 84 assertEquals("1,2,3", Array.prototype.toString.call(a5));
85 assertEquals("1,2", Array.prototype.toLocaleString.call(a5)); 85 assertEquals("1,2", Array.prototype.toLocaleString.call(a5));
86
87 (function TestToLocaleStringCalls() {
88 let log = [];
89 let pushArgs = (label) => (...args) => log.push(label, args);
90
91 let NumberToLocaleString = Number.prototype.toLocaleString;
92 Number.prototype.toLocaleString = pushArgs("Number");
93
94 (new constructor([1, 2])).toLocaleString();
95 assertEquals(["Number", [], "Number", []], log);
96
97 Number.prototype.toLocaleString = NumberToLocaleString;
98 })();
86 } 99 }
OLDNEW
« no previous file with comments | « test/mjsunit/array-tostring.js ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698