提交 1966782b 编写于 作者: 杜庆泉's avatar 杜庆泉

补充部分示例

上级 36ab877c
......@@ -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<string>()
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();
......
......@@ -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();
......
......@@ -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<UTSJSONObject,string>();
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<UTSJSONObject,string>();
// 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<string,string>([['key1', 'value1'], ['key2', 'value2']]);
expect(map5.get('key1')).toEqual('value1');
expect(map5.get('key2')).toEqual('value2');
......
......@@ -9,7 +9,7 @@ export class Matchers<T> {
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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册