提交 7a5b31c6 编写于 作者: 杜庆泉's avatar 杜庆泉

增加regexp exec 部分测试示例

上级 72944093
......@@ -231,6 +231,17 @@ export function testRegExp(): Result {
const pattern10 = /(?<!@)\w+/;
const result10 = pattern10.exec('Username: john')!;
expect(result10[0]).toEqual('Username');
const CHUNK_REGEXP =
/^(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?\s*(\S*)?\s*(\d*\.?\d+(?:ms|s)?)?$/
const match2 = CHUNK_REGEXP.exec('none')
expect(match2!![0]).toEqual("none");
expect(match2!![1]).toEqual("none");
expect(JSON.stringify(match2!![2])).toEqual("null");
expect(JSON.stringify(match2!![3])).toEqual("null");
expect(JSON.stringify(match2!![4])).toEqual("null");
})
})
}
......@@ -141,7 +141,8 @@ export function testString(): Result {
const url = '';
const urlRegex = /^(\w+):\/\/([^\/?#]+)([^?#]*)(\?[^#]*)?(#.*)?$/;
const match = url.match(urlRegex);
expect(match).toEqual(null);
expect(JSON.stringify(match)).toEqual("null");
})
test('padEnd', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册