v8/test/mjsunit/harmony/function-name.js
adamk 819c429ca2 [es6] Support Function name inference in variable declarations
This is behind the --harmony-function-name flag, currently disabled.

With the flag enabled, we now pass the relevant tests in
language/statements/*/fn-name-*.

BUG=v8:3699
LOG=y

Review URL: https://codereview.chromium.org/1518873004

Cr-Commit-Position: refs/heads/master@{#32817}
2015-12-12 00:20:37 +00:00

36 lines
1002 B
JavaScript

// 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);
})();