mootant 0.1.0 → 0.2.0
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.
- package/dist/adapters/jest/build-dry-file.d.ts +12 -12
- package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -7
- package/dist/adapters/jest/runner.d.ts +1 -1
- package/dist/adapters/jest/runner.js +1 -1
- package/dist/adapters/jest/types/jest-record.d.ts +4 -4
- package/dist/adapters/jest/types/unit-worker.d.ts +16 -8
- package/dist/adapters/jest/types/worker-session.d.ts +6 -7
- package/dist/adapters/jest/worker/boot-worker.d.ts +4 -3
- package/dist/adapters/jest/worker/run-unit.d.ts +20 -18
- package/dist/adapters/jest/worker/vm-setup.js +1 -1
- package/dist/adapters/jest/worker/worker.js +1 -1
- package/dist/adapters/jest/write-worker-session.d.ts +1 -2
- package/dist/adapters/jest/write-worker-session.js +2 -2
- package/dist/adapters/node-test/collect-node-dependencies.d.ts +5 -5
- package/dist/adapters/node-test/preload/preload.js +4 -1
- package/dist/adapters/node-test/run-test-file.js +1 -0
- package/dist/adapters/node-test/types/node-test-record.d.ts +3 -3
- package/dist/adapters/node-test/types/node-test-unit.d.ts +6 -1
- package/dist/adapters/shared/create-input-filter.d.ts +26 -0
- package/dist/adapters/shared/create-input-filter.js +32 -0
- package/dist/adapters/shared/track-file-inputs.d.ts +7 -3
- package/dist/adapters/shared/track-file-inputs.js +16 -7
- package/dist/adapters/shared/track-file-reads.d.ts +12 -8
- package/dist/adapters/shared/track-file-reads.js +110 -57
- package/dist/adapters/shared/track-inputs.d.ts +13 -6
- package/dist/adapters/shared/track-inputs.js +7 -7
- package/dist/adapters/shared/types/file-input-tracking.d.ts +6 -0
- package/dist/adapters/shared/types/input-tracking.d.ts +3 -3
- package/dist/adapters/vitest/collect-dependencies.d.ts +4 -3
- package/dist/adapters/vitest/collect-dependencies.js +25 -24
- package/dist/adapters/vitest/get-cache-inputs.js +3 -1
- package/dist/adapters/vitest/is-virtual-module.d.ts +11 -0
- package/dist/adapters/vitest/is-virtual-module.js +8 -0
- package/dist/adapters/vitest/read-out-files.d.ts +7 -2
- package/dist/adapters/vitest/read-out-files.js +5 -5
- package/dist/adapters/vitest/read-out-records.d.ts +17 -0
- package/dist/adapters/vitest/read-out-records.js +27 -0
- package/dist/adapters/vitest/read-strays.d.ts +20 -0
- package/dist/adapters/vitest/read-strays.js +53 -0
- package/dist/adapters/vitest/read-unit-inputs.d.ts +7 -1
- package/dist/adapters/vitest/read-unit-inputs.js +1 -1
- package/dist/adapters/vitest/run-dry.js +16 -16
- package/dist/adapters/vitest/run-plan.d.ts +3 -1
- package/dist/adapters/vitest/run-plan.js +15 -15
- package/dist/adapters/vitest/run-specifications.d.ts +3 -2
- package/dist/adapters/vitest/runner.d.ts +38 -23
- package/dist/adapters/vitest/runner.js +84 -85
- package/dist/adapters/vitest/types/stray-decisions.d.ts +8 -0
- package/dist/adapters/vitest/types/unit-outcome.d.ts +2 -1
- package/dist/adapters/vitest/types/vitest-worker.d.ts +83 -12
- package/dist/adapters/vitest/worker/encode-stray.d.ts +16 -0
- package/dist/adapters/vitest/worker/encode-stray.js +16 -0
- package/dist/adapters/vitest/worker/intercept-strays.d.ts +26 -0
- package/dist/adapters/vitest/worker/intercept-strays.js +13 -0
- package/dist/adapters/vitest/worker/read-try-facts.d.ts +5 -4
- package/dist/adapters/vitest/worker/write-out-record.d.ts +2 -2
- package/dist/cli/html/build-html-report.js +1 -1
- package/dist/cli/html/client/main.js +1 -1
- package/dist/cli/html/client/render-change.d.ts +3 -2
- package/dist/cli/html/client/render-code.d.ts +1 -1
- package/dist/cli/html/pack-replacement.d.ts +1 -1
- package/dist/cli/parse-arguments.js +1 -1
- package/dist/cli/report/build-list-report.js +1 -1
- package/dist/cli/report/build-run-report.js +1 -1
- package/dist/cli/report/format-file-groups.d.ts +1 -1
- package/dist/cli/run-mutation.js +31 -31
- package/dist/cli/terminal/create-spinner.d.ts +1 -1
- package/dist/cli/terminal/get-text-style.js +4 -4
- package/dist/core/cache/get-environment-key.js +2 -2
- package/dist/core/cache/hash-files.d.ts +7 -3
- package/dist/core/cache/hash-files.js +16 -17
- package/dist/core/cache/prepare-run-cache.d.ts +29 -7
- package/dist/core/cache/prepare-run-cache.js +96 -62
- package/dist/core/cache/save-run-cache.d.ts +8 -7
- package/dist/core/cache/save-run-cache.js +2 -1
- package/dist/core/cache/unknown-hash.d.ts +7 -0
- package/dist/core/cache/unknown-hash.js +2 -0
- package/dist/core/files/select-changed-mutants.d.ts +11 -6
- package/dist/core/files/select-changed-mutants.js +38 -13
- package/dist/core/generate/apply-solitary-rule.d.ts +8 -5
- package/dist/core/generate/apply-solitary-rule.js +36 -29
- package/dist/core/generate/collect-candidates.d.ts +18 -4
- package/dist/core/generate/collect-candidates.js +168 -86
- package/dist/core/generate/compare-targets.d.ts +14 -0
- package/dist/core/generate/compare-targets.js +6 -0
- package/dist/core/generate/deduplicate-candidates.d.ts +6 -4
- package/dist/core/generate/deduplicate-candidates.js +11 -9
- package/dist/core/generate/find-list-removal.d.ts +20 -0
- package/dist/core/generate/find-list-removal.js +26 -0
- package/dist/core/generate/generate-file-mutants.js +47 -46
- package/dist/core/generate/get-mutant-site.d.ts +18 -0
- package/dist/core/generate/get-mutant-site.js +4 -0
- package/dist/core/generate/get-target.d.ts +14 -0
- package/dist/core/generate/get-target.js +4 -0
- package/dist/core/generate/pick-host.d.ts +10 -0
- package/dist/core/generate/pick-host.js +16 -0
- package/dist/core/generate/validate-replacement.d.ts +15 -4
- package/dist/core/generate/validate-replacement.js +28 -13
- package/dist/core/ignore/find-ignore-rule.d.ts +8 -7
- package/dist/core/instrument/find-attribute-values.d.ts +12 -0
- package/dist/core/instrument/find-attribute-values.js +13 -0
- package/dist/core/instrument/get-site-syntax.d.ts +14 -0
- package/dist/core/instrument/get-site-syntax.js +12 -0
- package/dist/core/instrument/group-mutant-ranges.d.ts +7 -3
- package/dist/core/instrument/group-mutant-ranges.js +25 -19
- package/dist/core/instrument/instrument-file.d.ts +5 -3
- package/dist/core/instrument/instrument-file.js +10 -9
- package/dist/core/instrument/instrumenter-version.d.ts +1 -1
- package/dist/core/instrument/render-branch.d.ts +17 -0
- package/dist/core/instrument/render-branch.js +81 -0
- package/dist/core/instrument/render-mutant-range.d.ts +17 -6
- package/dist/core/instrument/render-mutant-range.js +39 -13
- package/dist/core/list-mutants.d.ts +7 -5
- package/dist/core/list-mutants.js +2 -2
- package/dist/core/mutators/array-element.d.ts +7 -6
- package/dist/core/mutators/array-element.js +13 -13
- package/dist/core/mutators/assignment-operator.js +34 -33
- package/dist/core/mutators/boolean-literal.d.ts +3 -2
- package/dist/core/mutators/number-literal.d.ts +1 -1
- package/dist/core/mutators/object-property.d.ts +4 -3
- package/dist/core/mutators/object-property.js +7 -8
- package/dist/core/mutators/return-value.js +65 -33
- package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +12 -7
- package/dist/core/mutators/shared/get-branch-copy-skip.js +34 -35
- package/dist/core/mutators/shared/get-canonical-falsy-default.d.ts +32 -0
- package/dist/core/mutators/shared/get-canonical-falsy-default.js +11 -0
- package/dist/core/mutators/shared/get-comparison-plan.js +86 -85
- package/dist/core/mutators/shared/get-condition-constants.d.ts +8 -8
- package/dist/core/mutators/shared/get-condition-constants.js +3 -3
- package/dist/core/mutators/shared/get-endless-value.d.ts +20 -0
- package/dist/core/mutators/shared/get-endless-value.js +25 -0
- package/dist/core/mutators/shared/get-forced-test-justifier.d.ts +44 -0
- package/dist/core/mutators/shared/get-forced-test-justifier.js +25 -0
- package/dist/core/mutators/shared/get-group-constant.d.ts +4 -4
- package/dist/core/mutators/shared/get-group-constant.js +2 -2
- package/dist/core/mutators/shared/get-literal-skip.d.ts +6 -6
- package/dist/core/mutators/shared/get-literal-skip.js +2 -2
- package/dist/core/mutators/shared/get-logical-drops.d.ts +8 -8
- package/dist/core/mutators/shared/get-logical-drops.js +80 -82
- package/dist/core/mutators/shared/get-owner-constant.d.ts +3 -1
- package/dist/core/mutators/shared/get-running-value.d.ts +5 -4
- package/dist/core/mutators/shared/get-toward-mutant.d.ts +10 -2
- package/dist/core/mutators/shared/get-toward-mutant.js +45 -40
- package/dist/core/mutators/shared/has-other-exit.js +16 -36
- package/dist/core/mutators/shared/is-loop-exit.d.ts +20 -0
- package/dist/core/mutators/shared/is-loop-exit.js +32 -0
- package/dist/core/mutators/shared/is-read-only.d.ts +26 -0
- package/dist/core/mutators/shared/is-read-only.js +53 -0
- package/dist/core/mutators/statement-removal.d.ts +4 -3
- package/dist/core/mutators/statement-removal.js +69 -73
- package/dist/core/mutators/string-literal.d.ts +15 -5
- package/dist/core/mutators/string-literal.js +79 -50
- package/dist/core/presets/recommended.d.ts +2 -2
- package/dist/core/presets/strict.d.ts +4 -2
- package/dist/core/run/apply-batch-result.d.ts +23 -22
- package/dist/core/run/apply-batch-result.js +5 -5
- package/dist/core/run/apply-isolated-result.d.ts +18 -17
- package/dist/core/run/apply-isolated-result.js +1 -0
- package/dist/core/run/classify-try.d.ts +9 -8
- package/dist/core/run/get-test-file-limits.d.ts +13 -0
- package/dist/core/run/get-test-file-limits.js +13 -0
- package/dist/core/run/get-unit-evidence.d.ts +6 -3
- package/dist/core/run/get-unit-evidence.js +1 -1
- package/dist/core/run/plan-batch.d.ts +6 -3
- package/dist/core/run/plan-batch.js +36 -31
- package/dist/core/run/plan-isolated.d.ts +3 -1
- package/dist/core/run/plan-isolated.js +8 -14
- package/dist/core/run/read-isolated-unit.d.ts +4 -4
- package/dist/core/run/run-batch-phases.d.ts +4 -3
- package/dist/core/run/run-dry-phase.d.ts +35 -19
- package/dist/core/run/run-dry-phase.js +127 -77
- package/dist/core/run/run-isolated-rounds.d.ts +6 -5
- package/dist/core/run/run-isolated-rounds.js +1 -0
- package/dist/core/run-mutants.d.ts +26 -21
- package/dist/core/run-mutants.js +72 -64
- package/dist/core/runtime/create-hit-limit-error.d.ts +5 -3
- package/dist/core/runtime/create-hit-limit-error.js +1 -1
- package/dist/core/runtime/install-mutant-runtime.js +23 -6
- package/dist/core/runtime/runtime-version.d.ts +4 -4
- package/dist/core/skips/skip-rules.d.ts +4 -0
- package/dist/core/skips/skip-rules.js +4 -0
- package/dist/core/syntax/is-brace-sensitive-attribute.d.ts +18 -0
- package/dist/core/syntax/is-brace-sensitive-attribute.js +28 -0
- package/dist/core/syntax/is-spread-safe-member.d.ts +18 -0
- package/dist/core/syntax/is-spread-safe-member.js +18 -0
- package/dist/core/syntax/is-value-position.d.ts +3 -1
- package/dist/core/text/get-list-removal-range.d.ts +22 -0
- package/dist/core/text/get-list-removal-range.js +46 -0
- package/dist/core/text/is-plain-attribute-string.d.ts +10 -0
- package/dist/core/text/is-plain-attribute-string.js +5 -0
- package/dist/core/text/parse-expression.d.ts +8 -4
- package/dist/core/text/parse-expression.js +1 -0
- package/dist/core/text/remove-list-element.d.ts +2 -4
- package/dist/core/text/remove-list-element.js +4 -45
- package/dist/docs/styles/colors.js +1 -1
- package/dist/package.js +1 -1
- package/dist/types/adapter/dry-file.d.ts +2 -1
- package/dist/types/adapter/dry-run-request.d.ts +5 -4
- package/dist/types/adapter/mutant-runtime.d.ts +30 -1
- package/dist/types/cli/text-style.d.ts +1 -1
- package/dist/types/config/preset-settings.d.ts +2 -2
- package/dist/types/config/run-config.d.ts +12 -4
- package/dist/types/html/indexed-mutant.d.ts +4 -2
- package/dist/types/html/shown-change.d.ts +4 -3
- package/dist/types/mutant/list-removal.d.ts +37 -0
- package/dist/types/mutant/mutant-candidate.d.ts +11 -17
- package/dist/types/mutant/mutant-host.d.ts +49 -0
- package/dist/types/mutant/mutant-kind.d.ts +18 -0
- package/dist/types/mutant/mutant-range.d.ts +15 -8
- package/dist/types/mutant/mutant.d.ts +9 -15
- package/dist/types/mutant/site-syntax.d.ts +14 -0
- package/dist/types/mutant/skip-justifier.d.ts +3 -1
- package/dist/types/mutant/skipped-candidate.d.ts +13 -10
- package/dist/types/mutant/skipped-mutant.d.ts +9 -6
- package/dist/types/mutator/replacement.d.ts +14 -3
- package/dist/types/report/html-report.d.ts +10 -7
- package/dist/types/report/list-report-focus.d.ts +3 -2
- package/dist/types/report/list-report-justifier.d.ts +4 -2
- package/dist/types/report/list-report-mutant.d.ts +15 -9
- package/dist/types/report/list-report-skipped.d.ts +3 -2
- package/dist/types/report/list-report.d.ts +1 -1
- package/dist/types/report/run-report.d.ts +2 -2
- package/dist/types/report/slim-list-report.d.ts +6 -3
- package/dist/types/report/slim-run-report.d.ts +1 -1
- package/dist/types/run/isolated-reason.d.ts +4 -3
- package/dist/types/run/mutant-state.d.ts +1 -1
- package/dist/types/run/run-event.d.ts +1 -1
- package/dist/types/run/run-kind.d.ts +3 -2
- package/dist/types/run/run-result.d.ts +6 -3
- package/dist/types/run/run-state.d.ts +9 -1
- package/dist/types/run/run-status.d.ts +2 -2
- package/dist/types/run/try-cause.d.ts +8 -6
- package/dist/types/syntax/syntax-helpers.d.ts +5 -3
- package/package.json +5 -5
- package/skills/mootant/SKILL.md +14 -12
- package/skills/mootant/references/mutators.md +3 -1
- package/dist/core/instrument/get-site-check.d.ts +0 -9
- package/dist/core/instrument/get-site-check.js +0 -5
- package/dist/core/instrument/get-template-site-check.d.ts +0 -12
- package/dist/core/instrument/get-template-site-check.js +0 -5
- /package/dist/cli/{built-in-adapters.d.ts → get-built-in-adapters.d.ts} +0 -0
- /package/dist/cli/{built-in-adapters.js → get-built-in-adapters.js} +0 -0
- /package/dist/cli/terminal/{colors.d.ts → create-colors.d.ts} +0 -0
- /package/dist/cli/terminal/{colors.js → create-colors.js} +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { isExpressionWrapper as e } from "../tree/is-expression-wrapper.js";
|
|
2
|
+
import { parseExpression as t } from "../text/parse-expression.js";
|
|
3
|
+
const n = [
|
|
4
|
+
"ts",
|
|
5
|
+
"tsx",
|
|
6
|
+
"jsx"
|
|
7
|
+
], r = /^\s*<!--/u;
|
|
8
|
+
function i(e) {
|
|
9
|
+
let r = `(${e})`;
|
|
10
|
+
if (!e.includes("<!--")) return r;
|
|
11
|
+
for (let i of n) {
|
|
12
|
+
let n = t(e, i);
|
|
13
|
+
if (n?.type === "ParenthesizedExpression") {
|
|
14
|
+
let e = o(n);
|
|
15
|
+
if (e === null) return r;
|
|
16
|
+
let t = e - n.start + 1;
|
|
17
|
+
return `${r.slice(0, t)}0, ${r.slice(t)}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return r;
|
|
21
|
+
}
|
|
22
|
+
function a(t) {
|
|
23
|
+
if (e(t) || t.type === "ChainExpression") return {
|
|
24
|
+
node: t.expression,
|
|
25
|
+
value: null
|
|
26
|
+
};
|
|
27
|
+
switch (t.type) {
|
|
28
|
+
case "TaggedTemplateExpression": return {
|
|
29
|
+
node: t.tag,
|
|
30
|
+
value: !1
|
|
31
|
+
};
|
|
32
|
+
case "ConditionalExpression": return {
|
|
33
|
+
node: t.test,
|
|
34
|
+
value: !0
|
|
35
|
+
};
|
|
36
|
+
case "AssignmentExpression": return {
|
|
37
|
+
node: t.left,
|
|
38
|
+
value: !1
|
|
39
|
+
};
|
|
40
|
+
case "SequenceExpression": return {
|
|
41
|
+
node: t.expressions[0],
|
|
42
|
+
value: !0
|
|
43
|
+
};
|
|
44
|
+
case "LogicalExpression":
|
|
45
|
+
case "BinaryExpression": return {
|
|
46
|
+
node: t.left,
|
|
47
|
+
value: !0
|
|
48
|
+
};
|
|
49
|
+
case "UpdateExpression": return t.prefix ? null : {
|
|
50
|
+
node: t.argument,
|
|
51
|
+
value: !1
|
|
52
|
+
};
|
|
53
|
+
case "MemberExpression": return {
|
|
54
|
+
node: t.object,
|
|
55
|
+
value: !0
|
|
56
|
+
};
|
|
57
|
+
case "CallExpression": return {
|
|
58
|
+
node: t.callee,
|
|
59
|
+
value: !1
|
|
60
|
+
};
|
|
61
|
+
default: return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function o(e) {
|
|
65
|
+
let t = {
|
|
66
|
+
start: e.start,
|
|
67
|
+
value: !0
|
|
68
|
+
}, n = !0, i = e, o = a(i);
|
|
69
|
+
for (; o !== null;) {
|
|
70
|
+
let { node: e } = o;
|
|
71
|
+
n = o.value ?? n, e.type === "ParenthesizedExpression" ? t = {
|
|
72
|
+
start: e.start,
|
|
73
|
+
value: n
|
|
74
|
+
} : i.type !== "ParenthesizedExpression" && e.start !== i.start && (t = {
|
|
75
|
+
start: e.start,
|
|
76
|
+
value: !1
|
|
77
|
+
}), i = e, o = a(i);
|
|
78
|
+
}
|
|
79
|
+
return i.type === "Literal" && "regex" in i && r.test(i.regex.pattern) && t.value ? t.start : null;
|
|
80
|
+
}
|
|
81
|
+
export { i as renderBranch };
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import { MutantRange } from '../../types/mutant/mutant-range.js';
|
|
2
|
+
import { SiteSyntax } from '../../types/mutant/site-syntax.js';
|
|
2
3
|
/**
|
|
3
4
|
* Renders the host of one group of mutants, the hosts of its nested groups
|
|
4
5
|
* first. An expression group becomes a chain of conditional expressions, a
|
|
5
6
|
* block group a chain of `if` statements; the last branch holds the original
|
|
6
|
-
* text with the nested hosts in it, and replacement texts are used verbatim.
|
|
7
|
-
*
|
|
8
|
-
* of
|
|
7
|
+
* text with the nested hosts in it, and replacement texts are used verbatim.
|
|
8
|
+
* The branches of an expression group are in parentheses (see `renderBranch`).
|
|
9
|
+
* A group of removals of array elements or object members becomes one
|
|
10
|
+
* conditional expression around their literal: while none of them is active it
|
|
11
|
+
* runs the literal as written, with the nested hosts in it, and otherwise a
|
|
12
|
+
* copy of the literal that leaves the active element out (see `renderCopy`). An
|
|
13
|
+
* expression group or a group of removals that starts a statement of a
|
|
14
|
+
* statement list gets the guard of that statement in front. An expression group
|
|
15
|
+
* at a quoted JSX attribute value is hosted in braces, where a conditional
|
|
16
|
+
* expression may stand for the value.
|
|
9
17
|
*
|
|
10
18
|
* @param range - Group to render.
|
|
11
19
|
* @param source - Text of the file the mutants belong to.
|
|
12
20
|
* @param context - Where the group sits.
|
|
13
21
|
* @param context.statementStarts - Guards by the offsets where the expression
|
|
14
22
|
* statements of statement lists start (see `findStatementStarts`).
|
|
15
|
-
* @param context.
|
|
16
|
-
*
|
|
23
|
+
* @param context.attributeValues - Offsets where quoted JSX attribute values
|
|
24
|
+
* start (see `findAttributeValues`); none when omitted.
|
|
25
|
+
* @param context.syntax - How the code reaches the mutant runtime; the syntax
|
|
26
|
+
* of script code when omitted.
|
|
17
27
|
* @returns Text that replaces the range in the switched file.
|
|
18
28
|
*/
|
|
19
29
|
export declare function renderMutantRange(range: MutantRange, source: string, context: {
|
|
20
30
|
statementStarts: ReadonlyMap<number, string>;
|
|
21
|
-
|
|
31
|
+
attributeValues?: ReadonlySet<number>;
|
|
32
|
+
syntax?: SiteSyntax;
|
|
22
33
|
}): string;
|
|
@@ -1,18 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { getSiteSyntax as e } from "./get-site-syntax.js";
|
|
2
|
+
import { renderBranch as t } from "./render-branch.js";
|
|
3
|
+
function n(t, n, i) {
|
|
4
|
+
return r(t, n, {
|
|
5
|
+
attributeValues: i.attributeValues ?? /* @__PURE__ */ new Set(),
|
|
6
|
+
syntax: i.syntax ?? e(!1),
|
|
5
7
|
statementStarts: i.statementStarts,
|
|
6
8
|
guarded: !0
|
|
7
9
|
});
|
|
8
10
|
}
|
|
9
|
-
function
|
|
10
|
-
let { statementStarts:
|
|
11
|
-
for (let
|
|
12
|
-
guarded: e.kind === "block" ||
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
function r(e, n, a) {
|
|
12
|
+
let { attributeValues: o, statementStarts: s, guarded: c, syntax: l } = a, { runtime: u, quote: d } = l, f = "", p = e.start;
|
|
13
|
+
for (let t of e.children) f += n.slice(p, t.start), f += r(t, n, {
|
|
14
|
+
guarded: e.kind === "block" || t.start !== e.start,
|
|
15
|
+
attributeValues: o,
|
|
16
|
+
statementStarts: s,
|
|
17
|
+
syntax: l
|
|
18
|
+
}), p = t.end;
|
|
19
|
+
if (f += n.slice(p, e.end), e.kind === "block") return `{ ${e.mutants.map((e) => `if (${u}?.hit(${d(e.id)})) {${e.replacement}}`).join(" else ")} else {${f}} }`;
|
|
20
|
+
let m = c ? s.get(e.start) ?? "" : "";
|
|
21
|
+
if (e.kind !== "expression") return `${m}(${u}?.hitAny([${e.mutants.map((e) => d(e.id)).join(", ")}]) ? ${i(e, n, l)} : ${f})`;
|
|
22
|
+
let h = `${m}(${e.mutants.map((e) => `${u}?.hit(${d(e.id)}) ? ${t(e.replacement)} : `).join("")}${t(f)})`;
|
|
23
|
+
return o.has(e.start) ? `{${h}}` : h;
|
|
17
24
|
}
|
|
18
|
-
|
|
25
|
+
function i(e, t, n) {
|
|
26
|
+
let { runtime: r, quote: i } = n, o = e.mutants.filter(a), s = /* @__PURE__ */ new Map();
|
|
27
|
+
for (let { focus: e, id: t } of o) {
|
|
28
|
+
let n = s.get(e.start);
|
|
29
|
+
n === void 0 ? s.set(e.start, {
|
|
30
|
+
ids: [t],
|
|
31
|
+
focus: e
|
|
32
|
+
}) : n.ids.push(t);
|
|
33
|
+
}
|
|
34
|
+
let c = [...s.values()].toSorted((e, t) => e.focus.start - t.focus.start), l = "", u = e.start;
|
|
35
|
+
for (let { focus: n, ids: a } of c) {
|
|
36
|
+
let o = a.map((e) => `${r}.active === ${i(e)}`).join(" || "), s = t.slice(n.start, n.end);
|
|
37
|
+
l += t.slice(u, n.start), e.kind === "property" ? l += `...(${o} ? {} : { ${s} })` : s.startsWith("...") ? l += `...(${o} ? ${r}.none : ${s.slice(3)})` : l += `(${o} ? ${r}.gap : ${s})`, u = n.end;
|
|
38
|
+
}
|
|
39
|
+
return l += t.slice(u, e.end), e.kind === "property" ? l : `${r}.cut(${l})`;
|
|
40
|
+
}
|
|
41
|
+
function a(e) {
|
|
42
|
+
return e.kind === "element" || e.kind === "property";
|
|
43
|
+
}
|
|
44
|
+
export { n as renderMutantRange };
|
|
@@ -24,7 +24,8 @@ interface ListMutantsOptions {
|
|
|
24
24
|
preset?: string;
|
|
25
25
|
/**
|
|
26
26
|
* Git revision given with `--since`: only mutants on lines changed since its
|
|
27
|
-
* merge base with `HEAD` are listed
|
|
27
|
+
* merge base with `HEAD` are listed, and the mutants that skipped candidates
|
|
28
|
+
* on those lines are left to.
|
|
28
29
|
*/
|
|
29
30
|
since?: string;
|
|
30
31
|
/**
|
|
@@ -37,10 +38,11 @@ interface ListMutantsOptions {
|
|
|
37
38
|
* and its plugins, resolves the presets, expands the paths with display paths
|
|
38
39
|
* relative to the project root, reads every file and generates its mutants one
|
|
39
40
|
* file at a time. A file that cannot be read or parsed is reported and the
|
|
40
|
-
* others are still listed. Skipped candidates are
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* are
|
|
41
|
+
* others are still listed. Skipped candidates are listed only on request. With
|
|
42
|
+
* `--since`, only the mutants and skipped candidates on lines changed since the
|
|
43
|
+
* merge base of the revision and `HEAD` are listed, with the mutants that those
|
|
44
|
+
* skipped candidates are left to, and only the changed files (see
|
|
45
|
+
* `selectChangedMutants`).
|
|
44
46
|
*
|
|
45
47
|
* @param options - Paths, configuration, preset and working directory of the
|
|
46
48
|
* run.
|
|
@@ -4,20 +4,20 @@ import { listFileMutants as n } from "./files/list-file-mutants.js";
|
|
|
4
4
|
import { prepareRun as r } from "./config/prepare-run.js";
|
|
5
5
|
async function i(i) {
|
|
6
6
|
let { knownMutatorIds: a, mutators: o, settings: s, preset: c, root: l } = await r(i), u = i.skipped ?? !1, d = i.since === void 0 ? null : await t(l, i.since), { diagnostics: f, files: p } = await n({
|
|
7
|
+
skipped: u || d !== null,
|
|
7
8
|
paths: i.paths,
|
|
8
9
|
cwd: i.cwd,
|
|
9
10
|
knownMutatorIds: a,
|
|
10
11
|
settings: s,
|
|
11
12
|
mutators: o,
|
|
12
|
-
skipped: u,
|
|
13
13
|
root: l
|
|
14
14
|
});
|
|
15
15
|
return {
|
|
16
|
+
files: d === null ? p : e(p, d.files, u),
|
|
16
17
|
since: d === null ? null : {
|
|
17
18
|
ref: i.since,
|
|
18
19
|
base: d.base
|
|
19
20
|
},
|
|
20
|
-
files: d === null ? p : e(p, d.files),
|
|
21
21
|
diagnostics: f,
|
|
22
22
|
mutators: o,
|
|
23
23
|
skipped: u,
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Mutator } from '../../types/mutator/mutator.js';
|
|
2
2
|
/**
|
|
3
3
|
* Removes one element from an array literal, or puts undefined into an empty
|
|
4
|
-
* one (catalog 4.2).
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
4
|
+
* one (catalog 4.2). A removal replaces the element with an empty text, which
|
|
5
|
+
* removes it with its comma. Each removal (T6) is solitary over the removed
|
|
6
|
+
* element, so the pipeline drops it while a mutant inside the element will run.
|
|
7
|
+
* Arrays with holes get nothing; the `[undefined]` of the empty dependency list
|
|
8
|
+
* of a React hook, and of an array that is only pushed to and joined with an
|
|
9
|
+
* empty separator (see `isJoinedArray`), follows as a skipped replacement when
|
|
10
|
+
* the name `undefined` surely holds the global value (see `isGlobalName`): a
|
|
10
11
|
* parameter, a local or a declaration that another script block of a component
|
|
11
12
|
* makes may give it any value.
|
|
12
13
|
*/
|
|
@@ -2,27 +2,27 @@ import { getCalleeName as e } from "../tree/get-callee-name.js";
|
|
|
2
2
|
const t = /^use[0-9A-Z]/u;
|
|
3
3
|
let n = {
|
|
4
4
|
create(e) {
|
|
5
|
-
let {
|
|
6
|
-
return { ArrayExpression(
|
|
7
|
-
let { elements:
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
10
|
-
let
|
|
5
|
+
let { syntax: t } = e;
|
|
6
|
+
return { ArrayExpression(n) {
|
|
7
|
+
let { elements: i } = n;
|
|
8
|
+
if (i.includes(null)) return [];
|
|
9
|
+
if (i.length === 0) {
|
|
10
|
+
let i = {
|
|
11
11
|
text: "[undefined]",
|
|
12
|
-
node:
|
|
12
|
+
node: n
|
|
13
13
|
};
|
|
14
|
-
return
|
|
14
|
+
return t.isGlobalName("undefined") && (r(n, e) ? i.skip = {
|
|
15
15
|
reason: "an empty hook dependency list and [undefined] never change, so the hook behaves the same",
|
|
16
16
|
rule: "hook-dependencies"
|
|
17
|
-
} :
|
|
17
|
+
} : t.isJoinedArray(n) && (i.skip = {
|
|
18
18
|
reason: "the array is only pushed to and joined with '', which writes undefined as an empty string",
|
|
19
19
|
rule: "joined-array"
|
|
20
|
-
})), [
|
|
20
|
+
})), [i];
|
|
21
21
|
}
|
|
22
|
-
return
|
|
23
|
-
text: t.removeListElement(i, n),
|
|
22
|
+
return i.map((e) => ({
|
|
24
23
|
solitary: [e],
|
|
25
|
-
node:
|
|
24
|
+
node: e,
|
|
25
|
+
text: ""
|
|
26
26
|
}));
|
|
27
27
|
} };
|
|
28
28
|
},
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getCanonicalFalsyDefault as e } from "./shared/get-canonical-falsy-default.js";
|
|
2
|
+
import { distinguishesNullishSwap as t } from "./shared/distinguishes-nullish-swap.js";
|
|
3
3
|
import { isAlwaysNullish as n } from "./shared/is-always-nullish.js";
|
|
4
4
|
import { getLiteralValue as r } from "./shared/get-literal-value.js";
|
|
5
5
|
import { isAlwaysTruthy as i } from "./shared/is-always-truthy.js";
|
|
6
6
|
import { isNumericPair as a } from "./shared/is-numeric-pair.js";
|
|
7
7
|
import { isNumberType as o } from "./shared/is-number-type.js";
|
|
8
8
|
import { mayBeNullish as s } from "./shared/may-be-nullish.js";
|
|
9
|
-
|
|
10
|
-
let l = /* @__PURE__ */ new Map([
|
|
9
|
+
let c = /* @__PURE__ */ new Map([
|
|
11
10
|
[">>>=", ">>="],
|
|
12
11
|
["<<=", ">>="],
|
|
13
12
|
[">>=", "<<="],
|
|
@@ -20,7 +19,7 @@ let l = /* @__PURE__ */ new Map([
|
|
|
20
19
|
["&=", "|="],
|
|
21
20
|
["|=", "&="],
|
|
22
21
|
["^=", "|="]
|
|
23
|
-
]),
|
|
22
|
+
]), l = /* @__PURE__ */ new Map([
|
|
24
23
|
["*=", /* @__PURE__ */ new Set([
|
|
25
24
|
-1n,
|
|
26
25
|
-1,
|
|
@@ -39,7 +38,7 @@ let l = /* @__PURE__ */ new Map([
|
|
|
39
38
|
["+=", /* @__PURE__ */ new Set([0n, 0])],
|
|
40
39
|
["-=", /* @__PURE__ */ new Set([0n, 0])],
|
|
41
40
|
["^=", /* @__PURE__ */ new Set([0n, 0])]
|
|
42
|
-
]),
|
|
41
|
+
]), u = {
|
|
43
42
|
create(e) {
|
|
44
43
|
let { settings: t, syntax: n } = e;
|
|
45
44
|
return { AssignmentExpression(r) {
|
|
@@ -60,25 +59,25 @@ let l = /* @__PURE__ */ new Map([
|
|
|
60
59
|
defaultOptions: { nullishSwap: "distinguishing" }
|
|
61
60
|
}
|
|
62
61
|
};
|
|
63
|
-
function
|
|
64
|
-
let { right: i, left: a } =
|
|
62
|
+
function d(e, r) {
|
|
63
|
+
let { right: i, left: a } = e, o = r.hints.getType(a), c = s(o), l = t({
|
|
65
64
|
right: i,
|
|
66
65
|
left: a
|
|
67
66
|
}, r.hints, r.options.nullishSwap), u = n(o) ? {
|
|
68
67
|
reason: "the type hints make the target always nullish, so the guard changes nothing",
|
|
69
68
|
rule: "typed-constant"
|
|
70
|
-
} : null, d =
|
|
69
|
+
} : null, d = p(e, o, r), f = {
|
|
71
70
|
reason: "??= and ||= differ here only on falsy values that the nullishSwap option does not count, such as the value itself",
|
|
72
71
|
rule: "nullish-swap"
|
|
73
|
-
},
|
|
72
|
+
}, m = {
|
|
74
73
|
reason: "every test that kills the swap between ??= and ||= also kills this change",
|
|
75
74
|
by: {
|
|
76
75
|
mutator: "assignment-operator",
|
|
77
|
-
node:
|
|
76
|
+
node: e
|
|
78
77
|
},
|
|
79
78
|
rule: "swap-subsumes-drop"
|
|
80
79
|
};
|
|
81
|
-
switch (
|
|
80
|
+
switch (e.operator) {
|
|
82
81
|
case "&&=": return [{
|
|
83
82
|
operator: "=",
|
|
84
83
|
skip: d
|
|
@@ -95,7 +94,7 @@ function f(t, r) {
|
|
|
95
94
|
operator: "??=",
|
|
96
95
|
skip: null
|
|
97
96
|
}, {
|
|
98
|
-
skip:
|
|
97
|
+
skip: m,
|
|
99
98
|
operator: null
|
|
100
99
|
}) : (c && e.push({
|
|
101
100
|
skip: f,
|
|
@@ -114,7 +113,7 @@ function f(t, r) {
|
|
|
114
113
|
operator: "||="
|
|
115
114
|
},
|
|
116
115
|
{
|
|
117
|
-
skip: l ?
|
|
116
|
+
skip: l ? m : u,
|
|
118
117
|
operator: "="
|
|
119
118
|
},
|
|
120
119
|
{
|
|
@@ -127,14 +126,14 @@ function f(t, r) {
|
|
|
127
126
|
];
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
|
-
function
|
|
131
|
-
let { operator: i, right: s, left: c } = e,
|
|
132
|
-
if (i === "+=" && !a(
|
|
129
|
+
function f(e, t, n) {
|
|
130
|
+
let { operator: i, right: s, left: c } = e, u = n.hints.getType(c);
|
|
131
|
+
if (i === "+=" && !a(u, n.hints.getType(s))) return {
|
|
133
132
|
reason: "the += is not known to be numeric, and -= on a string only gives NaN",
|
|
134
133
|
rule: "non-numeric-plus"
|
|
135
134
|
};
|
|
136
135
|
let d = r(s);
|
|
137
|
-
if (d !== null &&
|
|
136
|
+
if (d !== null && l.get(i)?.has(d) && (i !== "-=" || o(u))) {
|
|
138
137
|
let e = i === "+=" || i === "-=";
|
|
139
138
|
return {
|
|
140
139
|
reason: `with the value ${String(d)}, ${i} and ${t} give the same result`,
|
|
@@ -143,10 +142,21 @@ function p(e, t, n) {
|
|
|
143
142
|
}
|
|
144
143
|
return null;
|
|
145
144
|
}
|
|
145
|
+
function p(t, n, r) {
|
|
146
|
+
if (i(n)) return {
|
|
147
|
+
reason: "the type hints make the target always truthy, so its truth never changes the result",
|
|
148
|
+
rule: "typed-constant"
|
|
149
|
+
};
|
|
150
|
+
let a = e(t.left, t.right, r);
|
|
151
|
+
return a && {
|
|
152
|
+
reason: a.because === null ? "the assigned value is the only falsy value of the target's type, so the target's truth never changes the result" : `the assigned value is the only falsy value of the target, which is never NaN (${a.because}), so the target's truth never changes the result`,
|
|
153
|
+
rule: "canonical-falsy-default"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
146
156
|
function m(e, t) {
|
|
147
|
-
let { sourceCode: n } = t, r =
|
|
157
|
+
let { sourceCode: n } = t, r = c.get(e.operator);
|
|
148
158
|
if (r !== void 0) {
|
|
149
|
-
let i = n.replaceOperator(e, r), a =
|
|
159
|
+
let i = n.replaceOperator(e, r), a = f(e, r, t);
|
|
150
160
|
return [a ? {
|
|
151
161
|
text: i,
|
|
152
162
|
skip: a,
|
|
@@ -156,8 +166,8 @@ function m(e, t) {
|
|
|
156
166
|
node: e
|
|
157
167
|
}];
|
|
158
168
|
}
|
|
159
|
-
return
|
|
160
|
-
let i = t === null ?
|
|
169
|
+
return d(e, t).map(({ operator: t, skip: r }) => {
|
|
170
|
+
let i = t === null ? h(e, n) : n.replaceOperator(e, t);
|
|
161
171
|
return r ? {
|
|
162
172
|
text: i,
|
|
163
173
|
skip: r,
|
|
@@ -168,16 +178,7 @@ function m(e, t) {
|
|
|
168
178
|
};
|
|
169
179
|
});
|
|
170
180
|
}
|
|
171
|
-
function h(e,
|
|
172
|
-
return i(e) ? {
|
|
173
|
-
reason: "the type hints make the target always truthy, so its truth never changes the result",
|
|
174
|
-
rule: "typed-constant"
|
|
175
|
-
} : !s(e) && t(c(e).type, n) ? {
|
|
176
|
-
reason: "the assigned value is the only falsy value of the target's type, so the target's truth never changes the result",
|
|
177
|
-
rule: "canonical-falsy-default"
|
|
178
|
-
} : null;
|
|
179
|
-
}
|
|
180
|
-
function g(e, t) {
|
|
181
|
+
function h(e, t) {
|
|
181
182
|
let { comments: n, text: r } = t, i = t.getOperatorRange(e).start, a = "";
|
|
182
183
|
for (let t = e.left.end; t < i; t++) {
|
|
183
184
|
let e = n.find(({ start: e }) => e === t);
|
|
@@ -185,4 +186,4 @@ function g(e, t) {
|
|
|
185
186
|
}
|
|
186
187
|
return r.slice(e.start, e.left.end) + a;
|
|
187
188
|
}
|
|
188
|
-
export {
|
|
189
|
+
export { u as assignmentOperator };
|
|
@@ -8,7 +8,8 @@ import { Mutator } from '../../types/mutator/mutator.js';
|
|
|
8
8
|
* boolean-valued branch, when the test's owner emits that constant (O19) or a
|
|
9
9
|
* mutant that will run moves the test toward it (R5); the right operand of a
|
|
10
10
|
* value-mode `L || true` with a nullable boolean `L` while the `??` swap will
|
|
11
|
-
* run (R7); and a flip
|
|
12
|
-
* setting is on (TIMEOUT). A skipped
|
|
11
|
+
* run (R7); and a flip that may keep a loop running forever (see
|
|
12
|
+
* `getEndlessValue`) unless the `timeouts` setting is on (TIMEOUT). A skipped
|
|
13
|
+
* flip follows as a skipped replacement.
|
|
13
14
|
*/
|
|
14
15
|
export declare let booleanLiteral: Mutator;
|
|
@@ -13,7 +13,7 @@ interface NumberLiteralOptions {
|
|
|
13
13
|
* `-` applied directly to one, gets its value plus one (T7). Comparison
|
|
14
14
|
* operands, boolean-mode operands, `void` operands, keys and (unless the
|
|
15
15
|
* `caseTests` option is set) case labels are skipped, and so are changes that
|
|
16
|
-
* keep the truth value in a boolean context, that
|
|
16
|
+
* keep the truth value in a boolean context, that may cause a timeout, that
|
|
17
17
|
* keep the sign of a sort comparator's result, or that another mutant owns or
|
|
18
18
|
* subsumes (branch pairs, no-op callbacks, emptied `||` defaults, `slice(-1)`).
|
|
19
19
|
* A skipped change follows as a skipped replacement. Timer delays are skipped
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Mutator } from '../../types/mutator/mutator.js';
|
|
2
2
|
/**
|
|
3
|
-
* Removes one property or spread from an object literal (catalog 4.12)
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Removes one property or spread from an object literal (catalog 4.12): the
|
|
4
|
+
* replacement of a member with an empty text, which removes it with its comma.
|
|
5
|
+
* Each removal (T6) is solitary over the removed member, so the pipeline drops
|
|
6
|
+
* it while a mutant inside the member will run. Removing an option of an `Intl`
|
|
6
7
|
* constructor that holds the default value is skipped as equivalent
|
|
7
8
|
* (`getDefaultOptionSkip`).
|
|
8
9
|
*/
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { getDefaultOptionSkip as e } from "./shared/get-default-option-skip.js";
|
|
2
2
|
let t = {
|
|
3
3
|
create(t) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let o = e(i, r, t);
|
|
4
|
+
return { ObjectExpression(n) {
|
|
5
|
+
return n.properties.map((r) => {
|
|
6
|
+
let i = e(r, n, t);
|
|
8
7
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
...i && { skip: i },
|
|
9
|
+
solitary: [r],
|
|
10
|
+
node: r,
|
|
11
|
+
text: ""
|
|
13
12
|
};
|
|
14
13
|
});
|
|
15
14
|
} };
|