14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd. 34514f5e3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44514f5e3Sopenharmony_ci * you may not use this file except in compliance with the License. 54514f5e3Sopenharmony_ci * You may obtain a copy of the License at 64514f5e3Sopenharmony_ci * 74514f5e3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84514f5e3Sopenharmony_ci * 94514f5e3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104514f5e3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114514f5e3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124514f5e3Sopenharmony_ci * See the License for the specific language governing permissions and 134514f5e3Sopenharmony_ci * limitations under the License. 144514f5e3Sopenharmony_ci */ 154514f5e3Sopenharmony_ci 164514f5e3Sopenharmony_ci/* 174514f5e3Sopenharmony_ci * @tc.name:objoperate 184514f5e3Sopenharmony_ci * @tc.desc:test object operate 194514f5e3Sopenharmony_ci * @tc.type: FUNC 204514f5e3Sopenharmony_ci * @tc.require: issueI5NO8G 214514f5e3Sopenharmony_ci */ 224514f5e3Sopenharmony_cifunction assertEqual(a, b) { 234514f5e3Sopenharmony_ci var t1 = JSON.stringify(a); 244514f5e3Sopenharmony_ci var t2 = JSON.stringify(b); 254514f5e3Sopenharmony_ci if (t1 == t2) { 264514f5e3Sopenharmony_ci print("PASS"); 274514f5e3Sopenharmony_ci } else { 284514f5e3Sopenharmony_ci print("FAIL"); 294514f5e3Sopenharmony_ci } 304514f5e3Sopenharmony_ci} 314514f5e3Sopenharmony_ci 324514f5e3Sopenharmony_civar obj1 = {a:2, b:3, c:4}; 334514f5e3Sopenharmony_civar obj2 = {d:1, ...obj1, e:5}; 344514f5e3Sopenharmony_ciassertEqual(obj2, {d:1, a:2, b:3, c:4, e:5}); 354514f5e3Sopenharmony_ci 364514f5e3Sopenharmony_civar obj = {["a" + "b" + "de"]:function() {return 1;}} 374514f5e3Sopenharmony_ciassertEqual(obj.abde.name, "abde"); 384514f5e3Sopenharmony_ci 394514f5e3Sopenharmony_civar foo = () => { 404514f5e3Sopenharmony_ci function f1() { 414514f5e3Sopenharmony_ci return this; 424514f5e3Sopenharmony_ci } 434514f5e3Sopenharmony_ci function f2() { 444514f5e3Sopenharmony_ci return f1; 454514f5e3Sopenharmony_ci } 464514f5e3Sopenharmony_ci Object.defineProperty(this, "detailed", {configurable:true, enumerable:true, get:f1, set:f2}); 474514f5e3Sopenharmony_ci}; 484514f5e3Sopenharmony_cifoo(); 494514f5e3Sopenharmony_cifoo(); // expect no error 504514f5e3Sopenharmony_ci 514514f5e3Sopenharmony_civar b = new ArrayBuffer(400); 524514f5e3Sopenharmony_civar v1 = new Int32Array(b); 534514f5e3Sopenharmony_civar str = '-' + '0'; 544514f5e3Sopenharmony_civar str1 = '4.' + '67'; 554514f5e3Sopenharmony_civar str2 = "jjj" + "kk"; 564514f5e3Sopenharmony_ciprint(v1[str2]); 574514f5e3Sopenharmony_civ1[str2] = 5; 584514f5e3Sopenharmony_ciprint(v1[str2]); 594514f5e3Sopenharmony_ci 604514f5e3Sopenharmony_ci 614514f5e3Sopenharmony_civar obj1 = {}; 624514f5e3Sopenharmony_ci 634514f5e3Sopenharmony_ciobj1.__proto__ = v1; 644514f5e3Sopenharmony_ci 654514f5e3Sopenharmony_ciprint(obj1[str]); 664514f5e3Sopenharmony_ciobj1[str] = 5; 674514f5e3Sopenharmony_ciprint(obj1[str]); 684514f5e3Sopenharmony_ci 694514f5e3Sopenharmony_civ1[4] = 123; 704514f5e3Sopenharmony_civ1[5] = 23; 714514f5e3Sopenharmony_ciprint(obj1[str1]); 724514f5e3Sopenharmony_ciobj1[str1] = 5; 734514f5e3Sopenharmony_ciprint(obj1[str1]); 744514f5e3Sopenharmony_ci 754514f5e3Sopenharmony_cilet key = 1 + {}; 764514f5e3Sopenharmony_ciprint("abc"[key]) 774514f5e3Sopenharmony_ci 784514f5e3Sopenharmony_cilet v3 = /a/; 794514f5e3Sopenharmony_cilet v4=v3.exec(v3); 804514f5e3Sopenharmony_cifor(let i=0;i<5;i++){ 814514f5e3Sopenharmony_ci v4[{}]=print; 824514f5e3Sopenharmony_ci} 834514f5e3Sopenharmony_ciprint("set obj by name test success!") 84