• 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:stringSlice
18 * @tc.desc:test String.slice
19 * @tc.type: FUNC
20 * @tc.require: issueI5NO8G
21 */
22
23
24const array1 = ['a', 'b', 'c'];
25const iterator1 = array1.values();
26
27for (const value of iterator1) {
28	  print(value);
29}
30const arrayLike = {
31	  length: 3,
32	  0: "a",
33	  1: "b",
34	  2: "c",
35};
36for (const entry of Array.prototype.values.call(arrayLike)) {
37	  print(entry);
38}
39for (const element of [, "a"].values()) {
40	  print(element);
41}
42const arr = ["a", "b", "c", "d", "e"];
43const iterator = arr.values();
44print(iterator.next().value); // "a"
45arr[1] = "n";
46print(iterator.next().value); // "n"
47const array = ["a", "b", "c", "d", "e"];
48const values = array.values();
49for (const letter of values) {
50	  print(letter);
51	  if (letter === "b") {
52		      break;
53		    }
54}
55for (const letter of values) {
56	  print(letter);
57}
58
59const arr1 = ["a", "b", "c", "d", "e"];
60const values1 = arr1.values();
61for (const letter of values1) {
62	  print(letter);
63}
64for (const letter of values1) {
65	  print(letter);
66}
67