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

Unified Diff: test/mjsunit/harmony/function-name.js

Issue 1634403002: Add ES2015 Function.name support to pattern and default parameter initializers (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added parenthesized tests Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser-base.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/function-name.js
diff --git a/test/mjsunit/harmony/function-name.js b/test/mjsunit/harmony/function-name.js
index 8ca5d8209acd988d4273f9abfa3b5d9ebe52fc1b..06ada10ac8055bb5be0784cc70679171f223e7a8 100644
--- a/test/mjsunit/harmony/function-name.js
+++ b/test/mjsunit/harmony/function-name.js
@@ -3,6 +3,7 @@
// found in the LICENSE file.
//
// Flags: --harmony-function-name
+// Flags: --harmony-destructuring-bind --harmony-destructuring-assignment
(function testVariableDeclarationsFunction() {
'use strict';
@@ -159,3 +160,153 @@
classLit = class { constructor() {} static get ['name']() { return true; } };
assertTrue(classLit.name);
})();
+
+(function testObjectBindingPattern() {
+ var {
+ a = function() {},
+ b = () => {},
+ x = function withName() { },
+ y = class { },
+ z = class ClassName { },
+ q = class { static name() { return 42 } },
+ foo: bar = function() {},
+ inParens = (() => {}),
+ inManyParens = ((((() => {})))),
+ } = {};
+ assertEquals('a', a.name);
+ assertEquals('b', b.name);
+ assertEquals('withName', x.name);
+ assertEquals('y', y.name);
+ assertEquals('ClassName', z.name);
+ assertEquals('function', typeof q.name);
+ assertEquals('bar', bar.name);
+ assertEquals('inParens', inParens.name)
+ assertEquals('inManyParens', inManyParens.name)
+})();
+
+(function testArrayBindingPattern() {
+ var [
+ a = function() {},
+ b = () => {},
+ x = function withName() { },
+ y = class { },
+ z = class ClassName { },
+ q = class { static name() { return 42 } },
+ inParens = (() => {}),
+ inManyParens = ((((() => {})))),
+ ] = [];
+ assertEquals('a', a.name);
+ assertEquals('b', b.name);
+ assertEquals('withName', x.name);
+ assertEquals('y', y.name);
+ assertEquals('ClassName', z.name);
+ assertEquals('function', typeof q.name);
+ assertEquals('inParens', inParens.name)
+ assertEquals('inManyParens', inManyParens.name)
+})();
+
+(function testObjectAssignmentPattern() {
+ var a, b, x, y, z, q;
+ ({
+ a = function() {},
+ b = () => {},
+ x = function withName() { },
+ y = class { },
+ z = class ClassName { },
+ q = class { static name() { return 42 } },
+ foo: bar = function() {},
+ inParens = (() => {}),
+ inManyParens = ((((() => {})))),
+ } = {});
+ assertEquals('a', a.name);
+ assertEquals('b', b.name);
+ assertEquals('withName', x.name);
+ assertEquals('y', y.name);
+ assertEquals('ClassName', z.name);
+ assertEquals('function', typeof q.name);
+ assertEquals('bar', bar.name);
+ assertEquals('inParens', inParens.name)
+ assertEquals('inManyParens', inManyParens.name)
+})();
+
+(function testArrayAssignmentPattern() {
+ var a, b, x, y, z, q;
+ [
+ a = function() {},
+ b = () => {},
+ x = function withName() { },
+ y = class { },
+ z = class ClassName { },
+ q = class { static name() { return 42 } },
+ inParens = (() => {}),
+ inManyParens = ((((() => {})))),
+ ] = [];
+ assertEquals('a', a.name);
+ assertEquals('b', b.name);
+ assertEquals('withName', x.name);
+ assertEquals('y', y.name);
+ assertEquals('ClassName', z.name);
+ assertEquals('function', typeof q.name);
+ assertEquals('inParens', inParens.name)
+ assertEquals('inManyParens', inManyParens.name)
+})();
+
+(function testParameterDestructuring() {
+ (function({ a = function() {},
+ b = () => {},
+ x = function withName() { },
+ y = class { },
+ z = class ClassName { },
+ q = class { static name() { return 42 } },
+ foo: bar = function() {},
+ inParens = (() => {}),
+ inManyParens = ((((() => {})))) }) {
+ assertEquals('a', a.name);
+ assertEquals('b', b.name);
+ assertEquals('withName', x.name);
+ assertEquals('y', y.name);
+ assertEquals('ClassName', z.name);
+ assertEquals('function', typeof q.name);
+ assertEquals('bar', bar.name);
+ assertEquals('inParens', inParens.name)
+ assertEquals('inManyParens', inManyParens.name)
+ })({});
+
+ (function([ a = function() {},
+ b = () => {},
+ x = function withName() { },
+ y = class { },
+ z = class ClassName { },
+ q = class { static name() { return 42 } },
+ inParens = (() => {}),
+ inManyParens = ((((() => {})))) ]) {
+ assertEquals('a', a.name);
+ assertEquals('b', b.name);
+ assertEquals('withName', x.name);
+ assertEquals('y', y.name);
+ assertEquals('ClassName', z.name);
+ assertEquals('function', typeof q.name);
+ assertEquals('inParens', inParens.name)
+ assertEquals('inManyParens', inManyParens.name)
+ })([]);
+})();
+
+(function testDefaultParameters() {
+ (function(a = function() {},
+ b = () => {},
+ x = function withName() { },
+ y = class { },
+ z = class ClassName { },
+ q = class { static name() { return 42 } },
+ inParens = (() => {}),
+ inManyParens = ((((() => {}))))) {
+ assertEquals('a', a.name);
+ assertEquals('b', b.name);
+ assertEquals('withName', x.name);
+ assertEquals('y', y.name);
+ assertEquals('ClassName', z.name);
+ assertEquals('function', typeof q.name);
+ assertEquals('inParens', inParens.name)
+ assertEquals('inManyParens', inManyParens.name)
+ })();
+})();
« no previous file with comments | « src/parsing/parser-base.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698