提交 224ac5a0 编写于 作者: 杜庆泉's avatar 杜庆泉

修复Hello uts 因为UTSNumber编译报错的bug

上级 edece136
...@@ -69,11 +69,11 @@ export function testNumber() : Result { ...@@ -69,11 +69,11 @@ export function testNumber() : Result {
expect(isFinite(0)).toEqual(true); expect(isFinite(0)).toEqual(true);
// #ifdef APP-ANDROID // #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 Number
expect(isFinite(aNumber)).toEqual(true); expect(isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(aNumber)).toEqual(true); expect(Number.isFinite(aNumber)).toEqual(true);
expect(UTSNumber.isFinite(11.00)).toEqual(true); expect(Number.isFinite(11.00)).toEqual(true);
expect(UTSNumber.isFinite(Double.POSITIVE_INFINITY)).toEqual(false); expect(Number.isFinite(Double.POSITIVE_INFINITY)).toEqual(false);
// #endif // #endif
}) })
...@@ -138,39 +138,39 @@ export function testNumber() : Result { ...@@ -138,39 +138,39 @@ export function testNumber() : Result {
let a = JSON.parse("1") as Number let a = JSON.parse("1") as Number
a++; a++;
expect(a.toString()).toEqual("2"); expect(a.toString()).toEqual("2");
expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer");
a--; a--;
expect(a.toString()).toEqual("1"); expect(a.toString()).toEqual("1");
expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer");
a /= 0.5; a /= 0.5;
expect(a.toString()).toEqual("2"); expect(a.toString()).toEqual("2");
expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer");
a *= 5; a *= 5;
expect(a.toString()).toEqual("10"); expect(a.toString()).toEqual("10");
expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer");
a += -1; a += -1;
expect(a.toString()).toEqual("9"); expect(a.toString()).toEqual("9");
expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer");
a -= -2; a -= -2;
expect(a.toString()).toEqual("11"); expect(a.toString()).toEqual("11");
expect(UTSAndroid.getJavaClass(a).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(a).name).toEqual("java.lang.Integer");
let a2 = a % 5 let a2 = a % 5
expect(a2.toString()).toEqual("1"); expect(a2.toString()).toEqual("1");
expect(UTSAndroid.getJavaClass(a2).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(a2).name).toEqual("java.lang.Integer");
let b = 12 let b = 12
let c1 = b + a2 let c1 = b + a2
expect(c1.toString()).toEqual("13"); expect(c1.toString()).toEqual("13");
expect(UTSAndroid.getJavaClass(c1).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(c1).name).toEqual("java.lang.Integer");
let c2 = a2 + 2 let c2 = a2 + 2
expect(c2.toString()).toEqual("3"); expect(c2.toString()).toEqual("3");
expect(UTSAndroid.getJavaClass(c2).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(c2).name).toEqual("java.lang.Integer");
let c3 = 2 + a2 let c3 = 2 + a2
expect(c3.toString()).toEqual("3"); expect(c3.toString()).toEqual("3");
expect(UTSAndroid.getJavaClass(c3).name).toEqual("io.dcloud.uts.UTSNumber"); expect(UTSAndroid.getJavaClass(c3).name).toEqual("java.lang.Integer");
// #endif // #endif
...@@ -180,12 +180,12 @@ export function testNumber() : Result { ...@@ -180,12 +180,12 @@ export function testNumber() : Result {
expect(isNaN(0)).toEqual(false); expect(isNaN(0)).toEqual(false);
// #ifdef APP-ANDROID // #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 Number
expect(isNaN(aNumber)).toEqual(false); expect(isNaN(aNumber)).toEqual(false);
expect(UTSNumber.isNaN(aNumber)).toEqual(false); expect(Number.isNaN(aNumber)).toEqual(false);
expect(UTSNumber.isNaN(11)).toEqual(false); expect(Number.isNaN(11)).toEqual(false);
expect(UTSNumber.isNaN(null)).toEqual(false); expect(Number.isNaN(null)).toEqual(false);
expect(UTSNumber.isNaN(1 / 0)).toEqual(false); expect(Number.isNaN(1 / 0)).toEqual(false);
// #endif // #endif
}) })
...@@ -233,8 +233,8 @@ export function testNumber() : Result { ...@@ -233,8 +233,8 @@ export function testNumber() : Result {
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
expect(0.6.toString()).toEqual("0.6"); expect(0.6.toString()).toEqual("0.6");
expect((new UTSNumber(2709954670497349.5)).toString()).toEqual("2709954670497349.5"); expect((2709954670497349.5).toString(10)).toEqual("2709954670497349.5");
expect((new UTSNumber(0.00000000000001)).toString()).toEqual("1e-14"); expect(((0.00000000000001)).toString()).toEqual("1e-14");
expect((new UTSNumber(0.000001)).toString()).toEqual("0.000001"); expect((new UTSNumber(0.000001)).toString()).toEqual("0.000001");
expect((new UTSNumber(0.0000001)).toString()).toEqual("1e-7"); expect((new UTSNumber(0.0000001)).toString()).toEqual("1e-7");
expect((new UTSNumber(100000000000000000000.0)).toString()).toEqual("100000000000000000000"); expect((new UTSNumber(100000000000000000000.0)).toString()).toEqual("100000000000000000000");
......
...@@ -57,7 +57,7 @@ export function testUTSJSONObject() : Result { ...@@ -57,7 +57,7 @@ export function testUTSJSONObject() : Result {
} }
let data2 = JSON.parse<UTSJSONObject>(JSON.stringify(data1)) let data2 = JSON.parse<UTSJSONObject>(JSON.stringify(data1))
expect(data2!.toJSONString()).toEqual('{"str":"test","num":1.0,"num2":2.369}') expect(data2!.toJSONString()).toEqual('{"str":"test","num":1,"num2":2.369}')
class TestData2 implements IJSONStringify{ class TestData2 implements IJSONStringify{
toJSON():any|null{ toJSON():any|null{
......
...@@ -30,7 +30,7 @@ export function testConsole() : Result { ...@@ -30,7 +30,7 @@ export function testConsole() : Result {
let aj2 = JSON.parse('{"a":1}') as UTSJSONObject; let aj2 = JSON.parse('{"a":1}') as UTSJSONObject;
expect(obtainInnerObject(aj2['a']).get("type")).toEqual("number"); expect(obtainInnerObject(aj2['a']).get("type")).toEqual("Int");
expect(obtainInnerObject(aj2['a']).get("subType")).toEqual("number"); expect(obtainInnerObject(aj2['a']).get("subType")).toEqual("number");
// #endif // #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册