Added missing cases of private field as function

This commit is contained in:
Caio Lima 2019-02-06 17:13:42 -02:00
parent 04ae1c1359
commit 9fe84c576a
5 changed files with 178 additions and 0 deletions

View File

@ -0,0 +1,31 @@
// Copyright (C) 2019 Caio Lima. All rights reserved.
// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved.
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Calling arrow function returned from private field access
info: |
Updated Productions
CallExpression[Yield, Await]:
CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await]
SuperCall[?Yield, ?Await]
CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await]
CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]]
CallExpression[?Yield, ?Await].IdentifierName
CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await]
CallExpression[?Yield, ?Await].PrivateName
template: default
features: [class-fields-private, arrow-function]
---*/
//- elements
#m = () => 'test262';
method() {
return this.#m();
}
//- assertions
let c = new C();
assert.sameValue(c.method(), 'test262');

View File

@ -0,0 +1,37 @@
// Copyright (C) 2019 Caio Lima. All rights reserved.
// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved.
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Calling async arrow function returned from private field access
info: |
Updated Productions
CallExpression[Yield, Await]:
CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await]
SuperCall[?Yield, ?Await]
CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await]
CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]]
CallExpression[?Yield, ?Await].IdentifierName
CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await]
CallExpression[?Yield, ?Await].PrivateName
template: default
features: [class-fields-private, async-functions, arrow-function]
---*/
//- elements
#m = async () => 'test262';
method() {
return this.#m();
}
//- assertions
let c = new C();
async function asyncRun() {
assert.sameValue(await c.method(), 'test262');
}
asyncRun();

View File

@ -0,0 +1,37 @@
// Copyright (C) 2019 Caio Lima. All rights reserved.
// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved.
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Calling async function returned from private field access
info: |
Updated Productions
CallExpression[Yield, Await]:
CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await]
SuperCall[?Yield, ?Await]
CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await]
CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]]
CallExpression[?Yield, ?Await].IdentifierName
CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await]
CallExpression[?Yield, ?Await].PrivateName
template: default
features: [class-fields-private, async-functions]
---*/
//- elements
#m = async function() { return 'test262'; };
method() {
return this.#m();
}
//- assertions
let c = new C();
async function asyncRun() {
assert.sameValue(await c.method(), 'test262');
}
asyncRun();

View File

@ -0,0 +1,31 @@
// Copyright (C) 2019 Caio Lima. All rights reserved.
// Copyright (C) 2018 Jaideep Bhoosreddy (Bloomberg LP). All rights reserved.
// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Calling result returned from private field access
info: |
Updated Productions
CallExpression[Yield, Await]:
CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await]
SuperCall[?Yield, ?Await]
CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await]
CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]]
CallExpression[?Yield, ?Await].IdentifierName
CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await]
CallExpression[?Yield, ?Await].PrivateName
template: default
features: [class-fields-private]
---*/
//- elements
#m = function () { return 'test262'; };
method() {
return this.#m();
}
//- assertions
let c = new C();
assert.sameValue(c.method(), 'test262');

View File

@ -0,0 +1,42 @@
// Copyright (C) 2019 Caio Lima. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
desc: Acessing private field from super shoudl throw an error
info: |
Updated Productions
CallExpression[Yield, Await]:
CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await]
SuperCall[?Yield, ?Await]
CallExpression[?Yield, ?Await]Arguments[?Yield, ?Await]
CallExpression[?Yield, ?Await][Expression[+In, ?Yield, ?Await]]
CallExpression[?Yield, ?Await].IdentifierName
CallExpression[?Yield, ?Await]TemplateLiteral[?Yield, ?Await]
CallExpression[?Yield, ?Await].PrivateName
template: default
features: [class-fields-private, class-fields-public]
---*/
//- elements
#m = function() { return 'test262'; };
Child = class extends C {
access() {
return super.#m;
}
method() {
return super.#m();
}
}
//- assertions
assert.throws(TypeError, function() {
(new (new C()).Child).method();
}, 'super.#m() throws TypeError');
assert.throws(TypeError, function() {
(new (new C()).Child).access();
}, 'super.#m throws TypeError');