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

Side by Side Diff: test/mjsunit/harmony/function-name.js

Issue 1563923002: [es6] Handle function names in object and class literals (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« src/parsing/parser.cc ('K') | « src/parsing/preparser.cc ('k') | no next file » | 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 // Flags: --harmony-function-name 5 // Flags: --harmony-function-name
6 6
7 (function testVariableDeclarationsFunction() { 7 (function testVariableDeclarationsFunction() {
8 'use strict'; 8 'use strict';
9 var a = function(){}; 9 var a = function(){};
10 assertEquals('a', a.name); 10 assertEquals('a', a.name);
(...skipping 15 matching lines...) Expand all
26 let b = ((class {})); 26 let b = ((class {}));
27 assertEquals('b', b.name); 27 assertEquals('b', b.name);
28 // Should not overwrite name property. 28 // Should not overwrite name property.
29 const c = class { static name() { } } 29 const c = class { static name() { } }
30 assertEquals('function', typeof c.name); 30 assertEquals('function', typeof c.name);
31 31
32 var x = class {}, y = class NamedClass {}; 32 var x = class {}, y = class NamedClass {};
33 assertEquals('x', x.name); 33 assertEquals('x', x.name);
34 assertEquals('NamedClass', y.name); 34 assertEquals('NamedClass', y.name);
35 })(); 35 })();
36
37 (function testObjectProperties() {
38 'use strict';
39 var obj = {
40 a: function() {},
41 b: () => {},
42 c() { },
43 get d() { },
44 set d(val) { },
45 x: function withName() { },
46 y: class { },
47 z: class ClassName { },
48 42: function() {},
49 4.2: function() {},
50 };
51
52 assertEquals('a', obj.a.name);
53 assertEquals('b', obj.b.name);
54 assertEquals('c', obj.c.name);
55 var dDescriptor = Object.getOwnPropertyDescriptor(obj, 'd');
56 assertEquals('get d', dDescriptor.get.name);
57 assertEquals('set d', dDescriptor.set.name);
58 assertEquals('withName', obj.x.name);
59 assertEquals('y', obj.y.name);
60 assertEquals('ClassName', obj.z.name);
61 assertEquals('42', obj[42].name);
62 assertEquals('4.2', obj[4.2].name);
63 })();
64
65 (function testClassProperties() {
66 'use strict';
67 class C {
68 a() { }
69 static b() { }
70 get c() { }
71 set c(val) { }
72 42() { }
73 static 43() { }
74 get 44() { }
75 set 44(val) { }
76 };
77
78 assertEquals('a', C.prototype.a.name);
79 assertEquals('b', C.b.name);
80 var descriptor = Object.getOwnPropertyDescriptor(C.prototype, 'c');
81 assertEquals('get c', descriptor.get.name);
82 assertEquals('set c', descriptor.set.name);
83 assertEquals('42', C.prototype[42].name);
84 assertEquals('43', C[43].name);
85 var descriptor = Object.getOwnPropertyDescriptor(C.prototype, '44');
86 assertEquals('get 44', descriptor.get.name);
87 assertEquals('set 44', descriptor.set.name);
88 })();
OLDNEW
« src/parsing/parser.cc ('K') | « src/parsing/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698