mirror of
https://github.com/cocos/cocos-engine.git
synced 2026-09-07 00:02:53 +08:00
* 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
36 lines
1017 B
TypeScript
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>;
|
|
|