OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Flags: --harmony-function-name |
| 6 |
| 7 (function testVariableDeclarationsFunction() { |
| 8 'use strict'; |
| 9 var a = function(){}; |
| 10 assertEquals('a', a.name); |
| 11 let b = () => {}; |
| 12 assertEquals('b', b.name); |
| 13 const c = ((function(){})); |
| 14 assertEquals('c', c.name); |
| 15 |
| 16 var x = function(){}, y = () => {}, z = function withName() {}; |
| 17 assertEquals('x', x.name); |
| 18 assertEquals('y', y.name); |
| 19 assertEquals('withName', z.name); |
| 20 })(); |
| 21 |
| 22 (function testVariableDeclarationsClass() { |
| 23 'use strict'; |
| 24 var a = class {}; |
| 25 assertEquals('a', a.name); |
| 26 let b = ((class {})); |
| 27 assertEquals('b', b.name); |
| 28 // Should not overwrite name property. |
| 29 const c = class { static name() { } } |
| 30 assertEquals('function', typeof c.name); |
| 31 |
| 32 var x = class {}, y = class NamedClass {}; |
| 33 assertEquals('x', x.name); |
| 34 assertEquals('NamedClass', y.name); |
| 35 })(); |
OLD | NEW |