From eebbfbf6abbed37f3048f989ed9e338dab2c95b8 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Tue, 16 Jul 2024 18:02:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0RegExp=20=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E5=99=A8=E6=B5=8B=E8=AF=95=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/RegExp.uts | 17 +++++++++++++++++ uni_modules/uts-tests/utssdk/String.uts | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/uni_modules/uts-tests/utssdk/RegExp.uts b/uni_modules/uts-tests/utssdk/RegExp.uts index 6440a00..1e2ac9f 100644 --- a/uni_modules/uts-tests/utssdk/RegExp.uts +++ b/uni_modules/uts-tests/utssdk/RegExp.uts @@ -2,6 +2,23 @@ import { describe, test, expect, Result } from './tests.uts' export function testRegExp(): Result { return describe("RegExp", () => { + test("constructor", () => { + // #ifdef APP-ANDROID + const str = 'table football'; + const regex = new RegExp('foo*'); + const globalRegex = new RegExp(); + + expect(regex.test(str)).toEqual(true); + expect(globalRegex.test(str)).toEqual(true); + + let r2 = new RegExp(/ab+c/); + expect(r2.test(str)).toEqual(false); + + let r3 = new RegExp(/foo/); + expect(r3.test(str)).toEqual(true); + // #endif + }) + test("dotAll", () => { const regex1 = new RegExp('foo', 's'); expect(regex1.dotAll).toEqual(true); diff --git a/uni_modules/uts-tests/utssdk/String.uts b/uni_modules/uts-tests/utssdk/String.uts index 693b7e7..9c9d2f3 100644 --- a/uni_modules/uts-tests/utssdk/String.uts +++ b/uni_modules/uts-tests/utssdk/String.uts @@ -56,6 +56,7 @@ export function testString(): Result { expect(empty.charAt(0)).toEqual(""); }) test('toWellFormed', () => { + // #ifdef APP-ANDROID expect("ab\uD800".toWellFormed()).toEqual("ab\uFFFD"); expect("ab\uD800c".toWellFormed()).toEqual("ab\uFFFDc"); expect("\uDFFFab".toWellFormed()).toEqual("\uFFFDab"); @@ -64,8 +65,10 @@ export function testString(): Result { expect("ab\uD83D\uDE04c".toWellFormed()).toEqual("ab\uD83D\uDE04c"); expect("ab\uD83D\uDE04c".toWellFormed()).toEqual("ab\uD83D\uDE04c"); expect("ab\uD83D\uDE04c\uD83D".toWellFormed()).toEqual("ab\uD83D\uDE04c\uFFFD"); + // #endif }) test('isWellFormed', () => { + // #ifdef APP-ANDROID expect("ab\uD800".isWellFormed()).toEqual(false); expect("ab\uD800c".isWellFormed()).toEqual(false); expect("\uDFFFab".isWellFormed()).toEqual(false); @@ -74,6 +77,7 @@ export function testString(): Result { expect("ab\uD83D\uDE04c".isWellFormed()).toEqual(true); expect("ab\uD83D\uDE04c".isWellFormed()).toEqual(true); expect("ab\uD83D\uDE04c\uD83D".isWellFormed()).toEqual(false); + // #endif }) test('charCodeAt', () => { const sentence = 'The quick brown fox jumps over the lazy dog.'; -- GitLab