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
e45b2ae5
Commit
e45b2ae5
authored
8 years ago
by
Leo Balter
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for computed __proto__ property keys (#916)
Fixes #904
parent
2f11b4d8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/annexB/language/expressions/object/__proto__-duplicate-computed.js
+54
-0
54 additions, 0 deletions
...nguage/expressions/object/__proto__-duplicate-computed.js
test/language/expressions/object/computed-__proto__.js
+177
-0
177 additions, 0 deletions
test/language/expressions/object/computed-__proto__.js
with
231 additions
and
0 deletions
test/annexB/language/expressions/object/__proto__-duplicate-computed.js
0 → 100644
+
54
−
0
View file @
e45b2ae5
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-__proto__-property-names-in-object-initializers
es6id: B.3.1
description: >
The syntax error for duplicate `__proto__` property is not valid if the duplicate is a
ComputedPropertyName
info: |
B.3.1__proto__ Property Names in Object Initializers
It is a Syntax Error if PropertyNameList of PropertyDefinitionList contains any duplicate
entries for "__proto__" and at least two of those entries were obtained from productions of
the form
PropertyDefinition : PropertyName : AssignmentExpression .
12.2.6.6 Static Semantics: PropertyNameList
...
3. Append PropName of PropertyDefinition to the end of list.
...
12.2.6.5 Static Semantics: PropName
ComputedPropertyName : [ AssignmentExpression ]
1. Return empty.
---*/
var
obj
;
var
proto
=
{};
var
ownProp
=
{};
obj
=
{
__proto__
:
proto
,
[
'
__proto__
'
]:
{},
[
'
__proto__
'
]:
ownProp
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
proto
,
'
prototype is defined
'
);
assert
(
Object
.
hasOwnProperty
.
call
(
obj
,
'
__proto__
'
),
'
has own property __proto__
'
);
assert
.
sameValue
(
obj
.
__proto__
,
ownProp
,
'
own property value
'
);
This diff is collapsed.
Click to expand it.
test/language/expressions/object/computed-__proto__.js
0 → 100644
+
177
−
0
View file @
e45b2ae5
// Copyright (C) 2017 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: prod-PropertyDefinition
description: >
computed __proto__ property key is assigned to an own property
info: |
12.2.6 Object Initializer
PropertyDefinition[Yield, Await] :
PropertyName[?Yield, ?Await] : AssignmentExpression[+In, ?Yield, ?Await]
PropertyName[Yield, Await] :
LiteralPropertyName
ComputedPropertyName[?Yield, ?Await]
ComputedPropertyName[Yield, Await] :
[ AssignmentExpression[+In, ?Yield, ?Await] ]
B.3.1__proto__ Property Names in Object Initializers
...
5. If propKey is the String value "__proto__" and if IsComputedPropertyKey(propKey)
is false, then
a. If Type(propValue) is either Object or Null, then
i. Return object.[[SetPrototypeOf]](propValue).
b. Return NormalCompletion(empty).
---*/
var
obj
;
var
sample
=
{};
obj
=
{
[
'
__proto__
'
]:
sample
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (ordinary object)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (ordinary object)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
sample
,
'
value is properly defined (ordinary object)
'
);
obj
=
{
[
'
__proto__
'
]:
null
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (null)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (null)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
null
,
'
value is properly defined (null)
'
);
obj
=
{
[
'
__proto__
'
]:
undefined
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (undefined)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (undefined)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
undefined
,
'
value is properly defined (undefined)
'
);
var
func
=
function
()
{};
obj
=
{
[
'
__proto__
'
]:
func
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (func)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (func)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
func
,
'
value is properly defined (func)
'
);
var
symbol
=
Symbol
(
'
Leo
'
);
obj
=
{
[
'
__proto__
'
]:
symbol
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (symbol)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (symbol)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
symbol
,
'
value is properly defined (symbol)
'
);
obj
=
{
[
'
__proto__
'
]:
42
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (number)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (number)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
42
,
'
value is properly defined (number)
'
);
obj
=
{
[
'
__proto__
'
]:
''
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (string)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (string)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
''
,
'
value is properly defined (string)
'
);
obj
=
{
[
'
__proto__
'
]:
false
};
assert
.
sameValue
(
Object
.
getPrototypeOf
(
obj
),
Object
.
prototype
,
'
does not change the object prototype (boolean)
'
);
assert
(
obj
.
hasOwnProperty
(
'
__proto__
'
),
'
computed __proto__ property is set as an own property (boolean)
'
);
assert
.
sameValue
(
obj
.
__proto__
,
false
,
'
value is properly defined (boolean)
'
);
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