1/* 2 * Copyright (c) 2021 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 16/* 17 * @tc.name:objoperate 18 * @tc.desc:test object operate 19 * @tc.type: FUNC 20 * @tc.require: issueI5NO8G 21 */ 22function assertEqual(a, b) { 23 var t1 = JSON.stringify(a); 24 var t2 = JSON.stringify(b); 25 if (t1 == t2) { 26 print("PASS"); 27 } else { 28 print("FAIL"); 29 } 30} 31 32var obj1 = {a:2, b:3, c:4}; 33var obj2 = {d:1, ...obj1, e:5}; 34assertEqual(obj2, {d:1, a:2, b:3, c:4, e:5}); 35 36var obj = {["a" + "b" + "de"]:function() {return 1;}} 37assertEqual(obj.abde.name, "abde"); 38 39var foo = () => { 40 function f1() { 41 return this; 42 } 43 function f2() { 44 return f1; 45 } 46 Object.defineProperty(this, "detailed", {configurable:true, enumerable:true, get:f1, set:f2}); 47}; 48foo(); 49foo(); // expect no error 50