supercov 4.28.0 → 4.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +43 -16
  2. package/docs/cli.md +338 -2
  3. package/docs/getting-started.md +18 -0
  4. package/docs/mutation.md +588 -0
  5. package/docs/supported-suites.md +109 -60
  6. package/package.json +11 -10
  7. package/runtime/javascript/atomic.mjs +6 -2
  8. package/runtime/javascript/ava.mjs +12 -0
  9. package/runtime/javascript/bunTest.mjs +17 -0
  10. package/runtime/javascript/jest.cjs +67 -0
  11. package/runtime/javascript/jest.config.mjs +46 -6
  12. package/runtime/javascript/jestReporter.mjs +5 -2
  13. package/runtime/javascript/mocha.mjs +79 -5
  14. package/runtime/javascript/nodeTest.mjs +28 -0
  15. package/runtime/javascript/playwright.mjs +33 -0
  16. package/runtime/javascript/playwrightStrong.mjs +477 -0
  17. package/runtime/javascript/playwrightStrongReporter.mjs +377 -0
  18. package/runtime/javascript/resolve-loader.mjs +4 -1
  19. package/runtime/javascript/runnerEntry.mjs +62 -0
  20. package/runtime/javascript/runtime.mjs +752 -13
  21. package/runtime/javascript/snapshots.mjs +16 -1
  22. package/runtime/javascript/strongJestHost.mjs +103 -0
  23. package/runtime/javascript/strongJob.mjs +78 -0
  24. package/runtime/javascript/strongJobs.mjs +809 -0
  25. package/runtime/javascript/strongMochaHost.mjs +166 -0
  26. package/runtime/javascript/strongWasmOut.cjs +96 -0
  27. package/runtime/javascript/tap.mjs +43 -1
  28. package/runtime/javascript/transport.mjs +5 -0
  29. package/runtime/javascript/vitest.mjs +74 -2
  30. package/runtime/javascript/vitestBrowser.mjs +34 -2
  31. package/runtime/javascript/vitestStrong.mjs +234 -0
  32. package/runtime/javascript/vitestStrongReporter.mjs +2268 -0
  33. package/runtime/javascript/vitestStrongSpawner.mjs +248 -0
@@ -51,7 +51,7 @@ function pathComponent(value) {
51
51
  return safe || "unscoped";
52
52
  }
53
53
  function encodeCoverageScope(scope) {
54
- return new URLSearchParams({
54
+ return new URLSearchParams(Object.assign({
55
55
  v: String(scope.version),
56
56
  r: scope.runId,
57
57
  w: scope.workerId,
@@ -59,7 +59,7 @@ function encodeCoverageScope(scope) {
59
59
  k: scope.testKey,
60
60
  a: String(scope.retry),
61
61
  i: scope.attemptId
62
- }).toString();
62
+ }, scope.mutant ? { m: scope.mutant } : {})).toString();
63
63
  }
64
64
  function decodeCoverageScope(encoded) {
65
65
  if (!encoded)
@@ -72,9 +72,13 @@ function decodeCoverageScope(encoded) {
72
72
  const testKey = values.get("k");
73
73
  const attemptId = values.get("i");
74
74
  const retry = Number(values.get("a"));
75
- if (values.get("v") !== "1" || !nonEmpty(runId) || !nonEmpty(workerId) || !nonEmpty(testId2) || !nonEmpty(testKey) || !safeKey(testKey) || !nonEmpty(attemptId) || !safeKey(attemptId) || !Number.isSafeInteger(retry) || retry < 0)
75
+ // A strong pass's attempt names its mutant (`file#index`, `-` for none).
76
+ const mutant = values.get("m");
77
+ if (values.get("v") !== "1" || !nonEmpty(runId) || !nonEmpty(workerId) || !nonEmpty(testId2) || !nonEmpty(testKey) || !safeKey(testKey) || !nonEmpty(attemptId) || !safeKey(attemptId) || !Number.isSafeInteger(retry) || retry < 0 || mutant !== null && parseMutant(mutant) === void 0)
76
78
  return void 0;
77
- return {
79
+ if (mutant !== null)
80
+ enablePerRequestMutants();
81
+ return __spreadValues({
78
82
  version: 1,
79
83
  runId,
80
84
  workerId,
@@ -82,7 +86,7 @@ function decodeCoverageScope(encoded) {
82
86
  testKey,
83
87
  retry,
84
88
  attemptId
85
- };
89
+ }, mutant !== null ? { mutant } : {});
86
90
  } catch (e) {
87
91
  return void 0;
88
92
  }
@@ -150,6 +154,45 @@ var builtinSetHas = Set.prototype.has;
150
154
  var builtinWeakMapGet = WeakMap.prototype.get;
151
155
  var builtinWeakMapSet = WeakMap.prototype.set;
152
156
  var runtimeGlobal = globalThis;
157
+ // Supercov keeps its state on globals, some first set while a test runs
158
+ // (the test's id, an async scope). A suite that checks for globals its tests
159
+ // add (Mocha's --check-leaks) lists the global object's enumerable keys, so
160
+ // each is made here, before any test, and never enumerable.
161
+ for (const name of [
162
+ "__SUPERCOV_ACTIVATE_PROBE_CONTEXT__",
163
+ "__SUPERCOV_ACTIVE_SCOPE__",
164
+ "__SUPERCOV_ASSERTION_PHASE_BRIDGE__",
165
+ "__SUPERCOV_ASSERTION_PHASE_OPENER__",
166
+ "__SUPERCOV_ASSERTION_PHASE_STARTED__",
167
+ "__SUPERCOV_ATTEMPT__",
168
+ "__SUPERCOV_BROWSER_FETCH_PATCHED__",
169
+ "__SUPERCOV_BUFFER_EXIT_INSTALLED__",
170
+ "__SUPERCOV_BUFFER_FLUSHERS__",
171
+ "__SUPERCOV_CHILD_PATCHED__",
172
+ "__SUPERCOV_COMPACT_SNAPSHOT__",
173
+ "__SUPERCOV_COVERAGE_SNAPSHOT__",
174
+ "__SUPERCOV_DIRECT_RUNTIME__",
175
+ "__SUPERCOV_EMITTER_CONTEXT_MAPS__",
176
+ "__SUPERCOV_EMITTER_PATCHED_INSTANCES__",
177
+ "__SUPERCOV_FETCH_PATCHED__",
178
+ "__SUPERCOV_MCDC_SNAPSHOT__",
179
+ "__SUPERCOV_MCDC_STATES__",
180
+ "__SUPERCOV_MCDC_TEST_ID__",
181
+ "__SUPERCOV_MODULE_LOADS__",
182
+ "__SUPERCOV_PHASE_ID__",
183
+ "__SUPERCOV_RESET__",
184
+ "__SUPERCOV_SERVER_PHASE_STORAGES__",
185
+ "__SUPERCOV_TERMINATION_FLUSHERS__",
186
+ "__SUPERCOV_TERMINATION_INSTALLED__",
187
+ "__SUPERCOV_WASM_REGIONS__",
188
+ "__SUPERCOV_WASM_REGISTRY__",
189
+ "__SUPERCOV_WASM_STRONG__",
190
+ "__SUPERCOV_WORKER_EVIDENCE__",
191
+ "__SUPERCOV_WORKER_TOKEN__",
192
+ ]) {
193
+ if (!Object.prototype.hasOwnProperty.call(runtimeGlobal, name))
194
+ Object.defineProperty(runtimeGlobal, name, { value: void 0, writable: true, configurable: true, enumerable: false });
195
+ }
153
196
  var runtimeInstanceToken = "__SUPERCOV_RUNTIME_INSTANCE__";
154
197
  var runtimeInstance = runtimeInstanceToken === "__SUPERCOV_RUNTIME_INSTANCE__" ? "application" : runtimeInstanceToken;
155
198
  var _a;
@@ -197,6 +240,15 @@ function createState() {
197
240
  // Per value-position logical expression (`a && b`, `a || b`, `a ?? b`): the distinct
198
241
  // (right operand evaluated?, result truthy?) pairs seen, keyed by branch id.
199
242
  logicals: /* @__PURE__ */ new Map(),
243
+ // Per relational comparison site ("file:line:column"): the operand
244
+ // relations seen -- lt, eq, gt, unordered (NaN), or other (objects that
245
+ // are not Dates) -- that decide comparison mutants, beside the coverage.
246
+ // Each relation maps to the epoch a process writing records last wrote
247
+ // it in (0 where none did): see noteValue.
248
+ comparisons: /* @__PURE__ */ new Map(),
249
+ // Per logical selection, outside a snapshot: each outcome's epoch, as
250
+ // for comparisons.
251
+ logicalEpochs: /* @__PURE__ */ new Map(),
200
252
  // The events already recorded, by phase: a hit by its id, anything else
201
253
  // by its type and what tells it apart (eventSeen).
202
254
  eventKeys: /* @__PURE__ */ new Map(),
@@ -299,6 +351,11 @@ function activateProbeV2Key(key, force = false) {
299
351
  vectors.clear();
300
352
  }
301
353
  }
354
+ for (const outcomes of state.comparisons.values()) {
355
+ for (const outcome of outcomes.keys())
356
+ outcomes.set(outcome, 0);
357
+ }
358
+ state.logicalEpochs.clear();
302
359
  }
303
360
  epoch = state.probeV2NextEpoch;
304
361
  builtinMapSet.call(state.probeV2ContextEpochs, key, epoch);
@@ -419,13 +476,22 @@ function logicalSnapshot() {
419
476
  vectors: [...vectors.values()]
420
477
  }));
