diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 5810e5e7fca75942d70e1152c663aab9cf322c8a..79ef7318da8e68ad060526e71e7c707914b0be2d 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -7,6 +7,16 @@ type UserJSON={ name:string|null; } +/** + * 测试属性名为 原生关键字的场景 + */ +type UserWithKeyWord={ + class:string; + abstract:number; + is:boolean; +} + + export function testJSON() : Result { return describe("JSON", () => { test('parse', () => { @@ -80,7 +90,10 @@ export function testJSON() : Result { // p: 10, // }); + expect(JSON.parse('{}')!).toEqual({}); + let userKeyWord = JSON.parse('{"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"); diff --git a/uni_modules/uts-tests/utssdk/KeyWord.uts b/uni_modules/uts-tests/utssdk/KeyWord.uts index 37fef5865907b6892fab61a7da427a9e9eb5eed1..ba7ae3f662851cca1650b62b315120558701c0fd 100644 --- a/uni_modules/uts-tests/utssdk/KeyWord.uts +++ b/uni_modules/uts-tests/utssdk/KeyWord.uts @@ -22,9 +22,9 @@ 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())).toEqual('object') diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index bd72af1288fc682f3e0cd24d03ecd864fa5cd271..3920eeb733673650ef73fafb3d9d9774a2debdc4 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -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);