14514f5e3Sopenharmony_ci/* 24514f5e3Sopenharmony_ci * Copyright (c) 2024 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:split 184514f5e3Sopenharmony_ci * @tc.desc:test String.split 194514f5e3Sopenharmony_ci * @tc.type: FUNC 204514f5e3Sopenharmony_ci * @tc.require: issueI8SXEG 214514f5e3Sopenharmony_ci */ 224514f5e3Sopenharmony_ci 234514f5e3Sopenharmony_citry { 244514f5e3Sopenharmony_ci ("X").split("00QP", -32297n); 254514f5e3Sopenharmony_ci} catch (e) { 264514f5e3Sopenharmony_ci print(e); 274514f5e3Sopenharmony_ci} 284514f5e3Sopenharmony_ci 294514f5e3Sopenharmony_ci// Test String.prototype.split and cache 304514f5e3Sopenharmony_ciconst shortString = "ababaabcdefaaaaab"; 314514f5e3Sopenharmony_ciconst shortTwoBytesString = "\u0429\u0428\u0428\u0429\u0429\u0428\u0429\u0429\u0429"; 324514f5e3Sopenharmony_ciconst longString = new Array(200).fill("abcdef").join(''); 334514f5e3Sopenharmony_ciconst longTwoBytesString = new Array(200).fill("\u0426\u0427\u0428\u0429\u0430").join(''); 344514f5e3Sopenharmony_cilet res1 = shortString.split(''); 354514f5e3Sopenharmony_cilet res2 = shortString.split(''); 364514f5e3Sopenharmony_ciprint(res1.length) 374514f5e3Sopenharmony_ciprint(res1.length == res2.length); 384514f5e3Sopenharmony_ciprint(res1[0] == res2[0]); 394514f5e3Sopenharmony_cilet res3 = longString.split(''); 404514f5e3Sopenharmony_cilet res4 = longString.split(''); 414514f5e3Sopenharmony_ciprint(res3.length) 424514f5e3Sopenharmony_ciprint(res3.length == res4.length); 434514f5e3Sopenharmony_ciprint(res3[0] == res4[0]); 444514f5e3Sopenharmony_cilet res5 = shortTwoBytesString.split(''); 454514f5e3Sopenharmony_cilet res6 = shortTwoBytesString.split(''); 464514f5e3Sopenharmony_ciprint(res5.length) 474514f5e3Sopenharmony_ciprint(res5.length == res6.length); 484514f5e3Sopenharmony_ciprint(res5[0] == res6[0]); 494514f5e3Sopenharmony_cilet res7 = longTwoBytesString.split(''); 504514f5e3Sopenharmony_cilet res8 = longTwoBytesString.split(''); 514514f5e3Sopenharmony_ciprint(res7.length) 524514f5e3Sopenharmony_ciprint(res7.length == res8.length); 534514f5e3Sopenharmony_ciprint(res7[0] == res8[0]); 544514f5e3Sopenharmony_cilet res9 = shortString.split('a'); 554514f5e3Sopenharmony_cilet res10 = shortString.split('a'); 564514f5e3Sopenharmony_ciprint(res9.length) 574514f5e3Sopenharmony_ciprint(res9.length == res10.length); 584514f5e3Sopenharmony_ciprint(res9[0] == res10[0]); 594514f5e3Sopenharmony_cilet res11 = longString.split('a'); 604514f5e3Sopenharmony_cilet res12 = longString.split('a'); 614514f5e3Sopenharmony_ciprint(res11.length) 624514f5e3Sopenharmony_ciprint(res11.length == res12.length); 634514f5e3Sopenharmony_ciprint(res11[0] == res12[0]); 644514f5e3Sopenharmony_cilet res13 = shortTwoBytesString.split('\u0429'); 654514f5e3Sopenharmony_cilet res14 = shortTwoBytesString.split('\u0429'); 664514f5e3Sopenharmony_ciprint(res13.length) 674514f5e3Sopenharmony_ciprint(res13.length == res14.length); 684514f5e3Sopenharmony_ciprint(res13[0] == res14[0]); 694514f5e3Sopenharmony_cilet res15 = longTwoBytesString.split('\u0429'); 704514f5e3Sopenharmony_cilet res16 = longTwoBytesString.split('\u0429'); 714514f5e3Sopenharmony_ciprint(res15.length) 724514f5e3Sopenharmony_ciprint(res15.length == res16.length); 734514f5e3Sopenharmony_ciprint(res15[0] == res16[0]); 744514f5e3Sopenharmony_ci 754514f5e3Sopenharmony_ci// Test split string is tree string 764514f5e3Sopenharmony_civar a = "12345678910" 774514f5e3Sopenharmony_civar b = "12345678910" 784514f5e3Sopenharmony_civar c = a.concat(b); 794514f5e3Sopenharmony_cic.split("") 804514f5e3Sopenharmony_ci 814514f5e3Sopenharmony_ci// Test split string is sliced string 824514f5e3Sopenharmony_civar d = a.slice(4) 834514f5e3Sopenharmony_cid.split("")