提交 80894ed0 编写于 作者: 杜庆泉's avatar 杜庆泉

增加部分测试示例

上级 c0567af5
......@@ -217,6 +217,14 @@ export function testNumber() : Result {
expect(bStr12.length).toEqual(21);
expect(bStr12.substring(0,14)).toEqual("27373a86ba1a19");
// #ifdef APP-ANDROID
expect((new UTSNumber(2709954670497349.5)).toString()).toEqual("2709954670497349.5");
expect((new UTSNumber(0.00000000000001)).toString()).toEqual("1e-14");
expect((new UTSNumber(0.000001)).toString()).toEqual("0.000001");
expect((new UTSNumber(0.0000001)).toString()).toEqual("1e-7");
expect((new UTSNumber(100000000000000000000.0)).toString()).toEqual("100000000000000000000");
expect((new UTSNumber(1000000000000000000000.0)).toString()).toEqual("1e21");
// #endif
})
test('valueOf', () => {
......
......@@ -13,6 +13,31 @@ export function testUTSJSONObject() : Result {
console.log(UTSJSONObject.keys(obj))
})
test('toJSONObject', () => {
// #ifdef APP-ANDROID
let result = {}
result["opt"] = "xxxx"
let subArray = [] as Array<UTSJSONObject>
let subModel = {}
subModel["name"] = "xxx"
subModel["type"] = 0
subArray.push(subModel)
let service = {}
service["name"] = "0xxxb34fb"
service["type"] = 0
//这个数据返回为空对象数组
service["array"] = subArray
result["service"] = service
expect(result.toJSONObject().toJSONString()).toEqual('{"opt":"xxxx","service":{"array":[{"name":"xxx","type":0}],"name":"0xxxb34fb","type":0}}');
// #endif
})
test('assign-notype', () => {
// #ifdef APP-ANDROID
const target = { a: 1, b: 2 };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册