Skip to content
Snippets Groups Projects
Commit 9fe84c57 authored by Caio Lima's avatar Caio Lima
Browse files

Added missing cases of private field as function

parent 04ae1c13
No related branches found
No related tags found
No related merge requests found
// 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');
// 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();
// 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();
// 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');
// 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');
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment