/** * Tests de l'ARRONDI de la médiane de calibration (v1.9.2 — miroir du fix * Android v1.8.2 `medianRounded`) : `round2`/`round3` ARRONDISSENT au plus * proche (Math.round) au lieu de tronquer — la troncature au dernier bit * flottant faussait les échelles d'un cran (0,8999… → 0,89). */ import { test, describe } from 'node:test'; import assert from 'node:assert/strict'; import { round2, round3 } from '../js/pk/pk-calibration.js'; describe('round2 / round3 (arrondi, pas troncature — v1.9.2)', () => { test('round2 arrondit au plus proche (0,8999… → 0,90, pas 0,89)', () => { assert.equal(round2(0.8999999999999999), 0.9); assert.equal(round3(0.8999999999999999), 0.9); // la troncature historique aurait donné 0,89 assert.notEqual(Math.trunc(0.8999999999999999 * 100) / 100, 0.9); }); test('round2 / round3 : cas limites', () => { assert.equal(round2(2.0), 2.0); assert.equal(round3(1.2346), 1.235); assert.equal(round2(0.001), 0.0); }); });