HardYards/web/world/js/tests/b.test.js
m3ultra 18099c8e6f Align sail lane to contracts.js; free blown corners so they flog
Rebased onto M0 and reconciled against the real spine. checkContract
('sailRig') now conforms and js/tests/b.test.js runs 28 asserts green.

Contract fixes:
  - anchor.sway(t) is the ABSOLUTE position, not an offset (thanks A —
    I had it adding sway to pos, which would have flung every
    tree-anchored corner to double its coordinates).
  - events is an Emitter emitting {type, corner}, not a drained array.
  - coverageOver() rects are centre+size, matching world.gardenBed. It
    consumes world.sunDir directly: a hit along sunDir means shaded.
  - START_BUDGET/SPARE_COST/HARDWARE/FIXED_DT now come from contracts.js
    rather than being redeclared here.

Bug: a corner that blew was marked broken but never had its mass
returned, so invMass stayed 0 and the "blown" corner sat welded in
mid-air — no flogging, and the sail silently went dead. PLAN3D §5-B
wants flogging emergent from the freed node, so _checkFailure now frees
it. The cascade test missed this because it called _repin() by hand;
the new test drives a real overload failure instead and asserts the
corner tears 2 m off its anchor and keeps moving.

Tension dial remapped from the prototype's rest/tension to a real
pre-strain. rest/tension asks for 17% strain at dial 1.2 and 29% at 1.4
— stretching an 18 m sail by three metres — and put 68 kN on a corner of
the yard's biggest quad with no wind blowing. At 0.10 strain-per-dial it
swings a 5x5 rig's peak load 2.1x loose-to-tight and redlines a 192 m2
quad at 8.3 kN drum-tight, which is punishing and correct.

HARDWARE ratings retuned in contracts.js to real newtons per the
standing note there that Lane B owns these numbers. Costs and tier shape
untouched; $80 still buys rated hardware on at most 2 of 4 corners.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 21:55:37 +10:00

35 lines
1.8 KiB
JavaScript

/**
* Lane B selftests — cloth, corner loads, failure cascade, prep economy.
*
* The asserts themselves live next to the code they test, in
* `js/sail.selftest.js` and `js/rigging.selftest.js`, exported as [name, fn]
* pairs. This file is only the adapter that hands them to Lane A's Suite.
*
* The reason for the indirection: those two modules also run under plain
* `node web/world/js/sail.selftest.js` — no browser, no server, no renderer,
* ~6 s — which is how the cloth got proven before M0 landed. Keeping the
* asserts there means the browser suite and the headless suite can never drift,
* because they are literally the same array.
*
* PLAN3D §5-B asked for three asserts. All three are in there, plus a statics
* balance that pins the load meter to real newtons:
* 1. hypar sheds load — scored on WORST CASE over eight wind directions
* rather than one, because Lane C's storms veer and the player never gets
* to pick the wind. Per-direction would be a false assert: a flat sail
* sitting edge-on to the wind genuinely has low drag and beats the hypar
* from that one angle. Worst-case is what the hardware has to survive.
* 2. cascade — break a corner at fixed t, a neighbour's load spikes >= 2x.
* 3. determinism — byte-equal load traces, plus ragged frame dt converging on
* the fixed-dt trace (Lane A's render loop delivers ragged dt, so the
* accumulator has to absorb it or none of this applies to the real game).
*/
import { SAIL_TESTS } from '../sail.selftest.js';
import { RIGGING_TESTS } from '../rigging.selftest.js';
/** @param {import('../testkit.js').Suite} t */
export default function run(t) {
for (const [name, fn] of SAIL_TESTS) t.test(name, fn);
for (const [name, fn] of RIGGING_TESTS) t.test(`rigging: ${name}`, fn);
}