Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 static [sym2]() { } | 113 static [sym2]() { } |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Should be 'a' | 116 // Should be 'a' |
| 117 assertEquals('', C.prototype[a].name); | 117 assertEquals('', C.prototype[a].name); |
| 118 // Should be '[1]' | 118 // Should be '[1]' |
| 119 assertEquals('', C.prototype[sym1].name); | 119 assertEquals('', C.prototype[sym1].name); |
| 120 // Should be '[2]' | 120 // Should be '[2]' |
| 121 assertEquals('', C[sym2].name); | 121 assertEquals('', C[sym2].name); |
| 122 })(); | 122 })(); |
| 123 | |
| 124 | |
| 125 (function testAssignment() { | |
|
rossberg
2016/01/14 08:01:53
This could take a couple more tests. In particular
| |
| 126 var basicFn, arrowFn, generatorFn, classLit; | |
| 127 | |
| 128 basicFn = function() { return true; }; | |
| 129 assertEquals('basicFn', basicFn.name); | |
| 130 var basicFn2 = basicFn; | |
| 131 assertEquals('basicFn', basicFn2.name); | |
| 132 basicFn = function functionWithName() { }; | |
| 133 assertEquals("functionWithName", basicFn.name); | |
| 134 | |
| 135 arrowFn = x => x; | |
| 136 assertEquals('arrowFn', arrowFn.name); | |
| 137 var arrowFn2 = arrowFn; | |
| 138 assertEquals('arrowFn', arrowFn2.name); | |
| 139 | |
| 140 generatorFn = function*() { yield true; }; | |
| 141 assertEquals('generatorFn', generatorFn.name); | |
| 142 var generatorFn2 = generatorFn; | |
| 143 assertEquals('generatorFn', generatorFn2.name); | |
| 144 generatorFn = function* generatorWithName() { }; | |
| 145 assertEquals("generatorWithName", generatorFn.name); | |
| 146 | |
| 147 classLit = class { constructor() {} }; | |
| 148 assertEquals('classLit', classLit.name); | |
| 149 var classLit2 = classLit; | |
| 150 assertEquals('classLit', classLit2.name); | |
| 151 classLit = class classWithName { constructor() {} }; | |
| 152 assertEquals('classWithName', classLit.name); | |
| 153 classLit = class { constructor() {} static name() {} }; | |
| 154 assertEquals('function', typeof classLit.name); | |
| 155 classLit = class { constructor() {} static get name() { return true; } }; | |
| 156 assertTrue(classLit.name); | |
| 157 classLit = class { constructor() {} static ['name']() {} }; | |
| 158 assertEquals('function', typeof classLit.name); | |
| 159 classLit = class { constructor() {} static get ['name']() { return true; } }; | |
| 160 assertTrue(classLit.name); | |
| 161 })(); | |
| OLD | NEW |