58 lines
1.7 KiB
Markdown
58 lines
1.7 KiB
Markdown
# golden-tests(子模块规范)
|
||
|
||
## 子模块名称
|
||
|
||
golden-tests(Golden Cases 与性质测试)
|
||
|
||
## 目标描述
|
||
|
||
建立可持续的回归体系,保证换行算法满足:
|
||
|
||
- 同输入同输出(确定性)
|
||
- 跨端一致(在固定测量/宽度 profile 下)
|
||
- 规则变更可控(通过 `configVersion` 回溯)
|
||
|
||
本模块产出的是测试数据与测试规则,不产出业务功能。
|
||
|
||
## 输入/输出定义
|
||
|
||
### 输入
|
||
|
||
- Golden Case 集合(建议 JSON/TS fixture):
|
||
- `text`
|
||
- `lang`
|
||
- `context`
|
||
- `availableWidth`
|
||
- `maxLines`
|
||
- `fontSpec?`(APP)
|
||
- `constraints?`
|
||
- `overflowMode?`
|
||
- `configVersion`
|
||
|
||
### 输出
|
||
|
||
- 对每个 case 的期望输出:
|
||
- `expected.lines: string[]`
|
||
- `expected.wrappedText: string`
|
||
- 可选:`expected.meta.breaks`、`expected.meta.fallback_type/overflow_type/reason`
|
||
|
||
并定义性质测试(property tests):
|
||
|
||
- **确定性**:同输入多次调用输出一致
|
||
- **近似单调性**:`availableWidth` 变小不会让任一行变得更宽(在同测量模式下)
|
||
- **maxLines 不变差**:`maxLines` 增加时至少不从可解变 overflow
|
||
|
||
## 验收标准(可验证)
|
||
|
||
- **覆盖度**:
|
||
- 每种语言至少 20 个样例:短/长、含标点/无标点、含 emoji、含 protectedPhrases、含 shift/accum/self、极窄宽度
|
||
- **固定口径**:
|
||
- 测量可控:APP 用稳定的测量 mock(或固定字体与平台);WIDGET 用固定 width profile
|
||
- **CI 可运行**:在自动化环境可一键跑完(不依赖人工操作)
|
||
|
||
## 依赖与关联
|
||
|
||
- **依赖**:`core-contract`、`search-engine-*`、`scoring-tiebreak`、`overflow-fallback`
|
||
- **被依赖**:`integration`(接入后验收也可引用 Golden)
|
||
|