14514f5e3Sopenharmony_ci/*
24514f5e3Sopenharmony_ci * Copyright (c) 2023 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_cilet arr = [1, 2, 3, 4, 5, 6, 7, 8];
174514f5e3Sopenharmony_ciarr.splice(0, 1, 9)
184514f5e3Sopenharmony_ciprint(arr)
194514f5e3Sopenharmony_ciarr.splice(10, 1)
204514f5e3Sopenharmony_ciprint(arr)
214514f5e3Sopenharmony_ciarr = [1, 2, 3, 4, 5, 6, 7, 8];
224514f5e3Sopenharmony_ciarr.splice(8, 0, 1, 1)
234514f5e3Sopenharmony_ciprint(arr)
244514f5e3Sopenharmony_ciarr.splice(0, 8, 1, 1)
254514f5e3Sopenharmony_ciprint(arr)
264514f5e3Sopenharmony_ciarr = [1, 2, 3, 4, 5, 6, 7, 8];
274514f5e3Sopenharmony_ciarr.splice(1, 8)
284514f5e3Sopenharmony_ciprint(arr)
294514f5e3Sopenharmony_ciarr = new Array(100)
304514f5e3Sopenharmony_ciarr.splice(0, 20)
314514f5e3Sopenharmony_ciprint(arr.length)
324514f5e3Sopenharmony_ci
334514f5e3Sopenharmony_civar array = new Array(10);
344514f5e3Sopenharmony_civar spliced = array.splice(1, 1);
354514f5e3Sopenharmony_cifor (let i = 0; i < array.length; ++i) {
364514f5e3Sopenharmony_ci    print(i in array)
374514f5e3Sopenharmony_ci}
384514f5e3Sopenharmony_civar array1 = new Array(10);
394514f5e3Sopenharmony_civar spliced1 = array1.splice(1, 1, "a", "b");
404514f5e3Sopenharmony_cifor (let i = 0; i < array1.length; ++i) {
414514f5e3Sopenharmony_ci    print(i in array1)
424514f5e3Sopenharmony_ci}
434514f5e3Sopenharmony_ci
444514f5e3Sopenharmony_ciarray = [];
454514f5e3Sopenharmony_cispliced = undefined;
464514f5e3Sopenharmony_cifor (var i = 0; i < 1; i++) {
474514f5e3Sopenharmony_ci    let bad_start = { valueOf: function () { array.push(2 * i); return -1; } };
484514f5e3Sopenharmony_ci    let bad_count = { valueOf: function () { array.push(2 * i + 1); return 1; } };
494514f5e3Sopenharmony_ci    spliced = array.splice(bad_start, bad_count);
504514f5e3Sopenharmony_ci    print("array.length", array.length);
514514f5e3Sopenharmony_ci}
524514f5e3Sopenharmony_cifor (let i = 0; i < 2; i++) {
534514f5e3Sopenharmony_ci    let array = [1, 2, 3, 4];
544514f5e3Sopenharmony_ci    print("array:", array);
554514f5e3Sopenharmony_ci    if (i == 0) {
564514f5e3Sopenharmony_ci        let spliced = array.splice(1, 3, 'one', 'two', 'three');
574514f5e3Sopenharmony_ci    }
584514f5e3Sopenharmony_ci}
594514f5e3Sopenharmony_ci
604514f5e3Sopenharmony_cilet a = 0;
614514f5e3Sopenharmony_ciclass C3 extends Array {
624514f5e3Sopenharmony_ci    constructor(a5, a6, a7, a8) {
634514f5e3Sopenharmony_ci        a++;
644514f5e3Sopenharmony_ci        super(-9223372036854775808, Set);
654514f5e3Sopenharmony_ci        if (a == 1) {
664514f5e3Sopenharmony_ci            this.splice(Array);
674514f5e3Sopenharmony_ci        }
684514f5e3Sopenharmony_ci        return "n"
694514f5e3Sopenharmony_ci    }
704514f5e3Sopenharmony_ci}
714514f5e3Sopenharmony_citry { new C3(C3, Array, Array, C3); } catch (err) {print(err)};