421
478
  }
479
+ function comparisonSnapshot() {
480
+ return [...state.comparisons.entries()].map(([id, outcomes]) => ({
481
+ id,
482
+ outcomes: [...outcomes.keys()]
483
+ }));
484
+ }
422
485
  function coverageSnapshot() {
423
- return {
486
+ const snapshot = {
424
487
  decisions: decisionSnapshot(),
425
488
  hits: [...state.hits],
426
489
  events: eventObjects(state.eventLog),
427
490
  logicals: logicalSnapshot()
428
491
  };
492
+ if (state.comparisons.size)
493
+ snapshot.comparisons = comparisonSnapshot();
494
+ return snapshot;
429
495
  }
430
496
  // coverageSnapshot as snapshots.mjs's columnarEvents gives it, built from the
431
497
  // columns the events are kept in rather than from an object per event.
@@ -434,8 +500,11 @@ function coverageSnapshotColumns() {
434
500
  const decisions = decisionSnapshot();
435
501
  const hits = [...state.hits];
436
502
  const logicals = logicalSnapshot();
503
+ // The comparisons go with the columns as with the objects: a snapshot
504
+ // without them reads as if no comparison ran.
505
+ const comparisons = state.comparisons.size ? { comparisons: comparisonSnapshot() } : {};
437
506
  if (log.id.length === 0)
438
- return { decisions, hits, events: [], logicals };
507
+ return { decisions, hits, events: [], logicals, ...comparisons };
439
508
  const tables = { types: /* @__PURE__ */ new Map(), phases: /* @__PURE__ */ new Map(), environments: /* @__PURE__ */ new Map() };
440
509
  const index = (table, value) => {
441
510
  let found = table.get(value);
@@ -470,6 +539,7 @@ function coverageSnapshotColumns() {
470
539
  decisions,
471
540
  hits,
472
541
  logicals,
542
+ ...comparisons,
473
543
  eventColumns: {
474
544
  types: [...tables.types.keys()],
475
545
  phases: [...tables.phases.keys()],
@@ -483,6 +553,8 @@ function resetCoverage(testId2) {
483
553
  state.hits.clear();
484
554
  state.eventLog = emptyEventLog();
485
555
  state.logicals.clear();
556
+ state.comparisons.clear();
557
+ state.logicalEpochs.clear();
486
558
  state.eventKeys.clear();
487
559
  state.probeV2ContextEpochs.clear();
488
560
  state.probeV2EpochGeneration = (state.probeV2EpochGeneration || 0) + 1;
@@ -656,6 +728,8 @@ function evidenceSize() {
656
728
  size += decision.vectors.size;
657
729
  for (const vectors of state.logicals.values())
658
730
  size += vectors.size;
731
+ for (const outcomes of state.comparisons.values())
732
+ size += outcomes.size;
659
733
  return size;
660
734
  }
661
735
  // The evidence's size when this document gave it to the Playwright collector
@@ -722,8 +796,14 @@ function persistBrowser() {
722
796
  function attemptKey(scope) {
723
797
  return `${scope.runId}\0${scope.workerId}\0${scope.attemptId}`;
724
798
  }
799
+ // Every writer says, before its first record, that it records the values
800
+ // its comparisons, selections and probes see (`comparison` and `logical`
801
+ // records): a writer that does not, a runtime older than them, leaves its
802
+ // silence about values unread rather than read as "never seen".
803
+ var valuesRecord = { type: "values" };
725
804
  // An attempt's file says its scope once per writing process: each line
726
- // without one is of the scope of the line before it in the same file.
805
+ // without one is of the scope of the line before it in the same file. The
806
+ // first is the writer's note that it records values.
727
807
  var scopedPathsWritten = /* @__PURE__ */ new Set();
728
808
  function serverLine(record, path) {
729
809
  if (!path)
@@ -731,13 +811,13 @@ function serverLine(record, path) {
731
811
  const { scope, ...line } = record;
732
812
  if (scope && !scopedPathsWritten.has(path)) {
733
813
  scopedPathsWritten.add(path);
734
- line.scope = scope;
814
+ return JSON.stringify(__spreadProps(__spreadValues({}, valuesRecord), { scope })) + "\n" + JSON.stringify(line);
735
815
  }
736
816
  return JSON.stringify(line);
737
817
  }
738
818
  function serverRecordKey(record) {
739
819
  var _a8;
740
- const suffix = record.type === "decision" ? `${record.id}:${vectorKey(record.vector)}` : record.id;
820
+ const suffix = record.type === "decision" ? `${record.id}:${vectorKey(record.vector)}` : record.outcome !== void 0 ? `${record.id}\0${record.outcome}` : record.id;
741
821
  // Each request that names no test keeps its own first hits: the report
742
822
  // credits them to the test running when it came, and a later request's
743
823
  // work belongs to whichever test was running then.
@@ -950,6 +1030,9 @@ function writeBackgroundLines(fs, runId, payload) {
950
1030
  if (!path) {
951
1031
  const shard = (_a8 = process.env["SUPERCOV_EXECUTION_LOG_SHARD"]) != null ? _a8 : "process";
952
1032
  const writer = `${shard}-${process.pid}-${backgroundWriterToken()}`;
1033
+ // A writer's records are read together, by its name: its first says it
1034
+ // records values.
1035
+ payload = JSON.stringify(valuesRecord) + "\n" + payload;
953
1036
  const nextSequence = writeExclusiveBackgroundRecord(fs, runId, writer, state.backgroundSequence, payload);
954
1037
  state.backgroundSequence = nextSequence;
955
1038
  path = backgroundEvidencePath(runId, `${writer}-${nextSequence - 1}`);
@@ -1070,8 +1153,22 @@ function wasmRegionsWanted() {
1070
1153
  return true;
1071
1154
  return typeof process !== "undefined" && process.env != null && process.env.SUPERCOV_WASM_REGIONS === "1";
1072
1155
  }
1156
+ // A strong pass over Rust compiled to wasm: the mutant each instance runs is
1157
+ // handed to it through its exports (SUPERCOV_WASM_STRONG names the crates'
1158
+ // directories, `docs/design/mutation-drivers.md`).
1159
+ function wasmStrongRoots() {
1160
+ if (Array.isArray(runtimeGlobal.__SUPERCOV_WASM_STRONG__))
1161
+ return runtimeGlobal.__SUPERCOV_WASM_STRONG__;
1162
+ const named = typeof process !== "undefined" && process.env != null ? process.env.SUPERCOV_WASM_STRONG : void 0;
1163
+ if (typeof named !== "string" || named === "")
1164
+ return void 0;
1165
+ if (parsedWasmRoots === void 0 || parsedWasmRoots[0] !== named)
1166
+ parsedWasmRoots = [named, JSON.parse(named)];
1167
+ return parsedWasmRoots[1];
1168
+ }
1169
+ var parsedWasmRoots;
1073
1170
  function installWasmRegistry() {
1074
- if (runtimeGlobal.__SUPERCOV_WASM_REGISTRY__ || typeof WebAssembly === "undefined" || !wasmRegionsWanted())
1171
+ if (runtimeGlobal.__SUPERCOV_WASM_REGISTRY__ || typeof WebAssembly === "undefined" || !(wasmRegionsWanted() || wasmStrongRoots()))
1075
1172
  return;
1076
1173
  runtimeGlobal.__SUPERCOV_WASM_REGISTRY__ = true;
1077
1174
  if (!runtimeGlobal.__supercovWasm)
@@ -1095,6 +1192,7 @@ function registerWasmRealm(realm) {
1095
1192
  function Recorded(module, imports) {
1096
1193
  const instance = new Instance(module, imports);
1097
1194
  instances.push(instance);
1195
+ activateWasm(instance);
1098
1196
  return instance;
1099
1197
  }
1100
1198
  Recorded.prototype = Instance.prototype;
@@ -1109,7 +1207,9 @@ function registerWasmRealm(realm) {
1109
1207
  try {
1110
1208
  wasm[name] = function() {
1111
1209
  return original.apply(wasm, arguments).then(function(result) {
1112
- instances.push(result instanceof Instance ? result : result.instance);
1210
+ const instance = result instanceof Instance ? result : result.instance;
1211
+ instances.push(instance);
1212
+ activateWasm(instance);
1113
1213
  return result;
1114
1214
  });
1115
1215
  };
@@ -1117,6 +1217,50 @@ function registerWasmRealm(realm) {
1117
1217
  }
1118
1218
  });
1119
1219
  }
1220
+ /**
1221
+ * Switches the active mutant on in a wasm instance, as the Rust strong
1222
+ * runtime exports it: the mutant's file, relative to its crate's Cargo
1223
+ * workspace, written into `__supercov_strong_buffer_<key>`, and its index
1224
+ * given to `__supercov_strong_activate_<key>`. A mutant of no crate's (or
1225
+ * none) switches every crate's off.
1226
+ */
1227
+ function activateWasm(instance) {
1228
+ const roots = wasmStrongRoots();
1229
+ const exports = instance && instance.exports;
1230
+ if (!roots || !exports || !exports.memory)
1231
+ return;
1232
+ const strong = strongState();
1233
+ let file = "";
1234
+ let index = BigInt.asUintN(64, BigInt(-1));
1235
+ for (const root of roots) {
1236
+ if (typeof strong.file === "string" && strong.index >= 0 && strong.file.startsWith(root)) {
1237
+ file = strong.file.slice(root.length);
1238
+ index = BigInt(strong.index);
1239
+ break;
1240
+ }
1241
+ }
1242
+ const bytes = new TextEncoder().encode(file);
1243
+ for (const name of Object.keys(exports)) {
1244
+ if (name.indexOf("__supercov_strong_activate_") !== 0)
1245
+ continue;
1246
+ const buffer = exports["__supercov_strong_buffer_" + name.slice("__supercov_strong_activate_".length)];
1247
+ if (typeof buffer !== "function" || bytes.length > 4096)
1248
+ continue;
1249
+ try {
1250
+ new Uint8Array(exports.memory.buffer, Number(buffer()), bytes.length).set(bytes);
1251
+ exports[name](bytes.length, index);
1252
+ } catch (e) {
1253
+ }
1254
+ }
1255
+ }
1256
+ /** Every instance the runtime remembers runs the active mutant. */
1257
+ function activateWasmInstances() {
1258
+ const instances = runtimeGlobal.__supercovWasm;
1259
+ if (!instances || !wasmStrongRoots())
1260
+ return;
1261
+ for (const instance of instances)
1262
+ activateWasm(instance);
1263
+ }
1120
1264
  installWasmRegistry();
1121
1265
  function wasmBase64(bytes) {
1122
1266
  if (typeof Buffer !== "undefined")
@@ -1280,6 +1424,9 @@ function scheduleServerFlush() {
1280
1424
  function appendServer(record) {
1281
1425
  var _a8, _b, _c, _d;
1282
1426
  if (state.runtimeSnapshots) {
1427
+ // A snapshot holds its values itself.
1428
+ if (record.type !== "hit" && record.type !== "decision")
1429
+ return;
1283
1430
  const timestampMs = (_a8 = record.timestampMs) != null ? _a8 : Date.now();
1284
1431
  if (record.type === "decision")
1285
1432
  recordBrowserEvent("decision", record.id, record.vector, timestampMs, record.phaseId, "server");
@@ -1367,7 +1514,7 @@ function activateCoverageScope(scope) {
1367
1514
  if (scope)
1368
1515
  runtimeGlobal.__SUPERCOV_ACTIVE_SCOPE__ = scope;
1369
1516
  else
1370
- delete runtimeGlobal.__SUPERCOV_ACTIVE_SCOPE__;
1517
+ runtimeGlobal.__SUPERCOV_ACTIVE_SCOPE__ = void 0;
1371
1518
  activateProbeV2Context(scope ? { scope } : {});
1372
1519
  }
1373
1520
  function coverageCarrier() {
@@ -1507,6 +1654,11 @@ function withNodeAssertionPhase(operation, source, callback) {
1507
1654
  // as Jest started from another tool's process. The assertion still fails
1508
1655
  // with the frames its author would see.
1509
1656
  if (!scope) {
1657
+ // An adapter that makes such an assertion a test's (a node:test file's
1658
+ // top level) is told, and the assertion runs as it would have.
1659
+ const unscoped = runtimeGlobal.__SUPERCOV_UNSCOPED_ASSERTION__;
1660
+ if (typeof unscoped === "function")
1661
+ unscoped();
1510
1662
  try {
1511
1663
  return withStackRoom(callback);
1512
1664
  } catch (error) {
@@ -2399,12 +2551,575 @@ function recordLogicalOutcome(branchId, outcome) {
2399
2551
  builtinMapSet.call(vectors, key, { right: outcome >= 2, truthy: (outcome & 1) === 1 });
2400
2552
  workerEvidenceChanged();
2401
2553
  }
2554
+ if (isBrowser || state.runtimeSnapshots)
2555
+ return;
2556
+ let epochs = state.logicalEpochs.get(branchId);
2557
+ if (epochs === void 0) {
2558
+ epochs = /* @__PURE__ */ new Map();
2559
+ state.logicalEpochs.set(branchId, epochs);
2560
+ }
2561
+ const clock = state.probeV2Clock;
2562
+ if (!clock.fast || epochs.get(key) !== clock.e)
2563
+ noteValue(epochs, "logical", branchId, key);
2402
2564
  }
2403
2565
  // A JSX expression container has nowhere to put a statement and cannot hold a
2404
2566
  // bare comma operator, so a rendered expression carries its probe as a call
2405
2567
  // that returns the value through. Like optionalSelect, it records after the
2406
2568
  // value evaluates: an expression that throws is reported unevaluated rather
2407
2569
  // than covered.
2570
+ // `a < b` (op 0), `a <= b` (1), `a > b` (2), `a >= b` (3). The operands were
2571
+ // evaluated once, by the program, before this call; the relation is read
2572
+ // from them only when both are primitives of one kind or both Dates, which
2573
+ // no user code can observe, and the comparison itself runs once as written.
2574
+ function compareRelation(left, right) {
2575
+ const lt = typeof left, rt = typeof right;
2576
+ if (lt === "number" && rt === "number" || lt === "string" && rt === "string" || lt === "bigint" && rt === "bigint") {
2577
+ if (left < right) return "lt";
2578
+ if (left > right) return "gt";
2579
+ return left === right ? "eq" : "unordered";
2580
+ }
2581
+ if (left instanceof Date && right instanceof Date) {
2582
+ const a = Date.prototype.getTime.call(left), b = Date.prototype.getTime.call(right);
2583
+ return a < b ? "lt" : a > b ? "gt" : a === b ? "eq" : "unordered";
2584
+ }
2585
+ if ((lt === "number" || lt === "bigint") && (rt === "number" || rt === "bigint")) {
2586
+ if (left < right) return "lt";
2587
+ if (left > right) return "gt";
2588
+ return left == right ? "eq" : "unordered";
2589
+ }
2590
+ return "other";
2591
+ }
2592
+ // Op 4: an equality the program evaluated as the argument; its value is
2593
+ // recorded as "true" or "false" and handed back.
2594
+ function compareV2(site, left, right, op) {
2595
+ const result = op === 4 ? left : op === 0 ? left < right : op === 1 ? left <= right : op === 2 ? left > right : left >= right;
2596
+ try {
2597
+ recordProbeOutcome(site, op === 4 ? result ? "true" : "false" : compareRelation(left, right));
2598
+ } catch {
2599
+ }
2600
+ return result;
2601
+ }
2602
+ // The mutants' probes (on unless SUPERCOV_MUTANTS=0). Each helper gets the
2603
+ // values the program computed, does the program's own operation or
2604
+ // call once, and records whether Stryker's replacement would have given a
2605
+ // different value ("differs"), the same one ("same"), or cannot be told
2606
+ // ("unknown"), under the site's id in the comparison records. Counterparts
2607
+ // are computed only by built-ins on primitives (or on verified built-in
2608
+ // arrays, strings, dates and Math), so no user code runs an extra time.
2609
+ // Every repeat in the same context ends at the first check, as a hit's does:
2610
+ // a snapshot keeps each outcome once per test, a process writing records
2611
+ // once per context.
2612
+ function recordProbeOutcome(site, outcome) {
2613
+ let outcomes = state.comparisons.get(site);
2614
+ if (outcomes === void 0) {
2615
+ outcomes = /* @__PURE__ */ new Map();
2616
+ state.comparisons.set(site, outcomes);
2617
+ }
2618
+ const seen = outcomes.get(outcome);
2619
+ const clock = state.probeV2Clock;
2620
+ if (seen !== void 0 && (clock.fast && seen === clock.e || isBrowser || state.runtimeSnapshots))
2621
+ return;
2622
+ noteValue(outcomes, "comparison", site, outcome);
2623
+ }
2624
+ // An outcome new to this test's snapshot, or to this context's records. A
2625
+ // process that writes records rather than snapshots -- a server, or a
2626
+ // node:test, AVA or tap test process -- writes each outcome a site sees once
2627
+ // per context, as recordCoverageHit writes a point's hit: the report reads
2628
+ // those records as it reads a snapshot's values. `epochs` maps each outcome
2629
+ // to the epoch it was last written in.
2630
+ function noteValue(epochs, type, id, outcome) {
2631
+ const known = epochs.has(outcome);
2632
+ if (isBrowser || state.runtimeSnapshots) {
2633
+ if (!known) {
2634
+ epochs.set(outcome, 0);
2635
+ workerEvidenceChanged();
2636
+ }
2637
+ return;
2638
+ }
2639
+ const clock = state.probeV2Clock;
2640
+ let epoch = clock.e;
2641
+ if (!clock.fast) {
2642
+ const previousEpoch = clock.e;
2643
+ activateProbeV2Context(currentRequestContext());
2644
+ epoch = clock.e;
2645
+ clock.e = previousEpoch;
2646
+ } else if (epoch !== epoch) {
2647
+ epoch = resolveProbeV2Epoch();
2648
+ }
2649
+ if (epochs.get(outcome) === epoch)
2650
+ return;
2651
+ epochs.set(outcome, epoch);
2652
+ if (!known)
2653
+ workerEvidenceChanged();
2654
+ const phaseId = currentPhaseId();
2655
+ appendServer(__spreadValues({
2656
+ type,
2657
+ id,
2658
+ outcome,
2659
+ timestampMs: Date.now()
2660
+ }, phaseId ? { phaseId } : {}));
2661
+ }
2662
+ function probePrimitive(value) {
2663
+ return value === null || typeof value !== "object" && typeof value !== "function" && typeof value !== "symbol";
2664
+ }
2665
+ // + - * / % << >> & | ; Stryker's replacement of each: - + / * * >> << | &
2666
+ const probeArithmeticSwap = [1, 0, 3, 2, 2, 6, 5, 8, 7];
2667
+ function probeArithmetic(left, right, op) {
2668
+ switch (op) {
2669
+ case 0: return left + right;
2670
+ case 1: return left - right;
2671
+ case 2: return left * right;
2672
+ case 3: return left / right;
2673
+ case 4: return left % right;
2674
+ case 5: return left << right;
2675
+ case 6: return left >> right;
2676
+ case 7: return left & right;
2677
+ default: return left | right;
2678
+ }
2679
+ }
2680
+ function probeCounterpart(result, left, right, op) {
2681
+ if (!probePrimitive(left) || !probePrimitive(right)) return "unknown";
2682
+ // `+` with a string operand gives a string, and `-` always a number (and
2683
+ // the reverse): they differ, whatever the operands. Working the other out
2684
+ // would also turn a string the program builds by `+` (which V8 keeps as a
2685
+ // rope) flat at every step: a path built a segment at a time copied every
2686
+ // prefix of itself, and dot-prop's test of 100,000 levels ran out of memory.
2687
+ if ((op === 0 || op === 1) && (typeof left === "string" || typeof right === "string")) return "differs";
2688
+ let other;
2689
+ try {
2690
+ other = probeArithmetic(left, right, probeArithmeticSwap[op]);
2691
+ } catch {
2692
+ return "differs";
2693
+ }
2694
+ return Object.is(result, other) ? "same" : "differs";
2695
+ }
2696
+ function arithV2(site, left, right, op) {
2697
+ const result = probeArithmetic(left, right, op);
2698
+ try {
2699
+ recordProbeOutcome(site, probeCounterpart(result, left, right, op));
2700
+ } catch {
2701
+ }
2702
+ return result;
2703
+ }
2704
+ // `x op= value`: `current` is x as the assignment read it, before `value`.
2705
+ function assignV2(site, current, value, op) {
2706
+ try {
2707
+ let result;
2708
+ let outcome;
2709
+ try {
2710
+ result = probeArithmetic(current, value, op);
2711
+ outcome = probeCounterpart(result, current, value, op);
2712
+ } catch {
2713
+ outcome = "unknown";
2714
+ }
2715
+ recordProbeOutcome(site, outcome);
2716
+ } catch {
2717
+ }
2718
+ return value;
2719
+ }
2720
+ // A concise arrow's value: Stryker's mutant returns undefined.
2721
+ function valueV2(site, value) {
2722
+ try {
2723
+ recordProbeOutcome(site, value === void 0 ? "undefined" : "defined");
2724
+ } catch {
2725
+ }
2726
+ return value;
2727
+ }
2728
+ // Strong mutation (mutant schemata). A file instrumented in strong mode has
2729
+ // every listed mutant behind a switch and reads one record from here when
2730
+ // it loads, `strongSlot(file)`, with `file` its path from the project root
2731
+ // as mutants.json keys it. Each switch reads the record's `a`, the index of
2732
+ // the active mutant in the file's list (-1 for none), every time it is
2733
+ // evaluated, and the active mutant's branch calls `h()`, which counts its
2734
+ // evaluations and throws MutantTimeoutError past the limit, so a loop the
2735
+ // mutant made endless ends where it runs. The state is kept on the global
2736
+ // object, so copies of this runtime in one realm agree on it.
2737
+ class MutantTimeoutError extends Error {
2738
+ constructor(file, index, hits) {
2739
+ super(`Supercov: mutant ${index} of ${file} was evaluated more than ${hits - 1} times`);
2740
+ this.name = "MutantTimeoutError";
2741
+ this.code = "SUPERCOV_MUTANT_TIMEOUT";
2742
+ this.file = file;
2743
+ this.index = index;
2744
+ }
2745
+ }
2746
+ const strongStateKey = Symbol.for("supercov.strongMutation");
2747
+ // SUPERCOV_MUTANT_HIT_LIMIT: how often the active mutant may be evaluated in
2748
+ // a process before its switch throws (docs/design/mutation-drivers.md).
2749
+ function environmentHitLimit() {
2750
+ try {
2751
+ const given = typeof process !== "undefined" && process.env ? Number(process.env["SUPERCOV_MUTANT_HIT_LIMIT"]) : NaN;
2752
+ return Number.isSafeInteger(given) && given > 0 ? given : 1e6;
2753
+ } catch (e) {
2754
+ return 1e6;
2755
+ }
2756
+ }
2757
+ function strongState() {
2758
+ let strong = globalThis[strongStateKey];
2759
+ if (strong === void 0) {
2760
+ strong = { slots: /* @__PURE__ */ new Map(), file: void 0, index: -1, hits: 0, limit: environmentHitLimit() };
2761
+ Object.defineProperty(globalThis, strongStateKey, { value: strong, configurable: true });
2762
+ }
2763
+ return strong;
2764
+ }
2765
+ // `file#index`, or `-` for no mutant: what a strong pass's attempt names in
2766
+ // its scope, and what SUPERCOV_ACTIVE_MUTANT names for a whole process.
2767
+ const parsedMutants = /* @__PURE__ */ new Map();
2768
+ function parseMutant(text) {
2769
+ if (typeof text !== "string")
2770
+ return void 0;
2771
+ let parsed = parsedMutants.get(text);
2772
+ if (parsed !== void 0)
2773
+ return parsed;
2774
+ if (text === "-") {
2775
+ parsed = { file: void 0, index: -1, key: text };
2776
+ } else {
2777
+ const at = text.lastIndexOf("#");
2778
+ const index = Number(text.slice(at + 1));
2779
+ if (at <= 0 || !/^\d+$/.test(text.slice(at + 1)) || !Number.isSafeInteger(index))
2780
+ return void 0;
2781
+ parsed = { file: text.slice(0, at), index, key: text };
2782
+ }
2783
+ parsedMutants.set(text, parsed);
2784
+ return parsed;
2785
+ }
2786
+ // The mutant of the attempt whose request is being served: a strong pass of
2787
+ // browser tests gives each attempt its own mutant in its scope, which comes
2788
+ // with every request the attempt sends and stays with the request's work.
2789
+ // `undefined` outside any such attempt's work: the process's own mutant
2790
+ // applies there.
2791
+ function requestMutant(strong) {
2792
+ for (const resolve of strong.resolvers) {
2793
+ const scope = resolve();
2794
+ if (scope !== void 0)
2795
+ return parseMutant(scope.mutant);
2796
+ }
2797
+ return void 0;
2798
+ }
2799
+ function slotIndex(file) {
2800
+ const strong = strongState();
2801
+ if (strong.perRequest) {
2802
+ const mutant = requestMutant(strong);
2803
+ if (mutant !== void 0)
2804
+ return mutant.file === file ? mutant.index : -1;
2805
+ }
2806
+ return strong.file === file ? strong.index : -1;
2807
+ }
2808
+ // Each switch reads the slot's `a`. Where requests carry their own mutants
2809
+ // it is read from the request being served, so one server runs several
2810
+ // attempts' mutants at once; everywhere else it is a plain value, as cheap
2811
+ // as a switch can be.
2812
+ function requestSlot(slot, file) {
2813
+ Object.defineProperty(slot, "a", {
2814
+ configurable: true,
2815
+ enumerable: true,
2816
+ get: () => slotIndex(file),
2817
+ set: () => {
2818
+ }
2819
+ });
2820
+ return slot;
2821
+ }
2822
+ function enablePerRequestMutants() {
2823
+ if (isBrowser)
2824
+ return;
2825
+ const strong = strongState();
2826
+ if (strong.resolvers === void 0)
2827
+ strong.resolvers = /* @__PURE__ */ new Set();
2828
+ strong.resolvers.add(requestScopeOfThisRuntime);
2829
+ if (strong.perRequest)
2830
+ return;
2831
+ strong.perRequest = true;
2832
+ strong.requestHits = /* @__PURE__ */ new Map();
2833
+ for (const [file, slot] of strong.slots)
2834
+ requestSlot(slot, file);
2835
+ }
2836
+ function requestScopeOfThisRuntime() {
2837
+ const scope = currentRequestContext().scope;
2838
+ return scope !== void 0 && scope.mutant !== void 0 ? scope : void 0;
2839
+ }
2840
+ // A mutant evaluated past the limit: a loop it made endless. The process
2841
+ // says so where the strong pass reads it (SUPERCOV_STRONG_RESULTS beside),
2842
+ // since the error may never reach a test.
2843
+ function noteMutantTimeout(file, index, attemptId) {
2844
+ const strong = strongState();
2845
+ try {
2846
+ if (typeof strong.onTimeout === "function") {
2847
+ strong.onTimeout(file, index, attemptId);
2848
+ return;
2849
+ }
2850
+ if (isBrowser || typeof process === "undefined")
2851
+ return;
2852
+ const results = process.env["SUPERCOV_STRONG_RESULTS"];
2853
+ const fs = results ? getFs() : void 0;
2854
+ if (!fs)
2855
+ return;
2856
+ fs.appendFileSync(`${results}.timeouts.jsonl`, JSON.stringify({
2857
+ mutant: `${file}#${index}`,
2858
+ attemptId: attemptId != null ? attemptId : null,
2859
+ pass: process.env["SUPERCOV_STRONG_RESTART"] || "main"
2860
+ }) + "\n");
2861
+ } catch (e) {
2862
+ }
2863
+ }
2864
+ function strongHit() {
2865
+ const strong = strongState();
2866
+ if (strong.perRequest) {
2867
+ let attemptId;
2868
+ for (const resolve of strong.resolvers) {
2869
+ const scope = resolve();
2870
+ if (scope !== void 0) {
2871
+ attemptId = scope.attemptId;
2872
+ break;
2873
+ }
2874
+ }
2875
+ const mutant = attemptId !== void 0 ? requestMutant(strong) : void 0;
2876
+ if (mutant !== void 0 && mutant.file !== void 0) {
2877
+ const key = `${attemptId}\0${mutant.key}`;
2878
+ const hits = (strong.requestHits.get(key) || 0) + 1;
2879
+ strong.requestHits.set(key, hits);
2880
+ if (hits > strong.limit) {
2881
+ noteMutantTimeout(mutant.file, mutant.index, attemptId);
2882
+ throw new MutantTimeoutError(mutant.file, mutant.index, hits);
2883
+ }
2884
+ return;
2885
+ }
2886
+ }
2887
+ if (++strong.hits > strong.limit) {
2888
+ noteMutantTimeout(strong.file, strong.index);
2889
+ throw new MutantTimeoutError(strong.file, strong.index, strong.hits);
2890
+ }
2891
+ }
2892
+ function strongSlot(file) {
2893
+ const strong = strongState();
2894
+ let slot = strong.slots.get(file);
2895
+ if (slot === void 0) {
2896
+ slot = { a: strong.file === file ? strong.index : -1, h: strongHit };
2897
+ if (strong.perRequest)
2898
+ requestSlot(slot, file);
2899
+ strong.slots.set(file, slot);
2900
+ }
2901
+ return slot;
2902
+ }
2903
+ function setActiveMutant(file, index) {
2904
+ const strong = strongState();
2905
+ const previous = strong.slots.get(strong.file);
2906
+ if (previous !== void 0)
2907
+ previous.a = -1;
2908
+ strong.file = file;
2909
+ strong.index = index;
2910
+ strong.hits = 0;
2911
+ const slot = strong.slots.get(file);
2912
+ if (slot !== void 0)
2913
+ slot.a = index;
2914
+ activateWasmInstances();
2915
+ }
2916
+ function clearActiveMutant() {
2917
+ setActiveMutant(void 0, -1);
2918
+ }
2919
+ function setMutantHitLimit(limit) {
2920
+ strongState().limit = limit;
2921
+ }
2922
+ function mutantHitCount() {
2923
+ return strongState().hits;
2924
+ }
2925
+ // A process a strong pass starts with a mutant switched on everywhere
2926
+ // (SUPERCOV_ACTIVE_MUTANT=<file>#<index>: a server whose module-level code
2927
+ // or background work the mutant changes), or a child started for one
2928
+ // attempt's work, whose context names the attempt's mutant.
2929
+ (function activateProcessMutant() {
2930
+ if (isBrowser || typeof process === "undefined" || !process.env)
2931
+ return;
2932
+ try {
2933
+ const named = parseMutant(process.env["SUPERCOV_ACTIVE_MUTANT"]);
2934
+ const carried = named === void 0 ? environmentRequestContext() : void 0;
2935
+ const mutant = named !== void 0 ? named : parseMutant(carried && carried.scope && carried.scope.mutant);
2936
+ if (mutant !== void 0 && mutant.file !== void 0 && strongState().file !== mutant.file)
2937
+ setActiveMutant(mutant.file, mutant.index);
2938
+ } catch (e) {
2939
+ }
2940
+ })();
2941
+ function isMutantTimeout(error) {
2942
+ return error instanceof MutantTimeoutError || error != null && error.code === "SUPERCOV_MUTANT_TIMEOUT";
2943
+ }
2944
+ const probeArray = Array.prototype, probeString = String.prototype, probeDate = Date.prototype;
2945
+ const probeBuiltins = {
2946
+ array: new Map(["some", "every", "filter", "reverse", "slice", "sort", "find", "findIndex", "findLast", "findLastIndex"].filter((name) => typeof probeArray[name] === "function").map((name) => [name, probeArray[name]])),
2947
+ string: new Map(["charAt", "endsWith", "startsWith", "substr", "substring", "slice", "toLocaleLowerCase", "toLocaleUpperCase", "toLowerCase", "toUpperCase", "trim", "trimEnd", "trimStart"].filter((name) => typeof probeString[name] === "function").map((name) => [name, probeString[name]])),
2948
+ date: new Map(["setDate", "setTime", "setFullYear", "setMonth", "setHours", "setMinutes", "setSeconds", "setMilliseconds", "setUTCDate", "setUTCFullYear", "setUTCMonth", "setUTCHours", "setUTCMinutes", "setUTCSeconds", "setUTCMilliseconds"].map((name) => [name, probeDate[name]])),
2949
+ min: Math.min,
2950
+ max: Math.max,
2951
+ getTime: probeDate.getTime
2952
+ };
2953
+ // Stryker's swaps (StrykerJS 10.1.1); a name it removes has none.
2954
+ const probeSwaps = {
2955
+ endsWith: "startsWith", startsWith: "endsWith", every: "some", some: "every",
2956
+ toLocaleLowerCase: "toLocaleUpperCase", toLocaleUpperCase: "toLocaleLowerCase",
2957
+ toLowerCase: "toUpperCase", toUpperCase: "toLowerCase", trimEnd: "trimStart", trimStart: "trimEnd",
2958
+ min: "max", max: "min", setDate: "setTime", setTime: "setDate", setFullYear: "setMonth", setMonth: "setFullYear",
2959
+ setHours: "setMinutes", setMinutes: "setHours", setSeconds: "setMilliseconds", setMilliseconds: "setSeconds",
2960
+ setUTCDate: "setTime", setUTCFullYear: "setUTCMonth", setUTCMonth: "setUTCFullYear",
2961
+ setUTCHours: "setUTCMinutes", setUTCMinutes: "setUTCHours", setUTCSeconds: "setUTCMilliseconds",
2962
+ setUTCMilliseconds: "setUTCSeconds"
2963
+ };
2964
+ const probeRemoved = /* @__PURE__ */ new Set(["charAt", "filter", "reverse", "slice", "sort", "substr", "substring", "trim"]);
2965
+ function probeAllPrimitive(values) {
2966
+ for (const value of values) if (!probePrimitive(value)) return false;
2967
+ return true;
2968
+ }
2969
+ // The callback the program passed, called exactly as the built-in calls it;
2970
+ // the wrapper only reads what it returned.
2971
+ function probeObservedCallback(callback, arrow, observe) {
2972
+ return function(value, index) {
2973
+ const result = Reflect.apply(callback, this, arguments);
2974
+ try {
2975
+ observe(result, index);
2976
+ if (arrow !== void 0) recordProbeOutcome(arrow, result === void 0 ? "undefined" : "defined");
2977
+ } catch {
2978
+ }
2979
+ return result;
2980
+ };
2981
+ }
2982
+ // `pure` is a copy of a some/every callback the instrumenter found pure
2983
+ // (pure_callback: no calls, no writes, only its parameters' properties), without
2984
+ // the program's probes: where the call stopped at the first of several
2985
+ // elements, the probe runs it through the other method to decide.
2986
+ function probeArrayCall(site, receiver, name, arrow, args, pure) {
2987
+ const builtin = probeBuiltins.array.get(name);
2988
+ const length = receiver.length;
2989
+ if (name === "some" || name === "every" || name === "filter" || name.startsWith("find")) {
2990
+ if (typeof args[0] !== "function") return Reflect.apply(builtin, receiver, args);
2991
+ let calls = 0, lastIndex = -1;
2992
+ const observed = [probeObservedCallback(args[0], arrow, (_, index) => {
2993
+ calls++;
2994
+ lastIndex = index;
2995
+ })];
2996
+ for (let index = 1; index < args.length; index++) observed.push(args[index]);
2997
+ const result = Reflect.apply(builtin, receiver, observed);
2998
+ try {
2999
+ if (name === "filter") recordProbeOutcome(site, result.length !== length ? "differs" : "same");
3000
+ else if (name === "some" || name === "every") {
3001
+ // some stops at its first truthy outcome, every at its first falsy
3002
+ // one; the other method's value follows from the outcomes seen,
3003
+ // except when it stopped at the first element of several.
3004
+ const stoppedEarly = name === "some" ? result : !result;
3005
+ let outcome;
3006
+ if (calls === 0) outcome = "differs";
3007
+ else if (!stoppedEarly) outcome = "same";
3008
+ else if (calls > 1) outcome = "differs";
3009
+ else if (lastIndex === length - 1) outcome = "same";
3010
+ else if (typeof pure === "function") {
3011
+ // A throw from the copy (a property of null) is no answer.
3012
+ try {
3013
+ const other = Reflect.apply(probeBuiltins.array.get(name === "some" ? "every" : "some"), receiver, [pure]);
3014
+ outcome = other === result ? "same" : "differs";
3015
+ } catch {
3016
+ outcome = "unknown";
3017
+ }
3018
+ } else outcome = "unknown";
3019
+ recordProbeOutcome(site, outcome);
3020
+ }
3021
+ } catch {
3022
+ }
3023
+ return result;
3024
+ }
3025
+ if (name === "sort" || name === "reverse") {
3026
+ const before = probeBuiltins.array.get("slice").call(receiver);
3027
+ const result = Reflect.apply(builtin, receiver, args);
3028
+ try {
3029
+ let changed = before.length !== receiver.length;
3030
+ for (let index = 0; !changed && index < before.length; index++) changed = !Object.is(before[index], receiver[index]);
3031
+ recordProbeOutcome(site, changed ? "differs" : "same");
3032
+ } catch {
3033
+ }
3034
+ return result;
3035
+ }
3036
+ const result = Reflect.apply(builtin, receiver, args);
3037
+ try {
3038
+ recordProbeOutcome(site, result.length !== length ? "differs" : "same");
3039
+ } catch {
3040
+ }
3041
+ return result;
3042
+ }
3043
+ function probeStringCall(site, receiver, name, args) {
3044
+ const builtin = probeBuiltins.string.get(name);
3045
+ const result = Reflect.apply(builtin, receiver, args);
3046
+ try {
3047
+ if (probeRemoved.has(name)) recordProbeOutcome(site, Object.is(result, receiver) ? "same" : "differs");
3048
+ else if (probeSwaps[name] !== void 0) {
3049
+ if (!probeAllPrimitive(args)) recordProbeOutcome(site, "unknown");
3050
+ else {
3051
+ let other, threw = false;
3052
+ try {
3053
+ other = Reflect.apply(probeBuiltins.string.get(probeSwaps[name]), receiver, args);
3054
+ } catch {
3055
+ threw = true;
3056
+ }
3057
+ recordProbeOutcome(site, threw || !Object.is(result, other) ? "differs" : "same");
3058
+ }
3059
+ }
3060
+ } catch {
3061
+ }
3062
+ return result;
3063
+ }
3064
+ function probeDateCall(site, receiver, name, args) {
3065
+ const builtin = probeBuiltins.date.get(name);
3066
+ let copy;
3067
+ try {
3068
+ copy = probeAllPrimitive(args) ? new Date(probeBuiltins.getTime.call(receiver)) : void 0;
3069
+ } catch {
3070
+ }
3071
+ const result = Reflect.apply(builtin, receiver, args);
3072
+ try {
3073
+ if (copy === void 0) recordProbeOutcome(site, "unknown");
3074
+ else {
3075
+ let other, threw = false;
3076
+ try {
3077
+ other = Reflect.apply(probeBuiltins.date.get(probeSwaps[name]), copy, args);
3078
+ } catch {
3079
+ threw = true;
3080
+ }
3081
+ recordProbeOutcome(site, threw || !Object.is(result, other) ? "differs" : "same");
3082
+ }
3083
+ } catch {
3084
+ }
3085
+ return result;
3086
+ }
3087
+ function probeMathCall(site, name, args) {
3088
+ const result = Reflect.apply(probeBuiltins[name], Math, args);
3089
+ try {
3090
+ let numbers = true;
3091
+ for (const value of args) if (typeof value !== "number") numbers = false;
3092
+ if (!numbers) recordProbeOutcome(site, "unknown");
3093
+ else recordProbeOutcome(site, Object.is(result, Reflect.apply(probeBuiltins[probeSwaps[name]], Math, args)) ? "same" : "differs");
3094
+ } catch {
3095
+ }
3096
+ return result;
3097
+ }
3098
+ // `receiver.name(...)` as `methodV2(site, receiver, "name", arrow).name(...)`.
3099
+ // For a built-in receiver whose method is the built-in, the stand-in makes
3100
+ // the program's one call itself and compares Stryker's replacement; any
3101
+ // other receiver comes back unchanged and the call is the program's own.
3102
+ function methodV2(site, receiver, name, arrow, pure) {
3103
+ try {
3104
+ let call;
3105
+ if (Array.isArray(receiver)) {
3106
+ if (Object.getPrototypeOf(receiver) === probeArray && probeBuiltins.array.has(name) && receiver[name] === probeBuiltins.array.get(name))
3107
+ call = (args) => probeArrayCall(site, receiver, name, arrow, args, pure);
3108
+ } else if (typeof receiver === "string") {
3109
+ if (probeBuiltins.string.has(name) && probeString[name] === probeBuiltins.string.get(name))
3110
+ call = (args) => probeStringCall(site, receiver, name, args);
3111
+ } else if (receiver instanceof Date) {
3112
+ if (Object.getPrototypeOf(receiver) === probeDate && probeBuiltins.date.has(name) && receiver[name] === probeBuiltins.date.get(name))
3113
+ call = (args) => probeDateCall(site, receiver, name, args);
3114
+ } else if (receiver === Math) {
3115
+ if ((name === "min" || name === "max") && Math[name] === probeBuiltins[name])
3116
+ call = (args) => probeMathCall(site, name, args);
3117
+ }
3118
+ if (call !== void 0) return { [name]: (...args) => call(args) };
3119
+ } catch {
3120
+ }
3121
+ return receiver;
3122
+ }
2408
3123
  function renderedValueV2(file, index, value) {
2409
3124
  coverageHitV2(file, index);
2410
3125
  return value;
@@ -2700,6 +3415,18 @@ const directRuntimeApi = {
2700
3415
  selectionRight,
2701
3416
  selectShortV2,
2702
3417
  selectRightV2,
3418
+ compareV2,
3419
+ arithV2,
3420
+ assignV2,
3421
+ methodV2,
3422
+ valueV2,
3423
+ strongSlot,
3424
+ setActiveMutant,
3425
+ clearActiveMutant,
3426
+ setMutantHitLimit,
3427
+ mutantHitCount,
3428
+ isMutantTimeout,
3429
+ MutantTimeoutError,
2703
3430
  selectNamedRightV2,
2704
3431
  selectAssignEndV2,
2705
3432
  selectPathV2,
@@ -2770,6 +3497,18 @@ export {
2770
3497
  selectionRight,
2771
3498
  selectShortV2,
2772
3499
  selectRightV2,
3500
+ compareV2,
3501
+ arithV2,
3502
+ assignV2,
3503
+ methodV2,
3504
+ valueV2,
3505
+ strongSlot,
3506
+ setActiveMutant,
3507
+ clearActiveMutant,
3508
+ setMutantHitLimit,
3509
+ mutantHitCount,
3510
+ isMutantTimeout,
3511
+ MutantTimeoutError,
2773
3512
  selectNamedRightV2,
2774
3513
  selectAssignEndV2,
2775
3514
  selectPathV2,