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

Merge branch 'dev' of https://gitcode.net/dcloud/hello-uts into dev

# Conflicts:
#	uni_modules/uts-tests/utssdk/KeyWord.uts
......@@ -24,6 +24,16 @@ type PersionJSON = {
/**
* 测试属性名为 原生关键字的场景
*/
type UserWithKeyWord={
class:string;
abstract:number;
is:boolean;
}
export function testJSON() : Result {
return describe("JSON", () => {
test('parse', () => {
......@@ -97,7 +107,10 @@ export function testJSON() : Result {
// p: 10,
// });
expect(JSON.parse('{}')!).toEqual({});
let userKeyWord = JSON.parse<UserWithKeyWord>('{"is":false,"class":"classOne","abstract":12}')
expect(userKeyWord!.class).toEqual("classOne");
// TODO 不支持boolean、string,js端需抹平
// expect(JSON.parse('true')!).toEqual(true);
// expect(JSON.parse('"foo"')!).toEqual("foo");
......
......@@ -22,9 +22,10 @@ export function testKeyWord(): Result {
test('typeof', () => {
let new1 = new User()
expect(typeof(new1)).toEqual('object')
// expect(typeof(123456.789)).toEqual('number')
expect(typeof(123456.789)).toEqual('Double')
//expect(typeof(789778979798797987979)).toEqual('number')
// expect(typeof(0.0)).toEqual('number')
expect(typeof(0.0)).toEqual('Double')
expect(typeof("hello world")).toEqual('string')
expect(typeof([1,2,3])).toEqual('object')
expect(typeof(new Array<any>())).toEqual('object')
......
......@@ -62,6 +62,12 @@ export function testNumber(): Result {
expect(isFinite(910)).toEqual(true);
expect(isFinite(0)).toEqual(true);
})
test('isInteger', () => {
expect(Number.isInteger(12.0)).toEqual(true);
expect(Number.isInteger(12.01)).toEqual(false);
expect(Number.isInteger(-213123112.01)).toEqual(false);
expect(Number.isInteger(-213123112)).toEqual(true);
})
test('isNaN', () => {
expect(isNaN(0)).toEqual(false);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册