提交 e515ac76 编写于 作者: 雪洛's avatar 雪洛

feat: 屏蔽鸿蒙平台不支持的测试例

上级 cd3f691b
...@@ -89,7 +89,7 @@ export function testJSON() : Result { ...@@ -89,7 +89,7 @@ export function testJSON() : Result {
expect(JSON.stringify(new A3())).toEqual('"json"') expect(JSON.stringify(new A3())).toEqual('"json"')
expect(JSON.stringify(new A4())).toEqual('null') expect(JSON.stringify(new A4())).toEqual('null')
// #ifdef APP-ANDROID || APP-IOS // #ifdef APP-ANDROID || APP-IOS
// js平台toJSON不会递归 // js引擎toJSON不会归调用
expect(JSON.stringify(new A5())!.length).toEqual(28) expect(JSON.stringify(new A5())!.length).toEqual(28)
expect(JSON.stringify(new A6())!.length).toEqual(28) expect(JSON.stringify(new A6())!.length).toEqual(28)
// #endif // #endif
...@@ -236,11 +236,13 @@ export function testJSON() : Result { ...@@ -236,11 +236,13 @@ export function testJSON() : Result {
}`; }`;
let obj3 = JSON.parseObject<UserJSON>(json2); let obj3 = JSON.parseObject<UserJSON>(json2);
expect(obj3!.id).toEqual("30"); expect(obj3!.id).toEqual("30");
// #ifndef APP-HARMONY
const json3 = `{ const json3 = `{
"name": "John" "name": "John"
}`; }`;
let obj4 = JSON.parseObject<UserJSON>(json3); let obj4 = JSON.parseObject<UserJSON>(json3);
expect(obj4).toEqual(null); expect(obj4).toEqual(null);
// #endif
}) })
test('parseArray', () => { test('parseArray', () => {
// #TEST JSON.parseArray // #TEST JSON.parseArray
...@@ -458,6 +460,7 @@ export function testJSON() : Result { ...@@ -458,6 +460,7 @@ export function testJSON() : Result {
}) })
// #ifndef APP-HARMONY
test('invalidField', () => { test('invalidField', () => {
let str = "{\"a+b\":\"test1\",\"a-b\":2,\"class\":true}" let str = "{\"a+b\":\"test1\",\"a-b\":2,\"class\":true}"
let p = JSON.parseObject<PersonJSON>(str) let p = JSON.parseObject<PersonJSON>(str)
...@@ -468,6 +471,7 @@ export function testJSON() : Result { ...@@ -468,6 +471,7 @@ export function testJSON() : Result {
let retStr = JSON.stringify(p) let retStr = JSON.stringify(p)
console.log(retStr) console.log(retStr)
}) })
// #endif
test('UTSJSONOject', () => { test('UTSJSONOject', () => {
let t1 = "1" let t1 = "1"
...@@ -509,7 +513,7 @@ export function testJSON() : Result { ...@@ -509,7 +513,7 @@ export function testJSON() : Result {
num : number, num : number,
} }
const map = JSON.parse<Map<string, A>>(`{"a": {"num": 1}}`) const map = JSON.parse<Map<string, A>>(`{"a": {"num": 1}}`)
// #ifndef APP-IOS // #ifndef APP-IOS || APP-HARMONY
expect(map instanceof Map).toEqual(true) expect(map instanceof Map).toEqual(true)
// #endif // #endif
expect(map?.get('a')?.num).toEqual(1) expect(map?.get('a')?.num).toEqual(1)
......
...@@ -15,7 +15,6 @@ import { testMath } from './Math.uts' ...@@ -15,7 +15,6 @@ import { testMath } from './Math.uts'
import { testRegExp } from './RegExp.uts' import { testRegExp } from './RegExp.uts'
import { testForLoop } from './ForLoop.uts' import { testForLoop } from './ForLoop.uts'
import { testGlobal } from './Global.uts' import { testGlobal } from './Global.uts'
import { testType } from './Type.uts'
export { Result } from './tests.uts' export { Result } from './tests.uts'
import { testNativeCode } from './NativeCode.uts' import { testNativeCode } from './NativeCode.uts'
import { testEncoder } from "./TextEncoder.uts" import { testEncoder } from "./TextEncoder.uts"
...@@ -27,6 +26,7 @@ import { testPromise } from "./Promise.uts" ...@@ -27,6 +26,7 @@ import { testPromise } from "./Promise.uts"
import { testArrayBuffer } from './ArrayBuffer.uts' import { testArrayBuffer } from './ArrayBuffer.uts'
// for of、for in在鸿蒙平台支持度欠佳,或许应该借助编译器拉齐? // for of、for in在鸿蒙平台支持度欠佳,或许应该借助编译器拉齐?
import { testIterator } from "./iterator.uts" import { testIterator } from "./iterator.uts"
import { testType } from './Type.uts'
// #endif // #endif
import { testUTSXXX } from "./UTSXXX.uts" import { testUTSXXX } from "./UTSXXX.uts"
...@@ -45,7 +45,6 @@ export function runTests(): UTSJSONObject { ...@@ -45,7 +45,6 @@ export function runTests(): UTSJSONObject {
const KeyWordRes = testKeyWord(); const KeyWordRes = testKeyWord();
const ForLoopRes = testForLoop(); const ForLoopRes = testForLoop();
const GlobalRes = testGlobal(); const GlobalRes = testGlobal();
const TypeRes = testType();
const JsonRes = testJSON(); const JsonRes = testJSON();
const JSONLargeRes = testJSONLarge(); const JSONLargeRes = testJSONLarge();
const UTSJSONObjectRes = testUTSJSONObject(); const UTSJSONObjectRes = testUTSJSONObject();
...@@ -59,6 +58,7 @@ export function runTests(): UTSJSONObject { ...@@ -59,6 +58,7 @@ export function runTests(): UTSJSONObject {
// #ifndef APP-HARMONY // #ifndef APP-HARMONY
const ArrayBufferRes = testArrayBuffer(); const ArrayBufferRes = testArrayBuffer();
const IteratorRes = testIterator() const IteratorRes = testIterator()
const TypeRes = testType();
// #endif // #endif
const testUTSXXXRes = testUTSXXX() const testUTSXXXRes = testUTSXXX()
return { return {
...@@ -75,7 +75,6 @@ export function runTests(): UTSJSONObject { ...@@ -75,7 +75,6 @@ export function runTests(): UTSJSONObject {
KeyWord: KeyWordRes, KeyWord: KeyWordRes,
ForLoop: ForLoopRes, ForLoop: ForLoopRes,
Global: GlobalRes, Global: GlobalRes,
Type: TypeRes,
console: consoleRes, console: consoleRes,
Json: JsonRes, Json: JsonRes,
JSONLarge: JSONLargeRes, JSONLarge: JSONLargeRes,
...@@ -89,6 +88,7 @@ export function runTests(): UTSJSONObject { ...@@ -89,6 +88,7 @@ export function runTests(): UTSJSONObject {
// #ifndef APP-HARMONY // #ifndef APP-HARMONY
ArrayBuffer: ArrayBufferRes, ArrayBuffer: ArrayBufferRes,
Iterator: IteratorRes, Iterator: IteratorRes,
Type: TypeRes,
// #endif // #endif
UTSXXX: testUTSXXXRes, UTSXXX: testUTSXXXRes,
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册