提交 1db556f8 编写于 作者: 杜庆泉's avatar 杜庆泉

增加 UTSJSONObject 相关测试示例

上级 8a4262b6
...@@ -22528,7 +22528,7 @@ export function testJSONLarge() : Result { ...@@ -22528,7 +22528,7 @@ export function testJSONLarge() : Result {
console.log('指定类型转换耗时',spendTime,listdata!.length) console.log('指定类型转换耗时',spendTime,listdata!.length)
expect(listdata!.length).toEqual(33); expect(listdata!.length).toEqual(33);
expect(spendTime < 400).toEqual(true); expect(spendTime < 500).toEqual(true);
startTime = System.currentTimeMillis() startTime = System.currentTimeMillis()
let listdata2 = JSON.parse(allStr) let listdata2 = JSON.parse(allStr)
......
import { describe, test, expect, expectNumber, Result } from './tests.uts'
export function testUTSJSONObject() : Result {
return describe("utsjsonobject", () => {
test('keys', () => {
// #ifdef APP-ANDROID
let obj = {
name:"zhangsan",
age:11
}
expect(UTSJSONObject.keys(obj).size).toEqual(2);
console.log(UTSJSONObject.keys(obj))
// #endif
})
test('assign-notype', () => {
// #ifdef APP-ANDROID
const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };
const returnedTarget = UTSJSONObject.assign(target, source);
expect(returnedTarget!.toMap().size).toEqual(3);
console.log(returnedTarget)
// #endif
})
test('assign-withtype', () => {
// #ifdef APP-ANDROID
type User = {
a:number
b:number
}
const target = { a: 1, b: 2 };
const source = { b: 4, c: 5 };
const returnedTarget = UTSJSONObject.assign<User>(target, source);
expect(returnedTarget!.a).toEqual(1);
console.log(returnedTarget)
// #endif
})
})
}
\ No newline at end of file
...@@ -5,6 +5,7 @@ import { testError } from './Error.uts' ...@@ -5,6 +5,7 @@ import { testError } from './Error.uts'
import { testKeyWord } from './KeyWord.uts' import { testKeyWord } from './KeyWord.uts'
import { testJSON } from './JSON.uts' import { testJSON } from './JSON.uts'
import { testJSONLarge } from './JSON_large.uts' import { testJSONLarge } from './JSON_large.uts'
import { testUTSJSONObject } from './UTSJSONObject.uts'
import { testConsole } from './console.uts' import { testConsole } from './console.uts'
import { testNumber } from './Number.uts' import { testNumber } from './Number.uts'
import { testMap } from './Map.uts' import { testMap } from './Map.uts'
...@@ -35,7 +36,8 @@ export function runTests() : UTSJSONObject { ...@@ -35,7 +36,8 @@ export function runTests() : UTSJSONObject {
const GlobalRes = testGlobal(); const GlobalRes = testGlobal();
const TypeRes = testType(); const TypeRes = testType();
const JSONLargeRes = testJSONLarge(); const JSONLargeRes = testJSONLarge();
const consoleRes = testConsole(); const consoleRes = testConsole();
const UTSJSONObjectRes = testUTSJSONObject();
return { return {
Array: ArrayRes, Array: ArrayRes,
Date: DateRes, Date: DateRes,
...@@ -53,6 +55,7 @@ export function runTests() : UTSJSONObject { ...@@ -53,6 +55,7 @@ export function runTests() : UTSJSONObject {
ForLoop: ForLoopRes, ForLoop: ForLoopRes,
Global: GlobalRes, Global: GlobalRes,
Type: TypeRes, Type: TypeRes,
console:consoleRes console:consoleRes,
UTSJSONObject:UTSJSONObjectRes
} }
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册