提交 e79733f3 编写于 作者: lizhongyi_'s avatar lizhongyi_

测试例调整

上级 541b7fa9
......@@ -256,7 +256,7 @@ export function testArray(): Result {
expect(array1).toEqual([1, 100000, 21, 30, 4]);
const array2 = [5, 1, 4, 2, 3];
array2.sort((a: number, b: number):number => a - b);
array2.sort((a, b):Int => a - b);
expect(array2).toEqual([1, 2, 3, 4, 5]);
// const array3 = [5, "banana", 4, "apple", 3, "cherry", 2, "date", 1];
......
......@@ -13,7 +13,7 @@ export function testJSON() : Result {
const json = `{"result":true, "count":42}`;
const obj = JSON.parse(json)!;
expect(obj["count"]).toEqual(42);
expect(obj["result"]).toEqual(true);
expect(obj["result"] as boolean).toEqual(true);
const json1 = `{
"name": "John",
......
......@@ -12,7 +12,7 @@ export class Matchers<T> {
throw new Error(format(expected, this.actual))
// #endif
// #ifdef APP-IOS
NSException(name = NSExceptionName.internalInconsistencyException, reason = format(expected, this.actual)).raise()
// NSException(name = NSExceptionName.internalInconsistencyException, reason = format(expected, this.actual)).raise()
// #endif
}
}
......
......@@ -164,12 +164,12 @@ export function testString(): Result {
const regex = /Dog/i;
expect(p.replace(regex, 'ferret')).toEqual("The quick brown fox jumps over the lazy ferret. If the dog reacted, was it really lazy?");
const str = 'abc12345#$*%';
const replacer = (match:string, p1:string, p2:string, p3:string, offset:number, string:string): string => {
const replacer = (match:string, p: string[], offset:number, string:string): string => {
// p1 is nondigits, p2 digits, and p3 non-alphanumerics
expect(offset).toEqual(0);
expect(match).toEqual(str);
expect(string).toEqual(str);
return [p1, p2, p3].join(' - ');
return p.join(' - ');
}
var newString = str.replace(/([^\d]*)(\d*)([^\w]*)/, replacer);
expect(newString).toEqual("abc - 12345 - #$*%");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册