gestion_table_tournante_libre/test/fixtures/mutation/calcul.epreuve.js
Mathieu Benoit 8bdc959183 [ADD] mutation: run one mutant through node --test with a loader hook
A mutant counts only when the tests that import its module actually run
against the mutated source. A loader hook (module.registerHooks) serves the
mutated text in place of the module; the import graph picks the tests that
reach it, and node --test runs them in a child with a deadline. The verdict
is killed, survived, timed out or error; an empty request, a missing test
or a non-positive deadline is refused before anything starts.
Checked: red first; 3418 node and 76 long tests green from the index,
including a real run on a small invented module.

--- FR ---

[ADD] mutation : jouer un mutant sous node --test, crochet de chargement

Un mutant ne compte que si les épreuves qui importent son module jouent
vraiment contre le source muté. Un crochet de chargement
(module.registerHooks) sert le texte muté à la place du module ; le graphe
des imports choisit les épreuves qui l'atteignent, et node --test les joue
dans un enfant sous délai. Le verdict est tué, survivant, délai ou erreur ;
une demande vide, une épreuve absente ou un délai non positif sont refusés
avant tout lancement.
Vérifié : rouge d'abord ; 3418 node et 76 longues vertes depuis l'index,
dont un vrai lancement sur un petit module inventé.

Assisted-by: Claude Opus 5.5
2026-10-09 13:04:14 -04:00

21 lines
685 B
JavaScript

// © 2026 TechnoLibre (http://www.technolibre.ca)
// License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl)
// L'épreuve inventée de calcul.js, que test/mutation.long.test.js joue sous
// le repli node --test (§ 14.8). Son nom ne finit pas par .test.js : aucune
// série de Vitest ne la ramasse.
import assert from 'node:assert/strict';
import { describe, test } from '../../lanceur.js';
import { plusGrand, somme } from './calcul.js';
describe('calcul', () => {
test('somme', () => {
assert.equal(somme(4), 10);
assert.equal(somme(0), 0);
});
test('plusGrand', () => {
assert.equal(plusGrand(2, 5), 5);
assert.equal(plusGrand(5, 2), 5);
});
});