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
|
@@ -1,64 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getForcedTestJustifier as e } from "./shared/get-forced-test-justifier.js";
|
|
2
|
+
import { isPlainReturnValue as t } from "./shared/is-plain-return-value.js";
|
|
3
3
|
import { createRunContext as n } from "./shared/create-run-context.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
let s = /* @__PURE__ */ new Set([
|
|
4
|
+
import { isTailPosition as r } from "./shared/is-tail-position.js";
|
|
5
|
+
import { isEffectFree as i } from "../syntax/is-effect-free.js";
|
|
6
|
+
import { isTimerWait as a } from "./shared/is-timer-wait.js";
|
|
7
|
+
let o = /* @__PURE__ */ new Set([
|
|
9
8
|
"AssignmentExpression",
|
|
10
9
|
"UpdateExpression",
|
|
11
10
|
"AwaitExpression",
|
|
12
11
|
"NewExpression"
|
|
13
|
-
]),
|
|
12
|
+
]), s = /* @__PURE__ */ new Set([
|
|
14
13
|
"DoWhileStatement",
|
|
15
14
|
"ForInStatement",
|
|
16
15
|
"ForOfStatement",
|
|
17
16
|
"WhileStatement",
|
|
18
17
|
"ForStatement"
|
|
19
|
-
]),
|
|
20
|
-
create(
|
|
21
|
-
let { jumps: n } =
|
|
18
|
+
]), c = {
|
|
19
|
+
create(e) {
|
|
20
|
+
let { jumps: n } = e.options;
|
|
22
21
|
return {
|
|
23
|
-
BreakStatement(
|
|
24
|
-
let i =
|
|
25
|
-
return i ?
|
|
26
|
-
context:
|
|
27
|
-
skip:
|
|
22
|
+
BreakStatement(t, r) {
|
|
23
|
+
let i = t.label ? null : f(t, e);
|
|
24
|
+
return i ? v(t, r, {
|
|
25
|
+
context: e,
|
|
26
|
+
skip: m(i, e) ? {
|
|
28
27
|
reason: "falling through the case reaches only a break",
|
|
29
28
|
rule: "fall-through-break"
|
|
30
29
|
} : null
|
|
31
|
-
}) : n ?
|
|
30
|
+
}) : n ? v(t, r, {
|
|
32
31
|
skip: null,
|
|
33
|
-
context:
|
|
32
|
+
context: e
|
|
34
33
|
}) : [];
|
|
35
34
|
},
|
|
36
|
-
ReturnStatement(n,
|
|
37
|
-
let a = n.argument ?
|
|
38
|
-
return a && !
|
|
39
|
-
context:
|
|
40
|
-
skip:
|
|
35
|
+
ReturnStatement(n, i) {
|
|
36
|
+
let a = n.argument ? e.syntax.unwrapExpression(n.argument) : null;
|
|
37
|
+
return a && !t(a, e) ? [] : v(n, i, {
|
|
38
|
+
context: e,
|
|
39
|
+
skip: r(n, e) ? g(a, e) : null
|
|
41
40
|
});
|
|
42
41
|
},
|
|
43
|
-
ContinueStatement(
|
|
44
|
-
return n ?
|
|
45
|
-
context:
|
|
46
|
-
skip:
|
|
42
|
+
ContinueStatement(t, r) {
|
|
43
|
+
return n ? v(t, r, {
|
|
44
|
+
context: e,
|
|
45
|
+
skip: h(t, e) ? {
|
|
47
46
|
reason: "the continue ends the body of its loop",
|
|
48
47
|
rule: "loop-end"
|
|
49
48
|
} : null
|
|
50
49
|
}) : [];
|
|
51
50
|
},
|
|
52
|
-
ExpressionStatement(
|
|
53
|
-
return
|
|
54
|
-
skip:
|
|
55
|
-
context:
|
|
51
|
+
ExpressionStatement(t, n) {
|
|
52
|
+
return u(t, e) ? v(t, n, {
|
|
53
|
+
skip: p(t, e),
|
|
54
|
+
context: e
|
|
56
55
|
}) : [];
|
|
57
56
|
},
|
|
58
|
-
ThrowStatement(
|
|
59
|
-
return
|
|
57
|
+
ThrowStatement(t, n) {
|
|
58
|
+
return v(t, n, {
|
|
60
59
|
skip: null,
|
|
61
|
-
context:
|
|
60
|
+
context: e
|
|
62
61
|
});
|
|
63
62
|
}
|
|
64
63
|
};
|
|
@@ -68,30 +67,27 @@ let s = /* @__PURE__ */ new Set([
|
|
|
68
67
|
defaultOptions: { jumps: !1 }
|
|
69
68
|
}
|
|
70
69
|
};
|
|
71
|
-
function
|
|
72
|
-
let { sourceCode:
|
|
73
|
-
if (
|
|
74
|
-
let
|
|
75
|
-
|
|
76
|
-
reason: `removing the whole then-branch forces the test to false, as ${l.mutator} does`,
|
|
77
|
-
rule: "O19",
|
|
78
|
-
by: l
|
|
79
|
-
};
|
|
80
|
-
let u = r({
|
|
70
|
+
function l(t, r) {
|
|
71
|
+
let { sourceCode: i, syntax: a } = r, { parent: o } = i.getSlot(t);
|
|
72
|
+
if (o?.type === "BlockStatement" && o.body.length === 1 && ({parent: o} = i.getSlot(o)), o?.type !== "IfStatement" || o.alternate) return null;
|
|
73
|
+
let s = e({
|
|
74
|
+
decision: a.unwrapParentheses(o.test),
|
|
81
75
|
candidate: {
|
|
82
|
-
mutator:
|
|
83
|
-
node:
|
|
76
|
+
mutator: r.id,
|
|
77
|
+
node: t
|
|
84
78
|
},
|
|
85
|
-
decision: c,
|
|
86
79
|
value: !1
|
|
87
|
-
}, n(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
}, n(r), !0);
|
|
81
|
+
if (!s) return null;
|
|
82
|
+
let { heuristic: c, owned: l, by: u } = s;
|
|
83
|
+
return {
|
|
84
|
+
reason: l ? `removing the whole then-branch forces the test to false, as ${u.mutator} does` : `removing the whole then-branch forces the test to false, as ${u.mutator} does on some inputs`,
|
|
85
|
+
...c && { heuristic: c },
|
|
86
|
+
rule: l ? "O19" : "R4",
|
|
87
|
+
by: u
|
|
88
|
+
};
|
|
93
89
|
}
|
|
94
|
-
function
|
|
90
|
+
function u(e, t) {
|
|
95
91
|
let { syntax: n } = t, r = n.unwrapExpression(e.expression);
|
|
96
92
|
switch (r.type) {
|
|
97
93
|
case "ChainExpression":
|
|
@@ -99,21 +95,21 @@ function d(e, t) {
|
|
|
99
95
|
let e = r.type === "ChainExpression" ? r.expression : r;
|
|
100
96
|
return e.type === "CallExpression" && e.callee.type !== "Super";
|
|
101
97
|
}
|
|
102
|
-
case "UnaryExpression": return r.operator === "delete" || r.operator === "void" &&
|
|
98
|
+
case "UnaryExpression": return r.operator === "delete" || r.operator === "void" && b(n.unwrapExpression(r.argument));
|
|
103
99
|
case "YieldExpression": return t.options.jumps;
|
|
104
|
-
default: return
|
|
100
|
+
default: return o.has(r.type);
|
|
105
101
|
}
|
|
106
102
|
}
|
|
107
|
-
function
|
|
103
|
+
function d(e, t, n) {
|
|
108
104
|
return t?.type === "LabeledStatement" ? {
|
|
109
105
|
reason: "Mootant cannot switch a mutant on in the body of a label",
|
|
110
106
|
rule: "invalid-target"
|
|
111
|
-
} :
|
|
107
|
+
} : l(e, n) || (!n.settings.timeouts && n.syntax.advancesLoop(e) ? {
|
|
112
108
|
reason: "it removes the statement that advances a loop, so it may keep the loop running forever",
|
|
113
109
|
rule: "loop-advance"
|
|
114
110
|
} : null);
|
|
115
111
|
}
|
|
116
|
-
function
|
|
112
|
+
function f(e, t) {
|
|
117
113
|
let { sourceCode: n } = t, r = e, { parent: i } = n.getSlot(e);
|
|
118
114
|
if (i?.type === "BlockStatement" && i.body.at(-1) === e) {
|
|
119
115
|
let { parent: e } = n.getSlot(i);
|
|
@@ -121,35 +117,35 @@ function p(e, t) {
|
|
|
121
117
|
}
|
|
122
118
|
return i?.type === "SwitchCase" && i.consequent.at(-1) === r ? i : null;
|
|
123
119
|
}
|
|
124
|
-
function
|
|
120
|
+
function p(e, t) {
|
|
125
121
|
let { syntax: n } = t, r = n.unwrapExpression(e.expression);
|
|
126
|
-
return r.type !== "AwaitExpression" || !
|
|
122
|
+
return r.type !== "AwaitExpression" || !a(r, t) ? null : n.unwrapExpression(r.argument).arguments.every(i) ? {
|
|
127
123
|
reason: "the statement only waits for a timer delay",
|
|
128
124
|
rule: "timer-delay"
|
|
129
125
|
} : null;
|
|
130
126
|
}
|
|
131
|
-
function
|
|
127
|
+
function m(e, t) {
|
|
132
128
|
let { cases: n } = t.sourceCode.getParent(e), r = n.slice(n.indexOf(e) + 1).find((e) => e.consequent.length > 0);
|
|
133
129
|
if (!r) return !0;
|
|
134
130
|
let i = r.consequent[0], a = i.type === "BlockStatement" && r.consequent.length === 1 ? i.body[0] : i;
|
|
135
131
|
return a?.type === "BreakStatement" && a.label === null;
|
|
136
132
|
}
|
|
137
|
-
function
|
|
133
|
+
function h(e, t) {
|
|
138
134
|
let { sourceCode: n } = t, { parent: r } = n.getSlot(e);
|
|
139
|
-
if (r?.type === "BlockStatement" && r.body.at(-1) === e && ({parent: r} = n.getSlot(r)), !
|
|
135
|
+
if (r?.type === "BlockStatement" && r.body.at(-1) === e && ({parent: r} = n.getSlot(r)), !s.has(r?.type)) return !1;
|
|
140
136
|
let { parent: i } = n.getSlot(r);
|
|
141
137
|
return !e.label || i?.type === "LabeledStatement" && i.label.name === e.label.name;
|
|
142
138
|
}
|
|
143
|
-
function
|
|
139
|
+
function g(e, t) {
|
|
144
140
|
return e?.type === "Literal" && e.value === !1 ? {
|
|
145
141
|
reason: "removing a tail return false only turns false into undefined",
|
|
146
142
|
rule: "tail-return-false"
|
|
147
|
-
} :
|
|
143
|
+
} : _(e, t) ? {
|
|
148
144
|
reason: "removing a tail return of no value, undefined or null turns at most null into undefined",
|
|
149
145
|
rule: "tail-return"
|
|
150
146
|
} : null;
|
|
151
147
|
}
|
|
152
|
-
function
|
|
148
|
+
function _(e, t) {
|
|
153
149
|
if (!e) return !0;
|
|
154
150
|
if (e.type === "Literal") return e.value === null;
|
|
155
151
|
if (e.type === "UnaryExpression") {
|
|
@@ -158,23 +154,23 @@ function v(e, t) {
|
|
|
158
154
|
}
|
|
159
155
|
return e.type === "Identifier";
|
|
160
156
|
}
|
|
161
|
-
function
|
|
162
|
-
let { context: r } = n, i =
|
|
157
|
+
function v(e, t, n) {
|
|
158
|
+
let { context: r } = n, i = y(e, r) ? {
|
|
163
159
|
text: ";",
|
|
164
160
|
node: e
|
|
165
161
|
} : {
|
|
166
162
|
solitary: [e],
|
|
167
163
|
text: ";",
|
|
168
164
|
node: e
|
|
169
|
-
}, a = n.skip ??
|
|
165
|
+
}, a = n.skip ?? d(e, t, r);
|
|
170
166
|
return a && (i.skip = a), [i];
|
|
171
167
|
}
|
|
172
|
-
function
|
|
168
|
+
function y(e, t) {
|
|
173
169
|
if (e.type !== "ExpressionStatement") return !1;
|
|
174
170
|
let n = t.syntax.unwrapExpression(e.expression);
|
|
175
171
|
return n.type === "AssignmentExpression" && n.operator === "=";
|
|
176
172
|
}
|
|
177
|
-
function
|
|
173
|
+
function b(e) {
|
|
178
174
|
switch (e.type) {
|
|
179
175
|
case "ChainExpression": return e.expression.type === "CallExpression";
|
|
180
176
|
case "AwaitExpression":
|
|
@@ -183,4 +179,4 @@ function x(e) {
|
|
|
183
179
|
default: return !1;
|
|
184
180
|
}
|
|
185
181
|
}
|
|
186
|
-
export {
|
|
182
|
+
export { c as statementRemoval };
|
|
@@ -3,6 +3,14 @@ import { Mutator } from '../../types/mutator/mutator.js';
|
|
|
3
3
|
* Options of the string-literal mutator.
|
|
4
4
|
*/
|
|
5
5
|
interface StringLiteralOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Whether quoted JSX attribute values are mutated, apart from those of
|
|
8
|
+
* `className`, `class`, `style` and `data-testid`, those of attributes whose
|
|
9
|
+
* meaning braces would change, such as `disabled` and `onclick` (see
|
|
10
|
+
* `isBraceSensitiveAttribute`), and those with a backslash, a control
|
|
11
|
+
* character or a character reference.
|
|
12
|
+
*/
|
|
13
|
+
jsxAttributes: boolean;
|
|
6
14
|
/**
|
|
7
15
|
* Whether strings in `case` labels are mutated.
|
|
8
16
|
*/
|
|
@@ -15,11 +23,13 @@ interface StringLiteralOptions {
|
|
|
15
23
|
* glued together are rarely a value of their own; other expressions are kept,
|
|
16
24
|
* and so are those of a tagged template, which a string cannot replace. Keys,
|
|
17
25
|
* comparison, boolean-mode and `void` operands, `Symbol` descriptions, error
|
|
18
|
-
* messages, lookup keys whose call is only tested, JSX attribute
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
26
|
+
* messages, lookup keys whose call is only tested, quoted JSX attribute values
|
|
27
|
+
* (with the `jsxAttributes` option, only those of `className`, `class`, `style`
|
|
28
|
+
* and `data-testid` and those whose meaning braces would change), the pattern
|
|
29
|
+
* and flags of `RegExp` calls the regex mutators read, bare string statements,
|
|
30
|
+
* tagged templates, templates without static text and (unless the `caseTests`
|
|
31
|
+
* option is set) case labels are skipped, and so are mutants that another
|
|
32
|
+
* mutant owns or subsumes (branch pairs, no-op callbacks, emptied `||`
|
|
23
33
|
* defaults). A skipped change follows as a skipped replacement; a template
|
|
24
34
|
* without static text has nothing to change.
|
|
25
35
|
*/
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { isBraceSensitiveAttribute as e } from "../syntax/is-brace-sensitive-attribute.js";
|
|
2
|
+
import { isPlainAttributeString as t } from "../text/is-plain-attribute-string.js";
|
|
3
|
+
import { readRegexArgument as n } from "../regex/read-regex-argument.js";
|
|
4
|
+
import { createRunContext as r } from "./shared/create-run-context.js";
|
|
5
|
+
import { isLookupPosition as i } from "./shared/is-lookup-position.js";
|
|
6
|
+
import { getLiteralSkip as a } from "./shared/get-literal-skip.js";
|
|
7
|
+
import { readRegexCall as o } from "../regex/read-regex-call.js";
|
|
8
|
+
import { isReadChain as s } from "../syntax/is-read-chain.js";
|
|
9
|
+
const c = "mootant";
|
|
10
|
+
let l = /* @__PURE__ */ new Map([
|
|
11
|
+
["data-testid", "test id"],
|
|
12
|
+
["className", "class"],
|
|
13
|
+
["class", "class"],
|
|
14
|
+
["style", "style"]
|
|
15
|
+
]), u = /* @__PURE__ */ new Set([
|
|
9
16
|
"hasOwnProperty",
|
|
10
17
|
"getAttribute",
|
|
11
18
|
"hasAttribute",
|
|
@@ -18,31 +25,31 @@ let s = /* @__PURE__ */ new Set([
|
|
|
18
25
|
"getItem",
|
|
19
26
|
"has",
|
|
20
27
|
"get"
|
|
21
|
-
]),
|
|
28
|
+
]), d = {
|
|
22
29
|
create(e) {
|
|
23
30
|
let { sourceCode: t } = e;
|
|
24
31
|
return {
|
|
25
32
|
TemplateLiteral(n) {
|
|
26
|
-
let { expressions: r, quasis: i } = n,
|
|
33
|
+
let { expressions: r, quasis: i } = n, a = i.some((e) => e.value.cooked !== "");
|
|
27
34
|
if (r.length === 0) {
|
|
28
|
-
let t =
|
|
29
|
-
return
|
|
35
|
+
let t = a ? "" : c;
|
|
36
|
+
return g(n, {
|
|
30
37
|
text: `\`${t}\``,
|
|
31
38
|
value: t
|
|
32
39
|
}, e);
|
|
33
40
|
}
|
|
34
|
-
return
|
|
41
|
+
return a ? r.every(s) && t.getSlot(n).key !== "quasi" ? g(n, {
|
|
35
42
|
value: null,
|
|
36
43
|
text: "''"
|
|
37
|
-
}, e) :
|
|
44
|
+
}, e) : g(n, {
|
|
38
45
|
text: `\`${r.map((e) => `\${${t.getText(e)}}`).join("")}\``,
|
|
39
46
|
value: null
|
|
40
47
|
}, e) : [];
|
|
41
48
|
},
|
|
42
49
|
Literal(n) {
|
|
43
50
|
if (typeof n.value != "string") return [];
|
|
44
|
-
let r = t.text[n.start], i = n.value === "" ?
|
|
45
|
-
return
|
|
51
|
+
let r = t.text[n.start], i = n.value === "" ? c : "";
|
|
52
|
+
return g(n, {
|
|
46
53
|
text: `${r}${i}${r}`,
|
|
47
54
|
value: i
|
|
48
55
|
}, e);
|
|
@@ -51,12 +58,15 @@ let s = /* @__PURE__ */ new Set([
|
|
|
51
58
|
},
|
|
52
59
|
meta: {
|
|
53
60
|
description: "Empties a string or the static text of a template literal, or fills an empty one.",
|
|
54
|
-
defaultOptions: {
|
|
61
|
+
defaultOptions: {
|
|
62
|
+
jsxAttributes: !1,
|
|
63
|
+
caseTests: !1
|
|
64
|
+
}
|
|
55
65
|
}
|
|
56
66
|
};
|
|
57
|
-
function
|
|
58
|
-
let { sourceCode:
|
|
59
|
-
if (
|
|
67
|
+
function f(e, t, n) {
|
|
68
|
+
let { sourceCode: i, options: o, syntax: s } = n, { parent: c, key: l } = s.getContextSlot(e), { value: u, text: d } = t;
|
|
69
|
+
if (i.getSlot(e).key === "quasi") return {
|
|
60
70
|
reason: "the text of a tagged template belongs to its tag",
|
|
61
71
|
rule: "tagged-template"
|
|
62
72
|
};
|
|
@@ -72,56 +82,75 @@ function l(e, n, i) {
|
|
|
72
82
|
reason: "a bare string statement, such as a directive, is not mutated",
|
|
73
83
|
rule: "bare-string"
|
|
74
84
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
if (c?.type === "CallExpression" && p(c.callee, i)) return {
|
|
85
|
+
let f = c?.type === "JSXAttribute" ? p(c, e, n) : null;
|
|
86
|
+
if (f) return f;
|
|
87
|
+
if (c?.type === "CallExpression" && _(c.callee, n)) return {
|
|
80
88
|
reason: "it only changes the description of a symbol",
|
|
81
89
|
rule: "symbol-description"
|
|
82
90
|
};
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
let
|
|
86
|
-
if (
|
|
87
|
-
function
|
|
88
|
-
return
|
|
91
|
+
let g = m(e, n);
|
|
92
|
+
if (g) return g;
|
|
93
|
+
let v = r(n);
|
|
94
|
+
if (u === null) return a(e, { change: { text: d } }, v);
|
|
95
|
+
function y() {
|
|
96
|
+
return u === "" && h(e, n) ? {
|
|
89
97
|
reason: "an empty lookup key only makes a tested lookup constant, as another mutator does",
|
|
90
98
|
rule: "O8"
|
|
91
99
|
} : null;
|
|
92
100
|
}
|
|
93
|
-
return
|
|
94
|
-
change: { value:
|
|
95
|
-
getOwnSkip:
|
|
96
|
-
},
|
|
101
|
+
return a(e, {
|
|
102
|
+
change: { value: u },
|
|
103
|
+
getOwnSkip: y
|
|
104
|
+
}, v);
|
|
105
|
+
}
|
|
106
|
+
function p(n, r, i) {
|
|
107
|
+
if (!i.options.jsxAttributes) return {
|
|
108
|
+
reason: "it only changes the quoted value of a JSX attribute",
|
|
109
|
+
rule: "jsx-attribute"
|
|
110
|
+
};
|
|
111
|
+
let { name: a } = n, o = a.type === "JSXIdentifier" ? l.get(a.name) : void 0;
|
|
112
|
+
if (o !== void 0) return {
|
|
113
|
+
reason: `it only changes the ${o} of an element`,
|
|
114
|
+
rule: "jsx-attribute",
|
|
115
|
+
heuristic: !0
|
|
116
|
+
};
|
|
117
|
+
let s = i.sourceCode.getParent(n);
|
|
118
|
+
return e(n, s) ? {
|
|
119
|
+
reason: "Mootant cannot switch a mutant on for a quoted JSX attribute value that a compiler such as Solid's reads another way once it is in braces",
|
|
120
|
+
rule: "invalid-target",
|
|
121
|
+
heuristic: !0
|
|
122
|
+
} : t(i.sourceCode.getText(r)) ? null : {
|
|
123
|
+
reason: "Mootant cannot switch a mutant on for a quoted JSX attribute value with a backslash, a control character such as a line break, or a character reference",
|
|
124
|
+
rule: "invalid-target"
|
|
125
|
+
};
|
|
97
126
|
}
|
|
98
|
-
function
|
|
99
|
-
let { parent:
|
|
127
|
+
function m(e, t) {
|
|
128
|
+
let { parent: i, index: a, key: c } = t.syntax.getContextSlot(e), l = c === "arguments" && i ? o(i, t) : null;
|
|
100
129
|
if (l === null) return null;
|
|
101
|
-
if (
|
|
130
|
+
if (a === 0) return e.type === "TemplateLiteral" && !e.expressions.every(s) ? null : {
|
|
102
131
|
reason: "an empty RegExp pattern matches everything, which acts like a test of the match forced to true",
|
|
103
132
|
rule: "regex-argument"
|
|
104
133
|
};
|
|
105
|
-
let u =
|
|
134
|
+
let u = n(l, t.sourceCode.text), d = {
|
|
106
135
|
mutator: "regex-flag",
|
|
107
136
|
node: l.flagsNode
|
|
108
137
|
};
|
|
109
|
-
return u && !u.dynamic && t
|
|
138
|
+
return u && !u.dynamic && r(t).runs(d, {
|
|
110
139
|
mutator: "string-literal",
|
|
111
|
-
node:
|
|
140
|
+
node: e
|
|
112
141
|
}) ? {
|
|
113
142
|
reason: "regex-flag changes the flags of RegExp",
|
|
114
143
|
rule: "regex-argument"
|
|
115
144
|
} : null;
|
|
116
145
|
}
|
|
117
|
-
function
|
|
118
|
-
let { syntax:
|
|
119
|
-
if (
|
|
120
|
-
let o =
|
|
121
|
-
return (a === 0 &&
|
|
146
|
+
function h(e, t) {
|
|
147
|
+
let { syntax: n } = t, { parent: r, index: a } = n.getContextSlot(e);
|
|
148
|
+
if (r?.type !== "CallExpression") return !1;
|
|
149
|
+
let o = n.getMemberPath(r.callee), s = n.unwrapExpression(r.callee);
|
|
150
|
+
return (a === 0 && s.type === "MemberExpression" && !s.computed && u.has(s.property.name) || a === 1 && o?.join(".") === "Object.hasOwn") && i(r, t);
|
|
122
151
|
}
|
|
123
|
-
function
|
|
124
|
-
let { text: r } = t, i =
|
|
152
|
+
function g(e, t, n) {
|
|
153
|
+
let { text: r } = t, i = f(e, t, n);
|
|
125
154
|
return [i ? {
|
|
126
155
|
text: r,
|
|
127
156
|
skip: i,
|
|
@@ -131,8 +160,8 @@ function f(e, t, n) {
|
|
|
131
160
|
node: e
|
|
132
161
|
}];
|
|
133
162
|
}
|
|
134
|
-
function
|
|
163
|
+
function _(e, t) {
|
|
135
164
|
let n = t.syntax.unwrapExpression(e);
|
|
136
165
|
return n.type === "Identifier" && n.name === "Symbol";
|
|
137
166
|
}
|
|
138
|
-
export {
|
|
167
|
+
export { d as stringLiteral };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Preset } from '../../types/config/preset.js';
|
|
2
2
|
/**
|
|
3
3
|
* Default preset: every built-in mutator with its default options, without
|
|
4
|
-
* mutants that
|
|
5
|
-
*
|
|
4
|
+
* mutants that may cause timeouts, and the usual loggers, whose message texts
|
|
5
|
+
* are not mutated.
|
|
6
6
|
*/
|
|
7
7
|
export declare let recommended: Preset;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Preset } from '../../types/config/preset.js';
|
|
2
2
|
/**
|
|
3
3
|
* Recommended preset with the noisier options of the built-in mutators, the
|
|
4
|
-
* mutants that
|
|
5
|
-
*
|
|
4
|
+
* mutants that may cause timeouts and the coarse mutants that the solitary rule
|
|
5
|
+
* would drop. It leaves string-literal's `jsxAttributes` off: the braces that
|
|
6
|
+
* host a quoted JSX attribute value can change what Solid or a macro does with
|
|
7
|
+
* no mutant on.
|
|
6
8
|
*/
|
|
7
9
|
export declare let strict: Preset;
|
|
@@ -3,33 +3,34 @@ import { PlannedTry, RunState } from '../../types/run/run-state.js';
|
|
|
3
3
|
import { BatchResult } from '../../types/adapter/batch-result.js';
|
|
4
4
|
/**
|
|
5
5
|
* Records what a batch run reported, in fast mode. Each mutant try is
|
|
6
|
-
* classified. Only kills are accepted, and a kill
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
6
|
+
* classified. Only kills are accepted, and a kill only when the control tries
|
|
7
|
+
* right before and right after it both passed, else it is doubtful. An accepted
|
|
8
|
+
* kill is heuristic and final: passing controls do not prove that the mutant
|
|
9
|
+
* alone fails the test, since state an earlier try left can fail it, such as a
|
|
10
|
+
* value a control try set that the mutant no longer resets; the default mode
|
|
11
|
+
* decides every mutant isolated instead. A try that ran out of time has no
|
|
12
|
+
* control after it, since the worker gives up the unit: it counts only after a
|
|
13
|
+
* passing control, and then waits for a confirmation in a fresh run with twice
|
|
14
|
+
* the time of its whole test file, or is final when the run was one. A
|
|
15
|
+
* hit-limit timeout sends the mutant to the isolated path, even in such a run,
|
|
16
|
+
* since a mutant that only makes code hotter goes over the hit limit too and
|
|
17
|
+
* only that path confirms it with a raised limit. Doubtful tries and late
|
|
18
|
+
* errors send the mutant to the isolated path; a reached pass is only noted,
|
|
19
|
+
* since state left by a control try may hide the mutant, and the core rechecks
|
|
20
|
+
* it on the isolated path. A unit whose suite hook failed sends every mutant it
|
|
21
|
+
* planned that is still undecided to the isolated path. A test whose leading
|
|
22
|
+
* control skipped itself ends its repeats there, so its mutants count as tried
|
|
23
|
+
* without evidence rather than missing. A hung unit gets a `worker-hang`
|
|
24
|
+
* warning and its timed-out try the cause `hang`. Accepted kills and passes,
|
|
25
|
+
* whether they reached the mutant or not, go to the cache of the run, so a
|
|
26
|
+
* later run reuses a kill only after the same passes, unless the kill came from
|
|
27
|
+
* the first test of the mutant (`applyCachedBatch`).
|
|
26
28
|
*
|
|
27
29
|
* @param state - State of the run, updated in place.
|
|
28
30
|
* @param run - The run to record.
|
|
29
31
|
* @param run.plan - Plan the run executed.
|
|
30
32
|
* @param run.result - What the adapter reported.
|
|
31
|
-
* @param run.confirming - Whether the run
|
|
32
|
-
* bounds.
|
|
33
|
+
* @param run.confirming - Whether the run confirms timeouts.
|
|
33
34
|
* @returns Planned tries without facts whose mutant is still undecided on the
|
|
34
35
|
* batch path.
|
|
35
36
|
*/
|
|
@@ -41,13 +41,13 @@ function i(e, n, r) {
|
|
|
41
41
|
t(e, n.mutant.id, "doubtful");
|
|
42
42
|
break;
|
|
43
43
|
case "timeout": {
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
cause:
|
|
44
|
+
let r = o === "time-limit" && c ? "hang" : o;
|
|
45
|
+
r === "hit-limit" ? t(e, n.mutant.id, "doubtful") : i ? n.verdict = {
|
|
46
|
+
cause: r,
|
|
47
47
|
status: "Timeout",
|
|
48
48
|
...l
|
|
49
49
|
} : n.confirm.push({
|
|
50
|
-
cause:
|
|
50
|
+
cause: r,
|
|
51
51
|
test: s.id
|
|
52
52
|
});
|
|
53
53
|
break;
|
|
@@ -99,7 +99,7 @@ function s(e, n) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
function c(e, t, r) {
|
|
102
|
-
let { outcome: i, cause: a } = n(e, t, "batch"), o = i === "killed"
|
|
102
|
+
let { outcome: i, cause: a } = n(e, t, "batch"), o = i === "killed";
|
|
103
103
|
return (o || i === "timeout") && (!u(r.before) || o && !u(r.after)) && (i = "doubtful"), {
|
|
104
104
|
outcome: i,
|
|
105
105
|
cause: a
|