From f9f69ca36c030a0460d83386b7b217148dd61b06 Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Sat, 7 Sep 2024 12:58:53 +0800 Subject: [PATCH] =?UTF-8?q?[regexp]=E5=8E=BB=E9=99=A4=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E4=B8=AD=E6=89=8B=E5=8A=A8=E7=94=9F=E6=88=90=E7=9A=84=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/JSON.uts | 3 --- uni_modules/uts-tests/utssdk/RegExp.uts | 24 ++++++++++++------------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 68f2153..32cb2da 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -280,9 +280,6 @@ export function testJSON() : Result { console.log(JSON.stringify({ x: 5, y: 6 })); // expected output: "{"x":5,"y":6}" - console.log(JSON.stringify([3, 'false', boolean])); - // expected output: "[3,"false",false]" - console.log(JSON.stringify(new Date(2006, 0, 2, 15, 4, 5))); // expected output: ""2006-01-02T15:04:05.000Z"" // #END diff --git a/uni_modules/uts-tests/utssdk/RegExp.uts b/uni_modules/uts-tests/utssdk/RegExp.uts index 9fed1f4..36c817a 100644 --- a/uni_modules/uts-tests/utssdk/RegExp.uts +++ b/uni_modules/uts-tests/utssdk/RegExp.uts @@ -110,34 +110,37 @@ export function testRegExp() : Result { const result1 = regex.exec(str)!; console.log(result1.index); - console.log(regex.lastIndex); + const ret1 = regex.lastIndex + console.log(ret1); // expected output: // result1.index: 0 // regex.lastIndex: 2 const result2 = regex.exec(str)!; console.log(result2.index); - console.log(regex.lastIndex); + let ret2 = regex.lastIndex + console.log(ret2); // expected output: // result2.index: 3 // regex.lastIndex: 5 const result3 = regex.exec(str)!; console.log(result3.index); - console.log(regex.lastIndex); + let ret3 = regex.lastIndex + console.log(ret3); // expected output: // result3.index: 6 // regex.lastIndex: 8 // #END expect(result1.index).toEqual(0); - expect(regex.lastIndex).toEqual(2); + expect(ret1).toEqual(2); expect(result2.index).toEqual(3); - expect(regex.lastIndex).toEqual(5); + expect(ret2).toEqual(5); expect(result3.index).toEqual(6); - expect(regex.lastIndex).toEqual(8); + expect(ret3).toEqual(8); }); test("multiline", () => { @@ -188,18 +191,15 @@ export function testRegExp() : Result { console.log(regex1.sticky); // expected output: true + let ret = regex1.test(str1) + console.log(ret); + // expected output: true - console.log(regex1.test(str1)); - // expected output: true (the match starts at index 6) - - // Reset the lastIndex to test non-match regex1.lastIndex = 0; console.log(regex1.test(str1)); - // expected output: false (subsequent tests should fail since the lastIndex is at 0) // #END expect(regex1.sticky).toEqual(true); - expect(regex1.test(str1)).toEqual(true); expect(regex1.test(str1)).toEqual(false); }); -- GitLab