承载 set_self(spid, 43, n) 的 C 移植调用: - 1 基帧号, FrameIndex=0 按 1 处理(旧引擎 2 个对象如此) - 越界显式抛错(第二准则:不兜底) - 并发去重:多次 setFrame 在加载未完成时只触发一次 loadByPrefix - 命名与 scripts/ui-migration/frames.mjs:frameFileName 公式逐字对齐 分层: - core/frame-file-name.ts 纯公式,无 Cocos 依赖,直接单测 - ui/frame-set.ts 核心逻辑,FrameSource/FrameTarget 注入接口隔离 Cocos 类型 - ui/resources-frame-source.ts 生产实现,Resources.loadDir + Auto Atlas 合图过滤 tsconfig.framework.json 排除 resources-frame-source.ts(其含 cc 模块,走 Cocos 编辑器编译)。 103/103 framework tests pass,typecheck exit 0。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
25 lines
1.2 KiB
TypeScript
25 lines
1.2 KiB
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { frameFileName, padWidth } from '../../YouleNexus/assets/framework/core/frame-file-name.ts';
|
|
|
|
test('padWidth: 9帧→1位,12帧→2位,100帧→3位', () => {
|
|
assert.equal(padWidth(9), 1);
|
|
assert.equal(padWidth(12), 2);
|
|
assert.equal(padWidth(100), 3);
|
|
assert.equal(padWidth(1), 1);
|
|
});
|
|
|
|
test('frameFileName: 1基+补零,字典序 = 帧序', () => {
|
|
assert.equal(frameFileName('atlas-login/00014', 1, 12), 'atlas-login/00014_01.png');
|
|
assert.equal(frameFileName('atlas-login/00014', 10, 12), 'atlas-login/00014_10.png');
|
|
const names = [frameFileName('atlas-login/00014', 2, 12), frameFileName('atlas-login/00014', 10, 12)];
|
|
assert.deepEqual([...names].sort(), ['atlas-login/00014_02.png', 'atlas-login/00014_10.png']);
|
|
});
|
|
|
|
test('frameFileName: FrameIndex=0 按 1 处理(旧引擎 2 个对象如此)', () => {
|
|
assert.equal(frameFileName('atlas-login/00014', 0, 12), 'atlas-login/00014_01.png');
|
|
});
|
|
|
|
test('frameFileName: 单帧图(prefix 不带下划线)直接拼接 .png', () => {
|
|
assert.equal(frameFileName('atlas-login/00019', 1, 1), 'atlas-login/00019.png');
|
|
}); |