From 0c909097e540c765231c279fb3db7100a11c5237 Mon Sep 17 00:00:00 2001 From: duqingquan Date: Sat, 9 Sep 2023 16:42:14 +0800 Subject: [PATCH] add some case --- uni_modules/uts-tests/utssdk/JSON.uts | 13 +++++++++++++ uni_modules/uts-tests/utssdk/KeyWord.uts | 4 ++-- uni_modules/uts-tests/utssdk/Number.uts | 6 ++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 5810e5e..79ef731 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 37fef58..ba7ae3f 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 bd72af1..3920eeb 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); -- GitLab