Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test262
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pmaksimo
test262
Commits
a6e9a4ea
Commit
a6e9a4ea
authored
7 years ago
by
Valerie R Young
Browse files
Options
Downloads
Patches
Plain Diff
classfields: PrivateFieldAdd TypeError test
parent
ad12c4f5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/language/statements/class/privatefieldadd-typeerror.js
+60
-0
60 additions, 0 deletions
test/language/statements/class/privatefieldadd-typeerror.js
with
60 additions
and
0 deletions
test/language/statements/class/privatefieldadd-typeerror.js
0 → 100644
+
60
−
0
View file @
a6e9a4ea
// Copyright (C) 2017 Valerie Young. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Class construction should error if attempting to add private field twice
esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget
info: |
[[Construct]] ( argumentsList, newTarget)
...
8. If kind is "base", then
a. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument).
b. Let result be InitializeInstanceFields(thisArgument, F).
c. If result is an abrupt completion, then
i. Remove calleeContext from execution context stack and restore callerContext as the running execution context.
ii. Return Completion(result).
InitializeInstanceFields ( O, constructor )
1. Assert: Type ( O ) is Object.
2. Assert: Assert constructor is an ECMAScript function object.
3. Let fieldRecords be the value of constructor's [[Fields]] internal slot.
4. For each item fieldRecord in order from fieldRecords,
a. If fieldRecord.[[static]] is false, then
i. Perform ? DefineField(O, fieldRecord).
DefineField(receiver, fieldRecord)
...
8. If fieldName is a Private Name,
a. Perform ? PrivateFieldAdd(fieldName, receiver, initValue).
PrivateFieldAdd (P, O, value)
1. Assert: P is a Private Name value.
2. If O is not an object, throw a TypeError exception.
3. Let entry be PrivateFieldFind(P, O).
4. If entry is not empty, throw a TypeError exception.
features: [class-fields]
---*/
class
A
{
constructor
(
arg
)
{
return
arg
;
}
}
class
C
extends
A
{
#x
;
constructor
(
arg
)
{
super
(
arg
);
}
}
var
containsprivatex
=
new
C
();
assert
.
throws
(
TypeError
,
function
()
{
// After the super call in C's constructor, the `this` value in C will
// already have "#x" in it's [[PrivateFieldValues]]
new
C
(
containsprivatex
);
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment