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:loadicbyvalue
184514f5e3Sopenharmony_ci * @tc.desc:test loadicbyvalue
194514f5e3Sopenharmony_ci * @tc.type: FUNC
204514f5e3Sopenharmony_ci * @tc.require: issueI5NO8G
214514f5e3Sopenharmony_ci */
224514f5e3Sopenharmony_civar i = 3;
234514f5e3Sopenharmony_civar obj = { 3: "icsuccess" };
244514f5e3Sopenharmony_cifunction func1(a) {
254514f5e3Sopenharmony_ci    var b = a[i];
264514f5e3Sopenharmony_ci}
274514f5e3Sopenharmony_cifor (let j = 300; j > 0; j--) {
284514f5e3Sopenharmony_ci    func1(obj);
294514f5e3Sopenharmony_ci}
304514f5e3Sopenharmony_ciprint(obj[i]);
314514f5e3Sopenharmony_ci
324514f5e3Sopenharmony_ci// PoC testcase
334514f5e3Sopenharmony_ciconst arr = []
344514f5e3Sopenharmony_cifor (let i = 0; i < 20; i++) {
354514f5e3Sopenharmony_ci    const v0 = "p" + i;
364514f5e3Sopenharmony_ci    const v1 = Symbol.iterator;
374514f5e3Sopenharmony_ci    const v2 = {
384514f5e3Sopenharmony_ci        [v1]() { },
394514f5e3Sopenharmony_ci    };
404514f5e3Sopenharmony_ci    arr[v0] = i;
414514f5e3Sopenharmony_ci}
424514f5e3Sopenharmony_ciconst v3 = new Uint8Array(128);
434514f5e3Sopenharmony_civ3[arr];
444514f5e3Sopenharmony_ciprint("test successful !!!");
454514f5e3Sopenharmony_ci
464514f5e3Sopenharmony_civar obj1 = {
474514f5e3Sopenharmony_ci    0: 0,
484514f5e3Sopenharmony_ci    2147483647: 1,
494514f5e3Sopenharmony_ci    2147483648: 2,
504514f5e3Sopenharmony_ci    4294967295: 3,
514514f5e3Sopenharmony_ci    4294967296: 4,
524514f5e3Sopenharmony_ci}
534514f5e3Sopenharmony_ci
544514f5e3Sopenharmony_cifor (let item in obj1) {
554514f5e3Sopenharmony_ci    print(item + " " + obj1[item]);
564514f5e3Sopenharmony_ci}
574514f5e3Sopenharmony_ci// test ic
584514f5e3Sopenharmony_civar lineStr = "方舟ArK TypeScript RuntimekTS运行时(ARK TypeScript Runtime)K TypeScript Runtime是OppeScript RK TypeScripK TypeScript Runtimet Runtimeuntime)是OpeK TypeScript RuntimenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配enHarmonypeScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配上ArkTS应用使用peScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配的运行时。包含ArkTS/JS对象的分配器以及垃圾回收器(GC)、符合ECMAScript规范的标准库、用于运行ARK前端组件生成的方舟字节码(ARK Bytecode简称abc)的解释器、用于加速的内联缓存、静态类型编译器、运行时的C++/C函数接口(NAPI)等模块.";
594514f5e3Sopenharmony_civar str = "方舟ArkTS运行时(ARK TypeScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配器以及垃圾回收器(GC)、符合ECMAScript规范的标准库、用于运行ARK前端组件生成的方舟字节码(ARK Bytecode简称abc)的解释器、用于加速的内联缓存、静态类型编译器、运行时的C++/C函数接口(NAPI)等模块.";
604514f5e3Sopenharmony_cistr += str;
614514f5e3Sopenharmony_cistr += str;
624514f5e3Sopenharmony_cistr += str;
634514f5e3Sopenharmony_civar c;
644514f5e3Sopenharmony_civar l;
654514f5e3Sopenharmony_civar strC;
664514f5e3Sopenharmony_cifor (let i = 0; i < 100; i++) {
674514f5e3Sopenharmony_ci    strC = str.split("C");
684514f5e3Sopenharmony_ci    c = str[i];
694514f5e3Sopenharmony_ci    l = str.length;
704514f5e3Sopenharmony_ci    strC = lineStr.split("C");
714514f5e3Sopenharmony_ci    c = lineStr[i];
724514f5e3Sopenharmony_ci    l = lineStr.length;
734514f5e3Sopenharmony_ci}
744514f5e3Sopenharmony_civar strObj = new String("方舟ArkTS运行时(ARK TypeScript Runtime)是OpenHarmony上ArkTS应用使用的运行时。包含ArkTS/JS对象的分配器以及垃圾回收器(GC)、符合ECMAScript规范的标准库、用于运行ARK前端组件生成的方舟字节码(ARK Bytecode简称abc)的解释器、用于加速的内联缓存、静态类型编译器、运行时的C++/C函数接口(NAPI)等模块.");
754514f5e3Sopenharmony_cifor (let i = 0; i < 100; i++) {
764514f5e3Sopenharmony_ci    strC = strObj.split("C");
774514f5e3Sopenharmony_ci    c = strObj[i];
784514f5e3Sopenharmony_ci    l = strObj.length;
794514f5e3Sopenharmony_ci}
804514f5e3Sopenharmony_ci
814514f5e3Sopenharmony_ci
824514f5e3Sopenharmony_cifor (let i = 0; i < 100; i++) {
834514f5e3Sopenharmony_ci    let arr = [0];
844514f5e3Sopenharmony_ci    arr[0] = arr;
854514f5e3Sopenharmony_ci}
864514f5e3Sopenharmony_ciprint("load ic by COWArray Success")
874514f5e3Sopenharmony_ci
884514f5e3Sopenharmony_cifunction g(o, v) {
894514f5e3Sopenharmony_ci    let res;
904514f5e3Sopenharmony_ci    for (let i = 0; i < 100; i++) {
914514f5e3Sopenharmony_ci        res = o[1];
924514f5e3Sopenharmony_ci        if (res != v) {
934514f5e3Sopenharmony_ci            print("Error ",res);
944514f5e3Sopenharmony_ci        }
954514f5e3Sopenharmony_ci    }
964514f5e3Sopenharmony_ci    return res;
974514f5e3Sopenharmony_ci}
984514f5e3Sopenharmony_ci{
994514f5e3Sopenharmony_ci    let pro = [1,1,1,1];
1004514f5e3Sopenharmony_ci    let o = {
1014514f5e3Sopenharmony_ci        __proto__: pro };
1024514f5e3Sopenharmony_ci    o[102500] = 1;
1034514f5e3Sopenharmony_ci    o["test"] = "test";
1044514f5e3Sopenharmony_ci    print(g(o, 1));
1054514f5e3Sopenharmony_ci    Object.defineProperty(o, "1", { value: 2 });
1064514f5e3Sopenharmony_ci    print("change")
1074514f5e3Sopenharmony_ci    print(g(o, 2));
1084514f5e3Sopenharmony_ci}
1094514f5e3Sopenharmony_ci{
1104514f5e3Sopenharmony_ci    let pro = new Uint8Array(10);
1114514f5e3Sopenharmony_ci    pro[1]=1;
1124514f5e3Sopenharmony_ci    let o = {
1134514f5e3Sopenharmony_ci        __proto__: pro };
1144514f5e3Sopenharmony_ci    o[102500] = 1;
1154514f5e3Sopenharmony_ci    o["test"] = "test";
1164514f5e3Sopenharmony_ci    print(g(o, 1));
1174514f5e3Sopenharmony_ci    Object.defineProperty(o, "1", { value: 2 });
1184514f5e3Sopenharmony_ci    print("change")
1194514f5e3Sopenharmony_ci    print(g(o, 2));
1204514f5e3Sopenharmony_ci}
1214514f5e3Sopenharmony_ciprint("ic load success");
122