From b99d040b11a0013ba866a78e1f7076c3b133a52c Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Thu, 17 Sep 2026 15:54:02 +0800 Subject: [PATCH] =?UTF-8?q?test(07-12):=20=E5=AF=B9=E9=BD=90=E7=A9=BA?= =?UTF-8?q?=E5=AD=98=E6=A1=A3=20nextUid=20=E9=87=8D=E7=BD=AE=E5=A5=91?= =?UTF-8?q?=E7=BA=A6=EF=BC=88IN-02=EF=BC=8C=E6=B5=8B=E8=AF=95=E4=B8=93?= =?UTF-8?q?=E7=94=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - saveLoad.test.ts 的码 58 用例改写为「空存档 → 随后 add 发号 0 且不产生码 58」 - 用例内注释登记码 58 分支只剩非空畸形数组可达,生产实现保持原样 - equipStore.ts 零改动(生产修复基线 ba60ef9) --- packages-user/data-base/src/hero/saveLoad.test.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages-user/data-base/src/hero/saveLoad.test.ts b/packages-user/data-base/src/hero/saveLoad.test.ts index a435719..6c3160f 100644 --- a/packages-user/data-base/src/hero/saveLoad.test.ts +++ b/packages-user/data-base/src/hero/saveLoad.test.ts @@ -443,9 +443,10 @@ describe('HeroEquipsStore save and load round trips', () => { expect(result.info.map(info => info.code)).toContain(59); }); - // 验证存档不含任何裁E��E��例时绁Elogger.catch 观测到错误码E58 - it('warns code 58 when the max equipment uid cannot be found', () => { + // 验证空存档读档把 uid 计数器重置为 0(由随后的 add 发号 0 观测)且不产生码 58 + it('resets the uid counter when the save has no equipment', () => { const env = createEquipEnv(); + registerItem(env, createEquipItem(10, 'sword', [0], [['atk', 5]])); const result = logger.catch(() => env.store.loadState( @@ -454,7 +455,10 @@ describe('HeroEquipsStore save and load round trips', () => { ) ); - expect(result.info.map(info => info.code)).toContain(58); + // 码 58 分支现在只剩「非空数组但 maxBy 返回 undefined(畸形条目)」的防御 + // 路径可达,空存档不再触发;该分支属 equipStore 的现有实现,保持原样 + expect(env.store.add(10)).toBe(0); + expect(result.info.map(info => info.code)).not.toContain(58); }); });