summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/object/__proto__-duplicate-computed.js
blob: 99ac9e1374f46c6c5a560c9304c092182b0a0bf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 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.prototype.hasOwnProperty.call(obj, '__proto__'),
    'has own property __proto__'
);

assert.sameValue(
    obj.__proto__,
    ownProp,
    'own property value'
);

reportCompare(0, 0);