• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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:arrayjoin
18 * @tc.desc:test Array.join
19 * @tc.type: FUNC
20 * @tc.require: issueI5NO8G
21 */
22let arr = [1, 2, 3, 4];
23arr.fill(42, { toString() { arr.length = 0; } });
24print(arr.length);
25print(arr);
26
27let rawProto = Number.prototype.__proto__;
28Number.prototype.__proto__ = ["tr"];
29let v1 = 1.23;
30v1.fill(7);
31Number.prototype.__proto__ = rawProto
32print("fill Number Obj Success!")
33
34var log = [];
35var fake =
36    {
37      get source() {
38        log.push("p");
39        return {
40          toString: function() {
41            log.push("ps");
42            return "pattern";
43          }
44        };
45      },
46      get flags() {
47        log.push("f");
48        return {
49          toString: function() {
50            log.push("fs");
51            return "flags";
52          }
53        };
54      }
55    }
56RegExp.prototype.toString.call(fake);
57print(JSON.stringify(["p", "ps", "f", "fs"]) == JSON.stringify(log));
58