diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index a4f35372764da20bd2e6772cc88fd3ee8539f3f4..9ec72538d68e1ea87a4a59cdc296030bc10b627b 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.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('{"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 f22f3224345e6d9fac3523cb69618de4d6716772..ec76f32c82571912c12a12410b8a71e2daa0ccd7 100644 --- a/uni_modules/uts-tests/utssdk/KeyWord.uts +++ b/uni_modules/uts-tests/utssdk/KeyWord.uts @@ -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())).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);