二七王:新增 Node 单元测试,CLAUDE.md 记录测试命令

- test/_shim.js:平台全局垫片(min_ary_include/deduct、min_random/now/ontimeout、
  youle_erqiwang.import mock),忠实复刻 minhttp.js;仅测试用,不进正式代码
- test/_assert.js + run.js:极简断言与总运行器
- test/test_arith.js(扣底/算子常规+爬坡/算奖/甩牌/跟牌分量) test_config.js(位串/局数扣卡)
  test/test_paiju.js(亮牌/结算 get_paiju_account 集成),共 89 项断言全过
- test/README.md:运行方式与双运行时原理
- CLAUDE.md:常用命令补测试入口,说明服务端双运行时规范

(CLAUDE.md 内另含此前一处措辞微调,随本次文档更新一并纳入)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-04 23:51:12 +08:00
co-authored by Claude Opus 4.8
parent 60271175d6
commit 6d663c8a66
8 changed files with 303 additions and 3 deletions
+28
View File
@@ -0,0 +1,28 @@
// roomtype 位串解析 + 局数/扣卡映射(design §10.1)
require('./_shim');
const C = require('../class.config.js');
const t = require('./_assert')();
// 复刻 export 的两个映射(现为2行)做端到端验证
const needroomcard = rt => { const c = C.parse(rt); return c.deductAA ? (c.aset12 ? 2 : 1) : (c.aset12 ? 4 : 2); };
const asetcount = rt => { const c = C.parse(rt); return c.aset12 ? 12 : 6; };
// --- parse 位串 ---
t.eq('"00000"', C.parse("00000"), { aset12: false, deductAA: false, bangwang: false, climb: false, nocheck: false });
t.eq('"10100"', C.parse("10100"), { aset12: true, deductAA: false, bangwang: true, climb: false, nocheck: false });
t.eq('"01011"', C.parse("01011"), { aset12: false, deductAA: true, bangwang: false, climb: true, nocheck: true });
t.eq('"" 兜底', C.parse(""), { aset12: false, deductAA: false, bangwang: false, climb: false, nocheck: false });
t.eq('undefined 兜底', C.parse(undefined), { aset12: false, deductAA: false, bangwang: false, climb: false, nocheck: false });
t.eq('"1" 短串', C.parse("1"), { aset12: true, deductAA: false, bangwang: false, climb: false, nocheck: false });
// --- 局数 ---
t.eq('6局 "0"', asetcount("00000"), 6);
t.eq('12局 "1"', asetcount("10000"), 12);
// --- 开房房卡 (design §10.1) ---
t.eq('房主6局', needroomcard("00000"), 2);
t.eq('房主12局', needroomcard("10000"), 4);
t.eq('AA6局', needroomcard("01000"), 1);
t.eq('AA12局', needroomcard("11000"), 2);
process.exit(t.done('config') ? 0 : 1);