二七王:LayoutSolver grid 补显式失败校验,attach 四角补精确坐标测试
审查发现 _solveGrid 在 count > cols*rows 时静默截断多出的项,违反显式失败 红线;补校验直接抛错并报出 count 与容量。fillOrder 字段之前从未被读取、 形同虚设,改为显式拒绝除 'row' 外的值(不实现列优先,YAGNI)。 测试补 grid 超载/恰好满格/fillOrder 三态,以及 attach 四角(topLeft/ bottomLeft/bottomRight)的精确坐标核对(此前只有 topRight 有精确值)。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -137,7 +137,17 @@ var EQW_LayoutSolver = EQW_LayoutSolver || {
|
||||
|
||||
//grid:固定行列的按钮阵,逐行调 distributeHorizontally(清单 §6.1)
|
||||
_solveGrid: function (n, ctx) {
|
||||
var count = (typeof ctx.count === 'number') ? ctx.count : (n.cols * n.rows);
|
||||
//fillOrder 目前只实现行优先;不写等同 row,写了别的值一律显式拒绝(YAGNI,不做无人用的列优先)
|
||||
if (n.fillOrder && n.fillOrder !== 'row') {
|
||||
throw new Error('[EQW_LayoutSolver] grid 仅支持 fillOrder=row,暂不支持: ' + n.fillOrder);
|
||||
}
|
||||
|
||||
var capacity = n.cols * n.rows;
|
||||
var count = (typeof ctx.count === 'number') ? ctx.count : capacity;
|
||||
//配置与运行时项数不一致时必须显式报错,不能静默截断多出的项(工程总则 §7 显式失败)
|
||||
if (count > capacity) {
|
||||
throw new Error('[EQW_LayoutSolver] grid 项数超出容量: count=' + count + ' > cols(' + n.cols + ')*rows(' + n.rows + ')=' + capacity);
|
||||
}
|
||||
if (count <= 0) { return []; }
|
||||
|
||||
var out = [];
|
||||
|
||||
Reference in New Issue
Block a user