1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import assert from 'assert';
17
18// 不新增变量
19let [PropDemo1, PropDemo2] = ['akria', 12];
20let {...reset1} = {'name2': 'akria2', age2: 18};
21
22assert(PropDemo1 === 'akria', 'success');
23assert(PropDemo2 === 12, 'success');
24assert(reset1.name2 === 'akria2', 'success');
25assert(reset1.age2 === 18, 'success');
26
27function funcLayer(){
28  let [PropDemo3, PropDemo4] = ['akria3', 13];
29  let {...reset2} = {'name2': 'akria4', age2: 20};
30
31  const {PropDemo5, PropDemo6 = 1} = {PropDemo5: 1, PropDemo6: 2};
32  assert(PropDemo6 === 2, 'success');
33  assert(PropDemo3 === 'akria3', 'success');
34  assert(PropDemo4 === 13, 'success');
35  assert(reset2.name2 === 'akria4', 'success');
36  assert(reset2.age2 === 20, 'success');
37}
38funcLayer();
39
40// 新增变量
41let { newName, ...reset3 } = {'newName': 'akria5', newAge: 20};
42assert(newName === 'akria5', 'success');
43assert(reset3.newAge === 20, 'success');
44
45function foo() {
46  return { Propx1: 1, Propy1: 2 };
47}
48
49const { Propx1, Propy1 } = foo();
50assert(Propx1 === 1, 'success');
51assert(Propy1 === 2, 'success');
52
53let Propx2 = 13;
54let Propy2 = 14;
55const { Propx2: tempX2, Propy2: tempY2 } = {Propx2, Propy2}
56assert(tempX2 === 13, 'success');
57assert(tempY2 === 14, 'success');
58