1/* 2 * Copyright (c) 2024 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// This test need set ECMASCRIPT_ENABLE_ELEMENTSKIND_ALWAY_GENERIC to 1 18// update build.gn to enable elements_kind_generic test, and disable elements_kind test 19 20 21let GENERIC = 31; 22 23 24 25function test1() { 26 let a = [1, 2, 34]; 27 if (a[0] == 1 && a[1] == 2 && a[2] == 34 && ArkTools.getElementsKind(a) == GENERIC) { 28 print("test1 - success"); 29 } else { 30 print("test1 - failed"); 31 } 32} 33 34 35 36function test2() { 37 let a = [1, 2, 34]; 38 a[1] = 10; 39 if (a[0] == 1 && a[1] == 10 && a[2] == 34 && ArkTools.getElementsKind(a) == GENERIC) { 40 print("test2 - success"); 41 } else { 42 print("test2 - failed"); 43 } 44} 45 46 47 48 49function test3() { 50 let a = [1, 2, 34]; 51 print(a[10]); 52 if (a[0] == 1 && a[1] == 2 && a[2] == 34 && ArkTools.getElementsKind(a) == GENERIC) { 53 print("test3 - success"); 54 } else { 55 print("test3 - failed"); 56 } 57} 58 59 60 61 62function test4() { 63 let a = [1, 2, 34]; 64 print(a[10]); 65 a[1] = 10; 66 if (a[0] == 1 && a[1] == 10 && a[2] == 34 && ArkTools.getElementsKind(a) == GENERIC) { 67 print("test4 - success"); 68 } else { 69 print("test4 - failed"); 70 } 71} 72 73 74 75function test5() { 76 let a = [1.5, 3.5, 6.7]; 77 if (a[0] == 1.5 && a[1] == 3.5 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 78 print("test5 - success"); 79 } else { 80 print("test5 - failed"); 81 } 82} 83 84 85 86function test6() { 87 let a = [1.5, 3.5, 6.7]; 88 a[1] = 8.8; 89 if (a[0] == 1.5 && a[1] == 8.8 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 90 print("test6 - success"); 91 } else { 92 print("test6 - failed"); 93 } 94} 95 96 97 98 99function test7() { 100 let a = [1.5, 3.5, 6.7]; 101 print(a[10]); 102 if (a[0] == 1.5 && a[1] == 3.5 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 103 print("test7 - success"); 104 } else { 105 print("test7 - failed"); 106 } 107} 108 109 110 111 112function test8() { 113 let a = [1.5, 3.5, 6.7]; 114 print(a[10]); 115 a[1] = 8.8; 116 if (a[0] == 1.5 && a[1] == 8.8 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 117 print("test8 - success"); 118 } else { 119 print("test8 - failed"); 120 } 121} 122 123 124 125function test9() { 126 let a = [1.5, 3, 6.7]; 127 if (a[0] == 1.5 && a[1] == 3 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 128 print("test9 - success"); 129 } else { 130 print("test9 - failed"); 131 } 132} 133 134 135 136function test10() { 137 let a = [1.5, 3, 6.7]; 138 a[0] = 2; 139 if (a[0] == 2 && a[1] == 3 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 140 print("test10 - success"); 141 } else { 142 print("test10 - failed"); 143 } 144} 145 146 147 148 149function test11() { 150 let a = [1.5, 3, 6.7]; 151 print(a[10]); 152 if (a[0] == 1.5 && a[1] == 3 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 153 print("test11 - success"); 154 } else { 155 print("test11 - failed"); 156 } 157} 158 159 160 161 162function test12() { 163 let a = [1.5, 3, 6.7]; 164 print(a[10]); 165 a[0] = 2; 166 if (a[0] == 2 && a[1] == 3 && a[2] == 6.7 && ArkTools.getElementsKind(a) == GENERIC) { 167 print("test12 - success"); 168 } else { 169 print("test12 - failed"); 170 } 171} 172 173 174 175function test13() { 176 let a = ["o", "p", "q"]; 177 if (a[0] == "o" && a[1] == "p" && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 178 print("test13 - success"); 179 } else { 180 print("test13 - failed"); 181 } 182} 183 184 185 186function test14() { 187 let a = ["o", "p", "q"]; 188 a[0] = "x"; 189 if (a[0] == "x" && a[1] == "p" && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 190 print("test14 - success"); 191 } else { 192 print("test14 - failed"); 193 } 194} 195 196 197 198 199function test15() { 200 let a = ["o", "p", "q"]; 201 print(a[10]); 202 if (a[0] == "o" && a[1] == "p" && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 203 print("test15 - success"); 204 } else { 205 print("test15 - failed"); 206 } 207} 208 209 210 211 212function test16() { 213 let a = ["o", "p", "q"]; 214 print(a[10]); 215 a[0] = "x"; 216 if (a[0] == "x" && a[1] == "p" && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 217 print("test16 - success"); 218 } else { 219 print("test16 - failed"); 220 } 221} 222 223 224 225function test17() { 226 let a = [1, , 5]; 227 if (a[0] == 1 && a[1] == undefined && a[2] == 5 && ArkTools.getElementsKind(a) == GENERIC) { 228 print("test17 - success"); 229 } else { 230 print("test17 - failed"); 231 } 232} 233 234 235 236function test18() { 237 let a = [1.5, , 5.6]; 238 if (a[0] == 1.5 && a[1] == undefined && a[2] == 5.6 && ArkTools.getElementsKind(a) == GENERIC) { 239 print("test18 - success"); 240 } else { 241 print("test18 - failed"); 242 } 243} 244 245 246 247 248function test19() { 249 let a = [1, , 5]; 250 print(a[10]); 251 if (a[0] == 1 && a[1] == undefined && a[2] == 5 && ArkTools.getElementsKind(a) == GENERIC) { 252 print("test19 - success"); 253 } else { 254 print("test19 - failed"); 255 } 256} 257 258 259 260 261function test20() { 262 let a = [1.5, , 5.6]; 263 print(a[10]); 264 if (a[0] == 1.5 && a[1] == undefined && a[2] == 5.6 && ArkTools.getElementsKind(a) == GENERIC) { 265 print("test20 - success"); 266 } else { 267 print("test20 - failed"); 268 } 269} 270 271 272 273function test21() { 274 let a = [1, , 5]; 275 a[0] = 2; 276 if (a[0] == 2 && a[1] == undefined && a[2] == 5 && ArkTools.getElementsKind(a) == GENERIC) { 277 print("test21 - success"); 278 } else { 279 print("test21 - failed"); 280 } 281} 282 283 284 285function test22() { 286 let a = [1.5, , 5.6]; 287 a[0] = 2.2; 288 if (a[0] == 2.2 && a[1] == undefined && a[2] == 5.6 && ArkTools.getElementsKind(a) == GENERIC) { 289 print("test22 - success"); 290 } else { 291 print("test22 - failed"); 292 } 293} 294 295 296 297 298function test23() { 299 let a = [1, , 5]; 300 print(a[10]); 301 a[0] = 2; 302 if (a[0] == 2 && a[1] == undefined && a[2] == 5 && ArkTools.getElementsKind(a) == GENERIC) { 303 print("test23 - success"); 304 } else { 305 print("test23 - failed"); 306 } 307} 308 309 310 311 312function test24() { 313 let a = [1.5, , 5.6]; 314 print(a[10]); 315 a[0] = 2.2; 316 if (a[0] == 2.2 && a[1] == undefined && a[2] == 5.6 && ArkTools.getElementsKind(a) == GENERIC) { 317 print("test24 - success"); 318 } else { 319 print("test24 - failed"); 320 } 321} 322 323 324 325function test25() { 326 let a = [1, , 5]; 327 if (a[1] != undefined) { 328 print("test25 - failed: a[1] should be undefined"); 329 return; 330 } 331 a[1] = 2; 332 if (a[1] != 2) { 333 print("test25 - failed: store value to GENERIC spot failed"); 334 } 335 if (a[0] == 1 && a[1] == 2 && a[2] == 5 && ArkTools.getElementsKind(a) == GENERIC) { 336 print("test25 - success"); 337 } else { 338 print("test25 - failed"); 339 } 340} 341 342 343 344function test26() { 345 let a = [1.5, , 5.6]; 346 if (a[1] != undefined) { 347 print("test26 - failed: a[1] should be undefined"); 348 return; 349 } 350 a[1] = 2.2; 351 if (a[1] != 2.2) { 352 print("test26 - failed: store value to GENERIC spot failed"); 353 } 354 if (a[0] == 1.5 && a[1] == 2.2 && a[2] == 5.6 && ArkTools.getElementsKind(a) == GENERIC) { 355 print("test26 - success"); 356 } else { 357 print("test26 - failed"); 358 } 359} 360 361 362 363 364function test27() { 365 let a = [1, , 5]; 366 if (a[1] != undefined) { 367 print("test27 - failed: a[1] should be undefined"); 368 return; 369 } 370 a[1] = 2; 371 print(a[10]); 372 if (a[1] != 2) { 373 print("test27 - failed: store value to GENERIC spot failed"); 374 } 375 if (a[0] == 1 && a[1] == 2 && a[2] == 5 && ArkTools.getElementsKind(a) == GENERIC) { 376 print("test27 - success"); 377 } else { 378 print("test27 - failed"); 379 } 380} 381 382 383 384 385function test28() { 386 let a = [1.5, , 5.6]; 387 if (a[1] != undefined) { 388 print("test28 - failed: a[1] should be undefined"); 389 return; 390 } 391 a[1] = 2.2; 392 print(a[10]); 393 if (a[1] != 2.2) { 394 print("test28 - failed: store value to GENERIC spot failed"); 395 } 396 if (a[0] == 1.5 && a[1] == 2.2 && a[2] == 5.6 && ArkTools.getElementsKind(a) == GENERIC) { 397 print("test28 - success"); 398 } else { 399 print("test28 - failed"); 400 } 401} 402 403 404 405function test29() { 406 let a = [1, , 5.1]; 407 if (a[0] == 1 && a[1] == undefined && a[2] == 5.1 && ArkTools.getElementsKind(a) == GENERIC) { 408 print("test29 - success"); 409 } else { 410 print("test29 - failed"); 411 } 412} 413 414 415 416function test30() { 417 let a = ["o", , "q"]; 418 if (a[0] == "o" && a[1] == undefined && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 419 print("test30 - success"); 420 } else { 421 print("test30 - failed"); 422 } 423} 424 425 426 427 428function test31() { 429 let a = [1, , 5.1]; 430 print(a[10]); 431 if (a[0] == 1 && a[1] == undefined && a[2] == 5.1 && ArkTools.getElementsKind(a) == GENERIC) { 432 print("test31 - success"); 433 } else { 434 print("test31 - failed"); 435 } 436} 437 438 439 440 441function test32() { 442 let a = ["o", , "q"]; 443 print(a[10]); 444 if (a[0] == "o" && a[1] == undefined && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 445 print("test32 - success"); 446 } else { 447 print("test32 - failed"); 448 } 449} 450 451 452 453function test33() { 454 let a = [1, , 5.1]; 455 a[0] = 2; 456 if (a[0] == 2 && a[1] == undefined && a[2] == 5.1 && ArkTools.getElementsKind(a) == GENERIC) { 457 print("test33 - success"); 458 } else { 459 print("test33 - failed"); 460 } 461} 462 463 464 465function test34() { 466 let a = ["o", , "q"]; 467 a[0] = "x"; 468 if (a[0] == "x" && a[1] == undefined && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 469 print("test34 - success"); 470 } else { 471 print("test34 - failed"); 472 } 473} 474 475 476 477 478function test35() { 479 let a = [1, , 5.1]; 480 print(a[10]); 481 a[0] = 2; 482 if (a[0] == 2 && a[1] == undefined && a[2] == 5.1 && ArkTools.getElementsKind(a) == GENERIC) { 483 print("test35 - success"); 484 } else { 485 print("test35 - failed"); 486 } 487} 488 489 490 491 492function test36() { 493 let a = ["o", , "q"]; 494 print(a[10]); 495 a[0] = "x"; 496 if (a[0] == "x" && a[1] == undefined && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 497 print("test36 - success"); 498 } else { 499 print("test36 - failed"); 500 } 501} 502 503 504 505function test37() { 506 let a = [1, , 5.6]; 507 if (a[1] != undefined) { 508 print("test37 - failed: a[1] should be undefined"); 509 return; 510 } 511 a[1] = 2; 512 if (a[1] != 2) { 513 print("test37 - failed: store value to GENERIC spot failed"); 514 } 515 if (a[0] == 1 && a[1] == 2 && a[2] == 5.6 && ArkTools.getElementsKind(a) == GENERIC) { 516 print("test37 - success"); 517 } else { 518 print("test37 - failed"); 519 } 520} 521 522 523 524function test38() { 525 let a = ["o", , "q"]; 526 if (a[1] != undefined) { 527 print("test38 - failed: a[1] should be undefined"); 528 return; 529 } 530 a[1] = "p"; 531 if (a[1] != "p") { 532 print("test38 - failed: store value to GENERIC spot failed"); 533 } 534 if (a[0] == "o" && a[1] == "p" && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 535 print("test38 - success"); 536 } else { 537 print("test38 - failed"); 538 } 539} 540 541 542 543 544function test39() { 545 let a = [1, , 5.1]; 546 if (a[1] != undefined) { 547 print("test39 - failed: a[1] should be undefined"); 548 return; 549 } 550 a[1] = 2; 551 print(a[10]); 552 if (a[1] != 2) { 553 print("test39 - failed: store value to GENERIC spot failed"); 554 } 555 if (a[0] == 1 && a[1] == 2 && a[2] == 5.1 && ArkTools.getElementsKind(a) == GENERIC) { 556 print("test39 - success"); 557 } else { 558 print("test39 - failed"); 559 } 560} 561 562 563 564 565function test40() { 566 let a = ["o", , "q"]; 567 if (a[1] != undefined) { 568 print("test40 - failed: a[1] should be undefined"); 569 return; 570 } 571 a[1] = "p"; 572 print(a[10]); 573 if (a[1] != "p") { 574 print("test40 - failed: store value to GENERIC spot failed"); 575 } 576 if (a[0] == "o" && a[1] == "p" && a[2] == "q" && ArkTools.getElementsKind(a) == GENERIC) { 577 print("test40 - success"); 578 } else { 579 print("test40 - failed"); 580 } 581} 582 583 584 585function test41() { 586 let a = [1, 2, 3]; 587 if (a[0] != 1 || a[1] != 2 || a[2] != 3) { 588 print("test41 - failed"); 589 } 590 a[1] = 2.5; 591 if (a[0] == 1 && a[1] == 2.5 && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 592 print("test41 - success"); 593 } else { 594 print("test41 - failed"); 595 } 596} 597 598 599function test42() { 600 let a = [1, 2, 3]; 601 a[1] = 2.5; 602 if (a[0] == 1 && a[1] == 2.5 && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 603 print("test42 - success"); 604 } else { 605 print("test42 - failed"); 606 } 607} 608 609 610 611function test43() { 612 let a = [1, 2, 3]; 613 a[0] = 4; 614 a[1] = 2.5; 615 if (a[0] == 4 && a[1] == 2.5 && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 616 print("test43 - success"); 617 } else { 618 print("test43 - failed"); 619 } 620} 621 622 623 624function test44() { 625 let a = [1, 2, 3]; 626 if (a[0] != 1 || a[1] != 2 || a[2] != 3) { 627 print("test44 - failed"); 628 } 629 a[1] = "1"; 630 if (a[0] == 1 && a[1] == "1" && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 631 print("test44 - success"); 632 } else { 633 print("test44 - failed"); 634 } 635} 636 637 638function test45() { 639 let a = [1, 2.2, 3]; 640 if (a[0] != 1 || a[1] != 2.2 || a[2] != 3) { 641 print("test45 - failed"); 642 } 643 a[1] = 2; 644 if (a[0] == 1 && a[1] == 2 && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 645 print("test45 - success"); 646 } else { 647 print("test45 - failed"); 648 } 649} 650 651 652function test46() { 653 let a = [1, 2.2, 3]; 654 if (a[0] != 1 || a[1] != 2.2 || a[2] != 3) { 655 print("test46 - failed"); 656 } 657 a[1] = "2"; 658 if (a[0] == 1 && a[1] == "2" && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 659 print("test46 - success"); 660 } else { 661 print("test46 - failed"); 662 } 663} 664 665 666function test47() { 667 let a = [1, 2, 3]; 668 if (a[0] != 1 || a[1] != 2 || a[2] != 3) { 669 print("test47 - failed"); 670 } 671 a[1] = "2"; 672 if (a[0] == 1 && a[1] == "2" && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 673 print("test47 - success"); 674 } else { 675 print("test47 - failed"); 676 } 677} 678 679 680 681 682function test48() { 683 let a = [1, "2"]; 684 if (a[0] != 1 || a[1] != "2") { 685 print("test48 - failed"); 686 } 687 a[1] = 2; 688 if (a[0] == 1 && a[1] == 2 && ArkTools.getElementsKind(a) == GENERIC) { 689 print("test48 - success"); 690 } else { 691 print("test48 - failed"); 692 } 693} 694 695 696function test49() { 697 let a = [1, "2"]; 698 if (a[0] != 1 || a[1] != "2") { 699 print("test49 - failed"); 700 } 701 a[0] = "1"; 702 if (a[0] == "1" && a[1] == "2" && ArkTools.getElementsKind(a) == GENERIC) { 703 print("test49 - success"); 704 } else { 705 print("test49 - failed"); 706 } 707} 708 709 710 711function test50() { 712 let a = [1, , 3] 713 if (a[0] != 1 || a[1] != undefined || a[2] != 3) { 714 print("test50 - failed"); 715 } 716 a[0] = "1"; 717 if (a[0] == "1" && a[1] == undefined && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 718 print("test50 - success"); 719 } else { 720 print("test50 - failed"); 721 } 722} 723 724 725 726function test51() { 727 let a = [1, , 3] 728 a[0] = "1"; 729 if (a[0] == "1" && a[1] == undefined && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 730 print("test51 - success"); 731 } else { 732 print("test51 - failed"); 733 } 734} 735 736 737 738function test52() { 739 let a = [1, , 3] 740 if (a[0] != 1 || a[1] != undefined || a[2] != 3) { 741 print("test52 - failed"); 742 } 743 a[0] = 2.2; 744 if (a[0] == 2.2 && a[1] == undefined && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 745 print("test52 - success"); 746 } else { 747 print("test52 - failed"); 748 } 749} 750 751 752 753function test53() { 754 let a = [1, , 3] 755 a[0] = 2.2; 756 if (a[0] == 2.2 && a[1] == undefined && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 757 print("test53 - success"); 758 } else { 759 print("test53 - failed"); 760 } 761} 762 763 764 765function test54() { 766 let a = [1.1, , 3.3] 767 if (a[0] != 1.1 || a[1] != undefined || a[2] != 3.3) { 768 print("test54 - failed"); 769 } 770 a[0] = "1"; 771 if (a[0] == "1" && a[1] == undefined && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 772 print("test54 - success"); 773 } else { 774 print("test54 - failed"); 775 } 776} 777 778 779 780function test55() { 781 let a = [1.1, , 3.3] 782 a[0] = "1"; 783 if (a[0] == "1" && a[1] == undefined && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 784 print("test55 - success"); 785 } else { 786 print("test55 - failed"); 787 } 788} 789 790 791 792function test56() { 793 let a = [1, , 3.3] 794 if (a[0] != 1 || a[1] != undefined || a[2] != 3.3) { 795 print("test56 - failed"); 796 } 797 a[0] = "1"; 798 if (a[0] == "1" && a[1] == undefined && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 799 print("test56 - success"); 800 } else { 801 print("test56 - failed"); 802 } 803} 804 805 806 807function test57() { 808 let a = [1, , 3.3] 809 a[0] = "1"; 810 if (a[0] == "1" && a[1] == undefined && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 811 print("test57 - success"); 812 } else { 813 print("test57 - failed"); 814 } 815} 816 817 818 819 820function test58() { 821 let a = [1, , 3] 822 if (a[0] != 1 || a[1] != undefined || a[2] != 3) { 823 print("test58 - failed"); 824 } 825 a[1] = 2.2; 826 if (a[0] == 1 && a[1] == 2.2 && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 827 print("test58 - success"); 828 } else { 829 print("test58 - failed"); 830 } 831} 832 833 834 835 836function test59() { 837 let a = [1, , 3] 838 a[1] = 2.2; 839 if (a[0] == 1 && a[1] == 2.2 && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 840 print("test59 - success"); 841 } else { 842 print("test59 - failed"); 843 } 844} 845 846 847 848 849function test60() { 850 let a = [1, , 3] 851 if (a[0] != 1 || a[1] != undefined || a[2] != 3) { 852 print("test60 - failed"); 853 } 854 a[1] = "2"; 855 if (a[0] == 1 && a[1] == "2" && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 856 print("test60 - success"); 857 } else { 858 print("test60 - failed"); 859 } 860} 861 862 863 864 865function test61() { 866 let a = [1, , 3] 867 a[1] = "2"; 868 if (a[0] == 1 && a[1] == "2" && a[2] == 3 && ArkTools.getElementsKind(a) == GENERIC) { 869 print("test61 - success"); 870 } else { 871 print("test61 - failed"); 872 } 873} 874 875 876 877 878function test62() { 879 let a = [1.1, , 3.3] 880 if (a[0] != 1.1 || a[1] != undefined || a[2] != 3.3) { 881 print("test62 - failed"); 882 } 883 a[1] = 2; 884 if (a[0] == 1.1 && a[1] == 2 && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 885 print("test62 - success"); 886 } else { 887 print("test62 - failed"); 888 } 889} 890 891 892 893 894function test63() { 895 let a = [1.1, , 3.3] 896 a[1] = 2; 897 if (a[0] == 1.1 && a[1] == 2 && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 898 print("test63 - success"); 899 } else { 900 print("test63 - failed"); 901 } 902} 903 904 905 906 907function test64() { 908 let a = [1.1, , 3.3] 909 if (a[0] != 1.1 || a[1] != undefined || a[2] != 3.3) { 910 print("test64 - failed"); 911 } 912 a[1] = "2"; 913 if (a[0] == 1.1 && a[1] == "2" && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 914 print("test64 - success"); 915 } else { 916 print("test64 - failed"); 917 } 918} 919 920 921 922 923function test65() { 924 let a = [1.1, , 3.3] 925 a[1] = "2"; 926 if (a[0] == 1.1 && a[1] == "2" && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 927 print("test65 - success"); 928 } else { 929 print("test65 - failed"); 930 } 931} 932 933 934 935 936function test66() { 937 let a = [1, , 3.3] 938 if (a[0] != 1 || a[1] != undefined || a[2] != 3.3) { 939 print("test66 - failed"); 940 } 941 a[1] = "2"; 942 if (a[0] == 1 && a[1] == "2" && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 943 print("test66 - success"); 944 } else { 945 print("test66 - failed"); 946 } 947} 948 949 950 951 952function test67() { 953 let a = [1, , 3.3] 954 a[1] = "2"; 955 if (a[0] == 1 && a[1] == "2" && a[2] == 3.3 && ArkTools.getElementsKind(a) == GENERIC) { 956 print("test67 - success"); 957 } else { 958 print("test67 - failed"); 959 } 960} 961 962 963 964 965function test68() { 966 let a = [1, , "3"]; 967 if (a[0] != 1 || a[1] != undefined || a[2] != "3") { 968 print("test68 - failed"); 969 } 970 a[0] = "1"; 971 a[1] = "2"; 972 if (a[0] == "1" && a[1] == "2" && a[2] == "3" && ArkTools.getElementsKind(a) == GENERIC) { 973 print("test68 - success"); 974 } else { 975 print("test68 - failed"); 976 } 977} 978 979 980 981 982function test69() { 983 let a = [1, , "3"]; 984 a[0] = "1"; 985 a[1] = "2"; 986 if (a[0] == "1" && a[1] == "2" && a[2] == "3" && ArkTools.getElementsKind(a) == GENERIC) { 987 print("test69 - success"); 988 } else { 989 print("test69 - failed"); 990 } 991} 992 993 994 995function test70() { 996 let a = [1, 2, 3]; 997 let result = "Output: " + a; 998 let expected = "Output: 1,2,3"; 999 if (result == expected) { 1000 print("test70 - success"); 1001 } else { 1002 print("test70 - failed"); 1003 } 1004} 1005 1006 1007 1008function test71() { 1009 let a = [1.1, 2.2, 3.3]; 1010 let result = "Output: " + a; 1011 let expected = "Output: 1.1,2.2,3.3"; 1012 if (result == expected) { 1013 print("test71 - success"); 1014 } else { 1015 print("test71 - failed"); 1016 } 1017} 1018 1019 1020 1021function test72() { 1022 let a = [1, 2.2, 3.3]; 1023 let result = "Output: " + a; 1024 let expected = "Output: 1,2.2,3.3"; 1025 if (result == expected) { 1026 print("test72 - success"); 1027 } else { 1028 print("test72 - failed"); 1029 } 1030} 1031 1032 1033 1034function test73() { 1035 let a = [1, , 3]; 1036 let result = "Output: " + a; 1037 let expected = "Output: 1,,3"; 1038 if (result == expected) { 1039 print("test73 - success"); 1040 } else { 1041 print("test73 - failed"); 1042 } 1043} 1044 1045 1046 1047function test74() { 1048 let a = [1.1, , 3.3]; 1049 let result = "Output: " + a; 1050 let expected = "Output: 1.1,,3.3"; 1051 if (result == expected) { 1052 print("test74 - success"); 1053 } else { 1054 print("test74 - failed"); 1055 } 1056} 1057 1058 1059 1060function test75() { 1061 let a = [1, , 3.3]; 1062 let result = "Output: " + a; 1063 let expected = "Output: 1,,3.3"; 1064 if (result == expected) { 1065 print("test75 - success"); 1066 } else { 1067 print("test75 - failed"); 1068 } 1069} 1070 1071 1072 1073function test76() { 1074 let a = [1, 2, 3]; 1075 a[1] = 2.2; 1076 let result = "Output: " + a; 1077 let expected = "Output: 1,2.2,3"; 1078 if (result == expected) { 1079 print("test76 - success"); 1080 } else { 1081 print("test76 - failed"); 1082 } 1083} 1084 1085 1086 1087function test77() { 1088 let a = [1, 2, 3]; 1089 a[1] = "2"; 1090 let result = "Output: " + a; 1091 let expected = "Output: 1,2,3"; 1092 if (result == expected) { 1093 print("test77 - success"); 1094 } else { 1095 print("test77 - failed"); 1096 } 1097} 1098 1099 1100 1101function test78() { 1102 let a = [1.1, 2.2, 3.3]; 1103 a[1] = "2.2"; 1104 let result = "Output: " + a; 1105 let expected = "Output: 1.1,2.2,3.3"; 1106 if (result == expected) { 1107 print("test78 - success"); 1108 } else { 1109 print("test78 - failed"); 1110 } 1111} 1112 1113 1114 1115function test79() { 1116 let a = [1, 2.2, 3.3]; 1117 a[1] = "2"; 1118 let result = "Output: " + a; 1119 let expected = "Output: 1,2,3.3"; 1120 if (result == expected) { 1121 print("test79 - success"); 1122 } else { 1123 print("test79 - failed"); 1124 } 1125} 1126 1127 1128 1129function test80() { 1130 let a = [1, , 3]; 1131 a[1] = 2; 1132 let result = "Output: " + a; 1133 let expected = "Output: 1,2,3"; 1134 if (result == expected) { 1135 print("test80 - success"); 1136 } else { 1137 print("test80 - failed"); 1138 } 1139} 1140 1141 1142 1143function test81() { 1144 let a = [1, , 3.3]; 1145 a[1] = 2.2; 1146 let result = "Output: " + a; 1147 let expected = "Output: 1,2.2,3.3"; 1148 if (result == expected) { 1149 print("test81 - success"); 1150 } else { 1151 print("test81 - failed"); 1152 } 1153} 1154 1155 1156 1157function test82() { 1158 let a = ["1", "2", "3"]; 1159 let result = "Output: " + a; 1160 let expected = "Output: 1,2,3"; 1161 if (result == expected) { 1162 print("test82 - success"); 1163 } else { 1164 print("test82 - failed"); 1165 } 1166} 1167 1168 1169 1170function test83() { 1171 let a = ["1", , "3"]; 1172 a[1] = "2"; 1173 let result = "Output: " + a; 1174 let expected = "Output: 1,2,3"; 1175 if (result == expected) { 1176 print("test83 - success"); 1177 } else { 1178 print("test83 - failed"); 1179 } 1180} 1181 1182 1183function test84() { 1184 let a = new Array(5); 1185 if (ArkTools.getElementsKind(a) == GENERIC) { 1186 print("test84 - success"); 1187 } else { 1188 print("test84 - failed"); 1189 } 1190} 1191 1192function test85() { 1193 let a = new Array(1, 2, 3); 1194 if (ArkTools.getElementsKind(a) == GENERIC) { 1195 print("test85 - success"); 1196 } else { 1197 print("test85 - failed"); 1198 } 1199} 1200 1201function test86() { 1202 let a = new Array(1, 1.5, 3); 1203 if (ArkTools.getElementsKind(a) == GENERIC) { 1204 print("test86 - success"); 1205 } else { 1206 print("test86 - failed"); 1207 } 1208} 1209 1210function test87() { 1211 let a = new Array("1", 1.5, 3); 1212 if (ArkTools.getElementsKind(a) == GENERIC) { 1213 print("test87 - success"); 1214 } else { 1215 print("test87 - failed"); 1216 } 1217} 1218 1219function test88() { 1220 let a = new Array("1", "2", "3"); 1221 if (ArkTools.getElementsKind(a) == GENERIC) { 1222 print("test88 - success"); 1223 } else { 1224 print("test88 - failed"); 1225 } 1226} 1227 1228function test89() { 1229 let a = Array.of(1, 2, 3); 1230 if (a.length == 3 && ArkTools.getElementsKind(a) == GENERIC) { 1231 print("test89 - success"); 1232 } else { 1233 print("test89 - failed"); 1234 } 1235} 1236 1237function test90() { 1238 let a = Array.of(3); 1239 if (a.length == 1 && ArkTools.getElementsKind(a) == GENERIC) { 1240 print("test90 - success"); 1241 } else { 1242 print("test90 - failed"); 1243 } 1244} 1245 1246 1247 1248function test91() { 1249 let result = 0; 1250 function NotArray(len) { 1251 result = len; 1252 } 1253 1254 let a = Array.of.call(NotArray, 1, 2, 3); 1255 if (result == 3 && a.length == 3 && ArkTools.getElementsKind(a) == GENERIC) { 1256 print("test91 - success"); 1257 } else { 1258 print("test91 - failed"); 1259 } 1260} 1261 1262 1263function test92() { 1264 const num1 = [1, 2, 3]; 1265 const num2 = [4, 5, 6]; 1266 1267 const a = num1.concat(num2); 1268 if (a.length == 6 && ArkTools.getElementsKind(a) == GENERIC) { 1269 print("test92 - success"); 1270 } else { 1271 print("test92 - failed"); 1272 } 1273} 1274 1275function test93() { 1276 const num1 = [1, 2, 3]; 1277 const num2 = [4.4, 5.5, 6.6]; 1278 1279 const a = num1.concat(num2); 1280 if (a.length == 6 && ArkTools.getElementsKind(a) == GENERIC) { 1281 print("test93 - success"); 1282 } else { 1283 print("test93 - failed"); 1284 } 1285} 1286 1287function test94() { 1288 let a = [1, , 3].concat([4, 5]); 1289 if (a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1290 print("test94 - success"); 1291 } else { 1292 print("test94 - failed"); 1293 } 1294} 1295 1296function test95() { 1297 let a = [1, , 3].concat([4, 5]); 1298 if (a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1299 print("test95 - success"); 1300 } else { 1301 print("test95 - failed"); 1302 } 1303} 1304 1305function test96() { 1306 const obj1 = { 0: 1, 1: 2, 2: 3, length: 3 }; 1307 const obj2 = { 0: 1, 1: 2, 2: 3, length: 3, [Symbol.isConcatSpreadable]: true }; 1308 let a = [0].concat(obj1, obj2); 1309 if (a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1310 print("test96 - success"); 1311 } else { 1312 print("test96 - failed"); 1313 } 1314} 1315 1316 1317function test97() { 1318 let a = [1, 2, 3, 4, 5].copyWithin(0, 3); 1319 if (a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1320 print("test97 - success"); 1321 } else { 1322 print("test97 - failed"); 1323 } 1324} 1325 1326function test98() { 1327 let a = [1, , 3].copyWithin(2, 1, 2); 1328 if (a.length == 3 && ArkTools.getElementsKind(a) == GENERIC) { 1329 print("test98 - success"); 1330 } else { 1331 print("test98 - failed"); 1332 } 1333} 1334 1335 1336function test99() { 1337 const a = ["a", "b", "c"]; 1338 let i = 0; 1339 let flag = true; 1340 for (const [index, element] of a.entries()) { 1341 if (element != a[i]) { 1342 flag = false; 1343 } 1344 i++; 1345 } 1346 if (flag) { 1347 print("test99 - success"); 1348 } else { 1349 print("test99 - failed"); 1350 } 1351} 1352 1353 1354function test100() { 1355 const isBelowThreshold = (currentValue) => currentValue < 40; 1356 const array1 = [1, 30, 39, 29, 10, 13]; 1357 1358 if (array1.every(isBelowThreshold)) { 1359 print("test100 - success"); 1360 } else { 1361 print("test100 - failed"); 1362 } 1363} 1364 1365 1366function test101() { 1367 const array1 = [1, 2, 3, 4]; 1368 1369 array1.fill(0, 2, 4); 1370 1371 if (array1.length == 4 && ArkTools.getElementsKind(array1) == GENERIC){ 1372 print("test101 - success"); 1373 } else { 1374 print("test101 - failed"); 1375 } 1376} 1377 1378function test102() { 1379 const array1 = [1, 2, 3, 4]; 1380 1381 array1.fill(5.5, 1); 1382 1383 if (array1.length == 4 && ArkTools.getElementsKind(array1) == GENERIC){ 1384 print("test102 - success"); 1385 } else { 1386 print("test102 - failed"); 1387 } 1388} 1389 1390function test103() { 1391 const array1 = [1, 2, 3, 4]; 1392 array1.fill("6"); 1393 1394 if (array1.length == 4 && ArkTools.getElementsKind(array1) == GENERIC){ 1395 print("test103 - success"); 1396 } else { 1397 print("test103 - failed"); 1398 } 1399} 1400 1401 1402function test104() { 1403 const words = ['spray', 'elite', 'exuberant', 'destruction', 'present']; 1404 const result = words.filter((word) => word.length > 6); 1405 1406 if (result.length == 3 && ArkTools.getElementsKind(result) == GENERIC){ 1407 print("test104 - success"); 1408 } else { 1409 print("test104 - failed"); 1410 } 1411} 1412 1413function test105() { 1414 const arrayLike = { 1415 length: 3, 1416 0: "a", 1417 1: "b", 1418 2: "c", 1419 3: "a", 1420 }; 1421 let result = Array.prototype.filter.call(arrayLike, (x) => x <= "b"); 1422 1423 if (result.length == 2 && ArkTools.getElementsKind(result) == GENERIC){ 1424 print("test105 - success"); 1425 } else { 1426 print("test105 - failed"); 1427 } 1428} 1429 1430function test106() { 1431 let result = [1, , undefined].filter((x) => x === undefined); 1432 if (result.length == 1 && ArkTools.getElementsKind(result) == GENERIC){ 1433 print("test106 - success"); 1434 } else { 1435 print("test106 - failed"); 1436 } 1437} 1438 1439 1440function test107() { 1441 const array1 = [5, 12, 8, 130, 44]; 1442 const found = array1.find((element) => element > 10); 1443 1444 if (found == 12) { 1445 print("test107 - success"); 1446 } else { 1447 print("test107 - failed"); 1448 } 1449} 1450 1451 1452function test108() { 1453 const array1 = [5, 12, 8, 130, 44]; 1454 const isLargeNumber = (element) => element > 13; 1455 let result = array1.findIndex(isLargeNumber); 1456 1457 if (result == 3) { 1458 print("test108 - success"); 1459 } else { 1460 print("test108 - failed"); 1461 } 1462} 1463 1464 1465function test109() { 1466 const array1 = [5, 12, 50, 130, 44]; 1467 const found = array1.findLast((element) => element > 45); 1468 1469 if (found == 130) { 1470 print("test109 - success"); 1471 } else { 1472 print("test109 - failed"); 1473 } 1474} 1475 1476 1477function test110() { 1478 const array1 = [5, 12, 50, 130, 44]; 1479 const isLargeNumber = (element) => element > 45; 1480 let result = array1.findLastIndex(isLargeNumber); 1481 1482 1483 if (result == 3) { 1484 print("test110 - success"); 1485 } else { 1486 print("test110 - failed"); 1487 } 1488} 1489 1490 1491function test111() { 1492 const arr1 = [0, 1, 2, [3, 4]]; 1493 let result = arr1.flat(); 1494 1495 1496 if (result.length == 5 && ArkTools.getElementsKind(result) == GENERIC) { 1497 print("test111 - success"); 1498 } else { 1499 print("test111 - failed"); 1500 } 1501} 1502 1503function test112() { 1504 const arr2 = [0, 1, [2, [3, [4, 5]]]]; 1505 let result = arr2.flat(); 1506 1507 1508 if (result.length == 4 && ArkTools.getElementsKind(result) == GENERIC) { 1509 print("test112 - success"); 1510 } else { 1511 print("test112 - failed"); 1512 } 1513} 1514 1515function test113() { 1516 const arr2 = [0, 1, [2, [3, [4, 5]]]]; 1517 let result = arr2.flat(2); 1518 1519 1520 if (result.length == 5 && ArkTools.getElementsKind(result) == GENERIC) { 1521 print("test113 - success"); 1522 } else { 1523 print("test113 - failed"); 1524 } 1525} 1526 1527function test114() { 1528 const arr2 = [0, 1, [2, [3, [4, 5]]]]; 1529 let result = arr2.flat(Infinity); 1530 1531 1532 if (result.length == 6 && ArkTools.getElementsKind(result) == GENERIC) { 1533 print("test114 - success"); 1534 } else { 1535 print("test114 - failed"); 1536 } 1537} 1538 1539 1540function test115() { 1541 const arr1 = [1, 2, 1]; 1542 const result = arr1.flatMap((num) => (num === 2 ? [2, 2] : 1)); 1543 1544 if (result.length == 4 && ArkTools.getElementsKind(result) == GENERIC) { 1545 print("test115 - success"); 1546 } else { 1547 print("test115 - failed"); 1548 } 1549} 1550 1551function test116() { 1552 const arr1 = [1, 2, 1]; 1553 const result = arr1.flatMap((num) => (num === 2 ? 2.2 : 1)); 1554 1555 if (result.length == 3 && ArkTools.getElementsKind(result) == GENERIC) { 1556 print("test116 - success"); 1557 } else { 1558 print("test116 - failed"); 1559 } 1560} 1561 1562 1563function test117() { 1564 const array1 = [1, 2, 3]; 1565 let result = 0; 1566 array1.forEach((element) => { result += element; }); 1567 if (result == 6) { 1568 print("test117 - success"); 1569 } else { 1570 print("test117 - failed"); 1571 } 1572} 1573 1574 1575function test118() { 1576 const array1 = [1, 2, 3]; 1577 let result = true; 1578 1579 if (!array1.includes(2) && ArkTools.getElementsKind(array1) == GENERIC) { 1580 result = false; 1581 } 1582 1583 const pets = ['cat', 'dog', 'bat']; 1584 1585 if (!pets.includes('cat')) { 1586 result = false; 1587 } 1588 1589 if (pets.includes('at')) { 1590 result = false; 1591 } 1592 1593 if (result) { 1594 print("test118 - success"); 1595 } else { 1596 print("test118 - failed"); 1597 } 1598} 1599 1600 1601function test119() { 1602 const beasts = ['ant', 'bison', 'camel', 'duck', 'bison']; 1603 let result = true; 1604 let index1 = beasts.indexOf('bison'); 1605 1606 if (index1 != 1) { 1607 result = false; 1608 } 1609 1610 1611 let index2 = beasts.indexOf('bison', 2); 1612 1613 if (index2 != 4) { 1614 result = false; 1615 } 1616 1617 let index3 = beasts.indexOf('giraffe'); 1618 1619 if (index3 != -1) { 1620 result = false; 1621 } 1622 if (result) { 1623 print("test119 - success"); 1624 } else { 1625 print("test119 - failed"); 1626 } 1627} 1628 1629 1630function test120() { 1631 const animals = ['Dodo', 'Tiger', 'Penguin', 'Dodo']; 1632 let result = true; 1633 let index1 = animals.lastIndexOf('Dodo'); 1634 1635 if (index1 != 3) { 1636 result = false; 1637 } 1638 1639 let index2 = animals.lastIndexOf('Tiger'); 1640 1641 if (index2 != 1) { 1642 result = false; 1643 } 1644 if (result) { 1645 print("test120 - success"); 1646 } else { 1647 print("test120 - failed"); 1648 } 1649} 1650 1651 1652function test121() { 1653 const elements = ['Fire', 'Air', 'Water']; 1654 let result = true; 1655 let joined1 = elements.join(); 1656 1657 if (joined1 != "Fire,Air,Water") { 1658 result = false; 1659 } 1660 1661 let joined2 = elements.join(''); 1662 1663 if (joined2 != "FireAirWater") { 1664 result = false; 1665 } 1666 1667 let joined3 = elements.join('-'); 1668 1669 if (joined3 != "Fire-Air-Water") { 1670 result = false; 1671 } 1672 if (result) { 1673 print("test121 - success"); 1674 } else { 1675 print("test121 - failed"); 1676 } 1677} 1678 1679 1680function test122() { 1681 const array1 = [1, 4, 9, 16]; 1682 1683 1684 const map1 = array1.map((x) => x * 2); 1685 1686 1687 if (map1.length == 4 && ArkTools.getElementsKind(map1) == GENERIC) { 1688 print("test122 - success"); 1689 } else { 1690 print("test122 - failed"); 1691 } 1692} 1693 1694function test123() { 1695 const array1 = [1, 4, 9, 16]; 1696 1697 1698 const map1 = array1.map((x) => x * 1.1); 1699 1700 1701 if (map1.length == 4 && ArkTools.getElementsKind(map1) == GENERIC) { 1702 print("test123 - success"); 1703 } else { 1704 print("test123 - failed"); 1705 } 1706} 1707 1708 1709function test124() { 1710 const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato']; 1711 1712 let popResult = plants.pop(); 1713 1714 if (popResult == "tomato" && ArkTools.getElementsKind(plants) == GENERIC) { 1715 print("test124 - success"); 1716 } else { 1717 print("test124 - failed"); 1718 } 1719} 1720 1721function test125() { 1722 const a = [1, 2, 3, 4, 5.5]; 1723 let popResult = a.pop(); 1724 1725 if (popResult == 5.5 && ArkTools.getElementsKind(a) == GENERIC) { 1726 print("test125 - success"); 1727 } else { 1728 print("test125 - failed"); 1729 } 1730} 1731 1732 1733function test126() { 1734 let a = [6, 5, 4, 3, 2, 1]; 1735 let b = a.toSorted(); 1736 if (b.length == 6 && ArkTools.getElementsKind(b) == GENERIC) { 1737 print("test126 - success"); 1738 } else { 1739 print("test126 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(b)); 1740 } 1741} 1742 1743 1744function test127() { 1745 let a = [0, 1, 2]; 1746 a.unshift(-1); 1747 if (a.length == 4 && ArkTools.getElementsKind(a) == GENERIC) { 1748 print("test127 - success"); 1749 } else { 1750 print("test127 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(a)); 1751 } 1752} 1753 1754function test128() { 1755 let a = [0, 1, 2]; 1756 a.unshift(-2, -1); 1757 if (a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1758 print("test128 - success"); 1759 } else { 1760 print("test128 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(a)); 1761 } 1762} 1763 1764function test129() { 1765 1766 let a = [0, 1, 2, 3, 4, 5, 6]; 1767 let b = a.toSpliced(2, 2, 3, 3); 1768 if (b.length == 7 && ArkTools.getElementsKind(b) == GENERIC) { 1769 print("test129 - success"); 1770 } else { 1771 print("test129 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(b)); 1772 } 1773} 1774 1775function test130() { 1776 1777 let a = [0, 1, 2, , 4, 5, 6]; 1778 let b = a.toSpliced(2, 1, 3); 1779 if (b.length == 7 && ArkTools.getElementsKind(b) == GENERIC) { 1780 print("test130 - success"); 1781 } else { 1782 print("test130 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(b)); 1783 } 1784} 1785 1786function test131() { 1787 1788 let a = [0, 1, 2, 3, 4, 5, 6]; 1789 let b = a.toSpliced(2, 1, 3.1); 1790 if (b.length == 7 && ArkTools.getElementsKind(b) == GENERIC) { 1791 print("test131 - success"); 1792 } else { 1793 print("test131 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(b)); 1794 } 1795} 1796 1797function test132() { 1798 1799 let a = [0, 1, 2, 4, 5, 6]; 1800 let b = a.toReversed(); 1801 if (b.length == 6 && ArkTools.getElementsKind(b) == GENERIC) { 1802 print("test132 - success"); 1803 } else { 1804 print("test132 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(b)); 1805 } 1806} 1807 1808function test133() { 1809 1810 let a = [0, 1, 2, , 4, 5, 6]; 1811 let b = a.toReversed(); 1812 if (b.length == 7 && ArkTools.getElementsKind(b) == GENERIC) { 1813 print("test133 - success"); 1814 } else { 1815 print("test133 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(b)); 1816 } 1817} 1818 1819function test134() { 1820 1821 let a = [0, 1, 2, ,4, 5, 6]; 1822 if (a.length == 7 && a.at(2) == 2 && a.at(3) == undefined) { 1823 print("test134 - success"); 1824 } else { 1825 print("test134 - failed, a.At(2): " + a[2] + " , but get: a.At(3): " + a[3]); 1826 } 1827} 1828 1829function test135() { 1830 1831 let a = [0, 1, 2, ,4, 5, 6]; 1832 let b = a.with(3, 6); 1833 if (b.length == 7 && b[3] == 6 && ArkTools.getElementsKind(b) == GENERIC) { 1834 print("test135 - success"); 1835 } else { 1836 print("test135 - failed, expected: " + GENERIC + " , but get: " + ArkTools.getElementsKind(b)); 1837 } 1838} 1839 1840function test136() { 1841 let a = [1, 2, 3, 4, 5]; 1842 a.push(5.5); 1843 if (a.length == 6 && a[5] == 5.5 && ArkTools.getElementsKind(a) == GENERIC) { 1844 print("test136 - success"); 1845 } else { 1846 print("test136 - failed"); 1847 } 1848} 1849 1850function test137() { 1851 let a = [1, 2, 3, 4, 5]; 1852 a.push(undefined); 1853 if (a.length == 6 && a[5] == undefined && ArkTools.getElementsKind(a) == GENERIC) { 1854 print("test137 - success"); 1855 } else { 1856 print("test137 - failed"); 1857 } 1858} 1859 1860function test138() { 1861 let a = [1, 2, , 4, 5]; 1862 1863 const initialValue = 0; 1864 const sumWithInitial = a.reduce( 1865 (accumulator, currentValue) => accumulator + currentValue, 1866 initialValue, 1867 ); 1868 1869 if (sumWithInitial == 12) { 1870 print("test138 - success"); 1871 } else { 1872 print("test138 - failed"); 1873 } 1874} 1875 1876function test139() { 1877 let a = [1, 2, , 4, 5]; 1878 1879 const initialValue = 0; 1880 const sumWithInitial = a.reduceRight( 1881 (accumulator, currentValue) => accumulator + currentValue, 1882 initialValue, 1883 ); 1884 1885 if (sumWithInitial == 12) { 1886 print("test139 - success"); 1887 } else { 1888 print("test139 - failed"); 1889 } 1890} 1891 1892function test140() { 1893 let a = [1, 2, 3, 4, 5]; 1894 a.reverse(); 1895 if (a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1896 print("test140 - success"); 1897 } else { 1898 print("test140 - failed"); 1899 } 1900} 1901 1902function test141() { 1903 let a = [1, 2, , 4, 5]; 1904 a.reverse(); 1905 if (a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1906 print("test141 - success"); 1907 } else { 1908 print("test141 - failed"); 1909 } 1910} 1911 1912function test142() { 1913 1914 let a = [0.1, 1, 2, 3, 4, 5, 6]; 1915 let result = a.shift(); 1916 if (a.length == 6 && result == 0.1 && ArkTools.getElementsKind(a) == GENERIC) { 1917 print("test142 - success"); 1918 } else { 1919 print("test142 - failed"); 1920 } 1921} 1922 1923function test143() { 1924 1925 let a = [0, 1, 2, , 4, 5, 6]; 1926 let result = a.shift(); 1927 if (a.length == 6 && result == 0 && ArkTools.getElementsKind(a) == GENERIC) { 1928 print("test143 - success"); 1929 } else { 1930 print("test143 - failed"); 1931 } 1932} 1933 1934function test144() { 1935 1936 let a = [0, 1, 2, , 4, 5, 6]; 1937 let b = a.slice(); 1938 if (b.length == 7 && ArkTools.getElementsKind(b) == GENERIC) { 1939 print("test144 - success"); 1940 } else { 1941 print("test144 - failed"); 1942 } 1943} 1944 1945function test145() { 1946 let a = [1, , 4, 21, 100000]; 1947 a.sort(); 1948 if (a[0] == 1 && a[1] == 100000 && a.length == 5 && ArkTools.getElementsKind(a) == GENERIC) { 1949 print("test145 - success"); 1950 } else { 1951 print("test145 - failed"); 1952 } 1953} 1954 1955function test146() { 1956 1957 let a = [0, 1, 2, 3, 4, 5, 6]; 1958 a.splice(2, 2, 3, 3); 1959 if (a.length == 7 && ArkTools.getElementsKind(a) == GENERIC) { 1960 print("test146 - success"); 1961 } else { 1962 print("test146 - failed"); 1963 } 1964} 1965 1966function test147() { 1967 1968 let a = [0, 1, 2, , 4, 5, 6]; 1969 a.splice(2, 1, 3); 1970 if (a.length == 7 && ArkTools.getElementsKind(a) == GENERIC) { 1971 print("test147 - success"); 1972 } else { 1973 print("test147 - failed"); 1974 } 1975} 1976 1977 1978test1(); 1979test2(); 1980test3(); 1981test4(); 1982 1983 1984test5(); 1985test6(); 1986test7(); 1987test8(); 1988 1989 1990test9(); 1991test10(); 1992test11(); 1993test12(); 1994 1995 1996test13(); 1997test14(); 1998test15(); 1999test16(); 2000 2001 2002 2003test17(); 2004test18(); 2005test19(); 2006test20(); 2007test21(); 2008test22(); 2009test23(); 2010test24(); 2011test25(); 2012test26(); 2013test27(); 2014test28(); 2015 2016test29(); 2017test30(); 2018test31(); 2019test32(); 2020test33(); 2021test34(); 2022test35(); 2023test36(); 2024test37(); 2025test38(); 2026test39(); 2027test40(); 2028 2029 2030test41(); 2031test42(); 2032test43(); 2033test44(); 2034test45(); 2035test46(); 2036test47(); 2037test48(); 2038test49(); 2039 2040 2041test50(); 2042test51(); 2043test52(); 2044test53(); 2045test54(); 2046test55(); 2047test56(); 2048test57(); 2049test58(); 2050test59(); 2051test60(); 2052test61(); 2053test62(); 2054test63(); 2055test64(); 2056test65(); 2057test66(); 2058test67(); 2059test68(); 2060test69(); 2061 2062 2063test70(); 2064test71(); 2065test72(); 2066test73(); 2067test74(); 2068test75(); 2069test76(); 2070test77(); 2071test78(); 2072test79(); 2073test80(); 2074test81(); 2075test82(); 2076test83(); 2077 2078 2079 2080test84(); 2081test85(); 2082test86(); 2083test87(); 2084test88(); 2085 2086 2087test89(); 2088test90(); 2089test91(); 2090 2091 2092test92(); 2093test93(); 2094test94(); 2095test95(); 2096test96(); 2097 2098 2099test97(); 2100test98(); 2101 2102 2103test99(); 2104 2105 2106test100(); 2107 2108 2109test101(); 2110test102(); 2111test103(); 2112 2113 2114test104(); 2115test105(); 2116test106(); 2117 2118 2119 2120 2121 2122test107(); 2123test108(); 2124test109(); 2125test110(); 2126 2127 2128test111(); 2129test112(); 2130test113(); 2131test114(); 2132 2133 2134test115(); 2135test116(); 2136 2137 2138test117(); 2139 2140 2141test118(); 2142 2143 2144test119(); 2145 2146 2147test120(); 2148 2149 2150test121(); 2151 2152 2153test122(); 2154test123(); 2155 2156 2157test124(); 2158test125(); 2159 2160 2161test126(); 2162 2163 2164test127(); 2165test128(); 2166 2167 2168test129(); 2169test130(); 2170test131(); 2171 2172 2173test132(); 2174test133(); 2175 2176 2177test134(); 2178 2179 2180test135(); 2181 2182 2183test136(); 2184test137(); 2185 2186 2187 2188test138(); 2189test139(); 2190 2191 2192test140(); 2193test141(); 2194 2195 2196test142(); 2197test143(); 2198 2199 2200test144(); 2201 2202 2203test145(); 2204 2205 2206test146(); 2207test147(); 2208 2209 2210class Index { 2211 currentArrays = [ 2212 [0, 0, 0, 0], 2213 [0, 0, 0, 0], 2214 [0, 0, 0, 0], 2215 [0, 0, 0, 0] 2216 ] 2217 2218 changeCurretArrays() { 2219 let newArrays = [ 2220 [0, 0, 0, 0], 2221 [0, 0, 0, 0], 2222 [0, 0, 0, 0], 2223 [0, 0, 0, 0] 2224 ] 2225 2226 for (let j = 0; j < 4; j++) { 2227 for (let i = 0; i < 4; i++) { 2228 newArrays[j][i] = this.currentArrays[j][i] + 1; 2229 } 2230 } 2231 return newArrays; 2232 } 2233 2234 computeScore(array) { 2235 let total = 0; 2236 for (let j = 0; j < 4; j++) { 2237 for (let i = 0; i < 4; i++) { 2238 total += array[j][i]; 2239 } 2240 } 2241 return total; 2242 } 2243 2244 run() { 2245 let newArray = this.changeCurretArrays(); 2246 print(this.computeScore(newArray)); 2247 print(this.computeScore(this.currentArrays)); 2248 this.currentArrays = newArray; 2249 } 2250} 2251 2252let index = new Index; 2253for (let i = 0; i < 3; i++) { 2254 index.run(); 2255} 2256 2257function testLength() { 2258 let a = [0]; 2259 print(ArkTools.getElementsKind(a)); 2260 a.length = 3; 2261 print(ArkTools.getElementsKind(a)); 2262} 2263 2264testLength(); 2265