Files
cocos-engine/tests/core/serialization/shared/utils.ts
Leslie Leigh (李的序) 705c977fc9 Binary serialization (#8946)
* Binary serialization

* Update snapshots

* Update

* rename option ccon -> useCCON

* Missing script

* encodeCCONJson: chunks -> chunkURLs

* Update

* (de)serializeSymbol -> (de)serializeTag;

* CustomizedSerializable -> CustomSerializable

* _deserializePrimitiveObject -> _fillPlainObject

* Unify CCClass CCClassConstructor

* encodeCCONJson -> parseCCONJson

* Custom serializable

* Move (de)serializeSuper(This) from context into global

* property -> read(write)Property; (de)serializeThis(Super) -> (read)writeThis(Super)

* CI and lint

* Mock cc env
2021-07-15 10:21:25 +08:00

36 lines
1017 B
TypeScript

import { _decorator } from 'cc';
import { Port } from './port';
import ps from 'path';
// @ts-expect-error Virtual module
import { runTest as runTest_ } from 'serialization-test-helper/run-test';
export const runTest: RunTest = runTest_;
export function getCaseName(fileName: string) {
const baseName = ps.basename(fileName, ps.dirname(fileName));
if (baseName.endsWith('.test.ts')) {
return baseName.substr(0, baseName.length - '.test.ts'.length);
} else {
return baseName;
}
}
export const ccclassAutoNamed = (fileName: string): ClassDecorator => {
const caseName = getCaseName(fileName);
return (target) => {
const className = target.name;
const ccName = `${caseName}.${className}`;
return cc._decorator.ccclass(ccName)(target);
};
};
export type RunTest = (
caseModulePath: string,
port: Readonly<Port>,
value: unknown,
verify?: (serialized: any) => void | Promise<void>,
env?: Record<string, any>,
) => Promise<void>;