From 1966782b7619fbf669862c785f92cb793f0b7918 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Fri, 21 Jul 2023 18:51:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E9=83=A8=E5=88=86=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uts-tests/utssdk/Array.uts | 10 +++++++++- uni_modules/uts-tests/utssdk/Date.uts | 8 ++++++++ uni_modules/uts-tests/utssdk/Map.uts | 13 +++++++------ uni_modules/uts-tests/utssdk/Matchers.uts | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/Array.uts b/uni_modules/uts-tests/utssdk/Array.uts index 786072c..1bc62ee 100644 --- a/uni_modules/uts-tests/utssdk/Array.uts +++ b/uni_modules/uts-tests/utssdk/Array.uts @@ -278,7 +278,15 @@ export function testArray(): Result { expect(array1.unshift(4, 5)).toEqual(5); expect(array1).toEqual([4, 5, 1, 2, 3]); }) - + test("toString", () => { + const array1: number[] = [1, 2, 3]; + expect(array1.toString()).toEqual("1,2,3"); + const array2 = new Array() + array2.push("a") + array2.push("b") + array2.push("c") + expect(array2.toString()).toEqual("a,b,c"); + }) test('reverse', () => { // const array1: string[] = ['one', 'two', 'three']; // const reversed1: string[] = array1.reverse(); diff --git a/uni_modules/uts-tests/utssdk/Date.uts b/uni_modules/uts-tests/utssdk/Date.uts index d5c734b..0073f8b 100644 --- a/uni_modules/uts-tests/utssdk/Date.uts +++ b/uni_modules/uts-tests/utssdk/Date.uts @@ -23,6 +23,14 @@ export function testDate() : Result { expect(unixTimeZero.toString()).toEqual("Thu Jan 01 1970 08:00:00 GMT+0800"); expect(javaScriptRelease.toString()).toEqual("Mon Dec 04 1995 08:12:00 GMT+0800"); }) + test('toTimeString', () => { + const date1 = new Date('01 Jan 1970 00:00:00 GMT'); + const date2 = new Date('December 17, 1995 03:24:00'); + + expect(date1.toTimeString()).toEqual("08:00:00 GMT+0800"); + expect(date2.toTimeString()).toEqual("03:24:00 GMT+0800"); + }) + test('getDate', () => { const birthday = new Date('August 19, 1975 23:15:30'); const date1 = birthday.getDate(); diff --git a/uni_modules/uts-tests/utssdk/Map.uts b/uni_modules/uts-tests/utssdk/Map.uts index 76f7125..5da7d8a 100644 --- a/uni_modules/uts-tests/utssdk/Map.uts +++ b/uni_modules/uts-tests/utssdk/Map.uts @@ -58,12 +58,13 @@ export function testMap(): Result { expect(map3.get(333)).toEqual(333); // ios不支持链式调用 // myMap.set(1, 'foobar').set(2, 'baz'); - const map4 = new Map(); - const key1 = {}, key2 = {}; - map4.set(key1, '1') - map4.set(key2, '2') - expect(map4.get(key1)).toEqual('1'); - expect(map4.get(key2)).toEqual('2'); + // const map4 = new Map(); + // key 不支持对象 + // const key1 = {}, key2 = {}; + // map4.set(key1, '1') + // map4.set(key2, '2') + // expect(map4.get(key1)).toEqual('1'); + // expect(map4.get(key2)).toEqual('2'); const map5 = new Map([['key1', 'value1'], ['key2', 'value2']]); expect(map5.get('key1')).toEqual('value1'); expect(map5.get('key2')).toEqual('value2'); diff --git a/uni_modules/uts-tests/utssdk/Matchers.uts b/uni_modules/uts-tests/utssdk/Matchers.uts index 94b45f7..d51e8f0 100644 --- a/uni_modules/uts-tests/utssdk/Matchers.uts +++ b/uni_modules/uts-tests/utssdk/Matchers.uts @@ -9,7 +9,7 @@ export class Matchers { return } // #ifndef APP-IOS - // throw new Error(format(expected, this.actual)) + throw new Error(format(expected, this.actual)) // #endif // #ifdef APP-IOS NSException(name = NSExceptionName.internalInconsistencyException, reason = format(expected, this.actual)).raise() -- GitLab