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

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

Issue 1518873004: [es6] Support Function name inference in variable declarations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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
Index: test/mjsunit/harmony/function-name.js
diff --git a/test/mjsunit/harmony/function-name.js b/test/mjsunit/harmony/function-name.js
new file mode 100644
index 0000000000000000000000000000000000000000..5da761f3c2ca7823b1a8f1212254610da035f0c0
--- /dev/null
+++ b/test/mjsunit/harmony/function-name.js
@@ -0,0 +1,35 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// Flags: --harmony-function-name
+
+(function testVariableDeclarationsFunction() {
+ 'use strict';
+ var a = function(){};
+ assertEquals('a', a.name);
+ let b = () => {};
+ assertEquals('b', b.name);
+ const c = ((function(){}));
+ assertEquals('c', c.name);
+
+ var x = function(){}, y = () => {}, z = function withName() {};
+ assertEquals('x', x.name);
+ assertEquals('y', y.name);
+ assertEquals('withName', z.name);
+})();
+
+(function testVariableDeclarationsClass() {
+ 'use strict';
+ var a = class {};
+ assertEquals('a', a.name);
+ let b = ((class {}));
+ assertEquals('b', b.name);
+ // Should not overwrite name property.
+ const c = class { static name() { } }
+ assertEquals('function', typeof c.name);
+
+ var x = class {}, y = class NamedClass {};
+ assertEquals('x', x.name);
+ assertEquals('NamedClass', y.name);
+})();

Powered by Google App Engine
This is Rietveld 408576698