diff --git a/uni_modules/uts-tests/utssdk/JSON.uts b/uni_modules/uts-tests/utssdk/JSON.uts index 1810ee4f1619aaddaaf6e3e8cf54864003dc72c1..00ebc1ed3892262c870c609830d06bfa9ae2578f 100644 --- a/uni_modules/uts-tests/utssdk/JSON.uts +++ b/uni_modules/uts-tests/utssdk/JSON.uts @@ -319,6 +319,12 @@ export function testJSON() : Result { a: 1 }.toMap() expect(map.get('a')).toEqual(1) + + const json = `{"result":true, "count":42}`; + const obj = JSON.parse(json) as UTSJSONObject; + let retStr = JSON.stringify(obj) + expect(retStr).toEqual('{"result":true,"count":42}') + }) test('parse Map', () => { diff --git a/uni_modules/uts-tests/utssdk/Number.uts b/uni_modules/uts-tests/utssdk/Number.uts index a9ab25ee65d71cddf7108825e6e36932a2838f99..29440bb4806b8206ba60c270fe429e5b52dcb77d 100644 --- a/uni_modules/uts-tests/utssdk/Number.uts +++ b/uni_modules/uts-tests/utssdk/Number.uts @@ -60,6 +60,25 @@ export function testNumber() : Result { expect(isFinite(910)).toEqual(true); expect(isFinite(0)).toEqual(true); }) + + test('number-from-json-parse', () => { + type A = { + a:number + } + let aj = JSON.parse('{"a":1}'); + expect(aj?.a == 1).toEqual(true); + expect(aj?.a == 1 as number).toEqual(true); + expect(aj?.a == 1.0).toEqual(true); + expect(aj?.a == 1.0 as number).toEqual(true); + let ki:Int = 1; + let kd:Double = 1.0; + let kf:Float = (1.0).toFloat(); + expect(aj?.a == ki).toEqual(true); + expect(aj?.a == kd).toEqual(true); + expect(aj?.a == kf).toEqual(true); + + }) + test('isInteger', () => { expect(Number.isInteger(12)).toEqual(true); expect(Number.isInteger(12.01)).toEqual(false); diff --git a/uni_modules/uts-tests/utssdk/console.uts b/uni_modules/uts-tests/utssdk/console.uts index 3d8c881e3d655d1d5cbfc8ac61a7f33de0ce9b1f..787979c9cb6cd4a286bbe396ca6c4e3c01faf64d 100644 --- a/uni_modules/uts-tests/utssdk/console.uts +++ b/uni_modules/uts-tests/utssdk/console.uts @@ -21,7 +21,21 @@ export function testConsole() : Result { expect(obtainInnerObject(pageInstance).get("className")).toEqual("io.dcloud.uniapp.vue.ComponentInternalInstance"); expect(obtainInnerObject(pageInstance).get("type")).toEqual("object"); // #endif - } - ) + }) + + test('console-number-from-JSON-parse', () => { + // #ifdef APP-ANDROID + + let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; + console.log(aj2!['a']) + + expect(obtainInnerObject(aj2!['a']).get("type")).toEqual("number"); + expect(obtainInnerObject(aj2!['a']).get("subType")).toEqual("number"); + + // #endif + + }) + }) + } \ No newline at end of file