提交 3de775b0 编写于 作者: lizhongyi_'s avatar lizhongyi_

调整部分测试例

上级 05d1943d
...@@ -323,8 +323,9 @@ export function testJSON() : Result { ...@@ -323,8 +323,9 @@ export function testJSON() : Result {
const json = `{"result":true, "count":42}`; const json = `{"result":true, "count":42}`;
const obj = JSON.parse(json) as UTSJSONObject; const obj = JSON.parse(json) as UTSJSONObject;
let retStr = JSON.stringify(obj) let retStr = JSON.stringify(obj)
// #ifdef APP-ANDROID
expect(retStr).toEqual('{"result":true,"count":42}') expect(retStr).toEqual('{"result":true,"count":42}')
// #endif
}) })
test('parse Map', () => { test('parse Map', () => {
......
...@@ -59,14 +59,14 @@ export function testNumber() : Result { ...@@ -59,14 +59,14 @@ export function testNumber() : Result {
expect(isFinite(1000 / 1)).toEqual(true); expect(isFinite(1000 / 1)).toEqual(true);
expect(isFinite(910)).toEqual(true); expect(isFinite(910)).toEqual(true);
expect(isFinite(0)).toEqual(true); expect(isFinite(0)).toEqual(true);
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
let aNumber = aj2['a'] as UTSNumber let aNumber = aj2['a'] as UTSNumber
expect(isFinite(aNumber)).toEqual(true); expect(isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(aNumber)).toEqual(true); expect(UTSNumber.isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(11.00)).toEqual(true); expect(UTSNumber.isFinite(11.00)).toEqual(true);
expect(UTSNumber.isFinite(Double.POSITIVE_INFINITY)).toEqual(false); expect(UTSNumber.isFinite(Double.POSITIVE_INFINITY)).toEqual(false);
// #endif
}) })
test('number-from-json-parse', () => { test('number-from-json-parse', () => {
...@@ -78,6 +78,7 @@ export function testNumber() : Result { ...@@ -78,6 +78,7 @@ export function testNumber() : Result {
expect(aj?.a == 1 as number).toEqual(true); expect(aj?.a == 1 as number).toEqual(true);
expect(aj?.a == 1.0).toEqual(true); expect(aj?.a == 1.0).toEqual(true);
expect(aj?.a == 1.0 as number).toEqual(true); expect(aj?.a == 1.0 as number).toEqual(true);
// #ifdef APP-ANDROID
expect(aj?.a === 1).toEqual(true); expect(aj?.a === 1).toEqual(true);
expect(aj?.a === 1 as number).toEqual(true); expect(aj?.a === 1 as number).toEqual(true);
expect(aj?.a === 1.0).toEqual(true); expect(aj?.a === 1.0).toEqual(true);
...@@ -110,6 +111,8 @@ export function testNumber() : Result { ...@@ -110,6 +111,8 @@ export function testNumber() : Result {
let aj2 = JSON.parse<A>('{"a":1}'); let aj2 = JSON.parse<A>('{"a":1}');
expect(aj?.a == aj2?.a).toEqual(true); expect(aj?.a == aj2?.a).toEqual(true);
// #endif
}) })
...@@ -122,7 +125,7 @@ export function testNumber() : Result { ...@@ -122,7 +125,7 @@ export function testNumber() : Result {
test('isNaN', () => { test('isNaN', () => {
expect(isNaN(0)).toEqual(false); expect(isNaN(0)).toEqual(false);
// #ifdef APP-ANDROID
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
let aNumber = aj2['a'] as UTSNumber let aNumber = aj2['a'] as UTSNumber
expect(isNaN(aNumber)).toEqual(false); expect(isNaN(aNumber)).toEqual(false);
...@@ -130,6 +133,7 @@ export function testNumber() : Result { ...@@ -130,6 +133,7 @@ export function testNumber() : Result {
expect(UTSNumber.isNaN(11)).toEqual(false); expect(UTSNumber.isNaN(11)).toEqual(false);
expect(UTSNumber.isNaN(null)).toEqual(false); expect(UTSNumber.isNaN(null)).toEqual(false);
expect(UTSNumber.isNaN(1 / 0)).toEqual(false); expect(UTSNumber.isNaN(1 / 0)).toEqual(false);
// #endif
}) })
test('toPrecision', () => { test('toPrecision', () => {
......
...@@ -27,6 +27,7 @@ export function testUTSJSONObject() : Result { ...@@ -27,6 +27,7 @@ export function testUTSJSONObject() : Result {
}) })
test('setvalue-after-get', () => { test('setvalue-after-get', () => {
// #ifdef APP-ANDROID
let obj = { let obj = {
"cars":[ "cars":[
{ {
...@@ -35,12 +36,12 @@ export function testUTSJSONObject() : Result { ...@@ -35,12 +36,12 @@ export function testUTSJSONObject() : Result {
} }
] ]
} }
let cars = obj.getArray<UTSJSONObject>("cars") let cars = obj.getArray<UTSJSONObject>("cars")
cars![0].set("value",20) cars![0].set("value",20)
let firstCar = obj.getJSON("cars[0]") let firstCar = obj.getJSON("cars[0]")
expect(firstCar!['value']).toEqual(20); expect(firstCar!['value']).toEqual(20);
// #endif
}) })
test('assign-withtype', () => { test('assign-withtype', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册