summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/destructuring/binding/syntax/property-list-bindings-elements.js
blob: a5e2aae653d4c66e5806b9db8eef54f12477c3a3 (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
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
es6id: 13.3.3
description: >
  The ObjectBindingPattern with binding elements
info: |
  Destructuring Binding Patterns - Syntax

  ObjectBindingPattern[Yield] :
    { }
    { BindingPropertyList[?Yield] }
    { BindingPropertyList[?Yield] , }

  BindingPropertyList[Yield] :
    BindingProperty[?Yield]
    BindingPropertyList[?Yield] , BindingProperty[?Yield]

  BindingProperty[Yield] :
    SingleNameBinding[?Yield]
    PropertyName[?Yield] : BindingElement[?Yield]

  BindingElement[Yield ] :
    SingleNameBinding[?Yield]
    BindingPattern[?Yield] Initializer[In, ?Yield]opt

  SingleNameBinding[Yield] :
    BindingIdentifier[?Yield] Initializer[In, ?Yield]opt

features: [destructuring-binding]
---*/

// BindingElement w/ SingleNameBinding
function fna({x: y}) {}

// BindingElement w/ SingleNameBinding with initializer
function fnb({x: y = 42}) {}

// BindingElement w/ BindingPattern
function fnc({x: {}}) {}
function fnd({x: {y}}) {}

// BindingElement w/ BindingPattern w/ initializer
function fne({x: {} = 42}) {}
function fnf({x: {y} = 42}) {}

reportCompare(0, 0);