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.
Files changed (244) hide show
  1. package/dist/adapters/jest/build-dry-file.d.ts +12 -12
  2. package/dist/adapters/jest/collect-jest-dependencies.d.ts +8 -7
  3. package/dist/adapters/jest/runner.d.ts +1 -1
  4. package/dist/adapters/jest/runner.js +1 -1
  5. package/dist/adapters/jest/types/jest-record.d.ts +4 -4
  6. package/dist/adapters/jest/types/unit-worker.d.ts +16 -8
  7. package/dist/adapters/jest/types/worker-session.d.ts +6 -7
  8. package/dist/adapters/jest/worker/boot-worker.d.ts +4 -3
  9. package/dist/adapters/jest/worker/run-unit.d.ts +20 -18
  10. package/dist/adapters/jest/worker/vm-setup.js +1 -1
  11. package/dist/adapters/jest/worker/worker.js +1 -1
  12. package/dist/adapters/jest/write-worker-session.d.ts +1 -2
  13. package/dist/adapters/jest/write-worker-session.js +2 -2
  14. package/dist/adapters/node-test/collect-node-dependencies.d.ts +5 -5
  15. package/dist/adapters/node-test/preload/preload.js +4 -1
  16. package/dist/adapters/node-test/run-test-file.js +1 -0
  17. package/dist/adapters/node-test/types/node-test-record.d.ts +3 -3
  18. package/dist/adapters/node-test/types/node-test-unit.d.ts +6 -1
  19. package/dist/adapters/shared/create-input-filter.d.ts +26 -0
  20. package/dist/adapters/shared/create-input-filter.js +32 -0
  21. package/dist/adapters/shared/track-file-inputs.d.ts +7 -3
  22. package/dist/adapters/shared/track-file-inputs.js +16 -7
  23. package/dist/adapters/shared/track-file-reads.d.ts +12 -8
  24. package/dist/adapters/shared/track-file-reads.js +110 -57
  25. package/dist/adapters/shared/track-inputs.d.ts +13 -6
  26. package/dist/adapters/shared/track-inputs.js +7 -7
  27. package/dist/adapters/shared/types/file-input-tracking.d.ts +6 -0
  28. package/dist/adapters/shared/types/input-tracking.d.ts +3 -3
  29. package/dist/adapters/vitest/collect-dependencies.d.ts +4 -3
  30. package/dist/adapters/vitest/collect-dependencies.js +25 -24
  31. package/dist/adapters/vitest/get-cache-inputs.js +3 -1
  32. package/dist/adapters/vitest/is-virtual-module.d.ts +11 -0
  33. package/dist/adapters/vitest/is-virtual-module.js +8 -0
  34. package/dist/adapters/vitest/read-out-files.d.ts +7 -2
  35. package/dist/adapters/vitest/read-out-files.js +5 -5
  36. package/dist/adapters/vitest/read-out-records.d.ts +17 -0
  37. package/dist/adapters/vitest/read-out-records.js +27 -0
  38. package/dist/adapters/vitest/read-strays.d.ts +20 -0
  39. package/dist/adapters/vitest/read-strays.js +53 -0
  40. package/dist/adapters/vitest/read-unit-inputs.d.ts +7 -1
  41. package/dist/adapters/vitest/read-unit-inputs.js +1 -1
  42. package/dist/adapters/vitest/run-dry.js +16 -16
  43. package/dist/adapters/vitest/run-plan.d.ts +3 -1
  44. package/dist/adapters/vitest/run-plan.js +15 -15
  45. package/dist/adapters/vitest/run-specifications.d.ts +3 -2
  46. package/dist/adapters/vitest/runner.d.ts +38 -23
  47. package/dist/adapters/vitest/runner.js +84 -85
  48. package/dist/adapters/vitest/types/stray-decisions.d.ts +8 -0
  49. package/dist/adapters/vitest/types/unit-outcome.d.ts +2 -1
  50. package/dist/adapters/vitest/types/vitest-worker.d.ts +83 -12
  51. package/dist/adapters/vitest/worker/encode-stray.d.ts +16 -0
  52. package/dist/adapters/vitest/worker/encode-stray.js +16 -0
  53. package/dist/adapters/vitest/worker/intercept-strays.d.ts +26 -0
  54. package/dist/adapters/vitest/worker/intercept-strays.js +13 -0
  55. package/dist/adapters/vitest/worker/read-try-facts.d.ts +5 -4
  56. package/dist/adapters/vitest/worker/write-out-record.d.ts +2 -2
  57. package/dist/cli/html/build-html-report.js +1 -1
  58. package/dist/cli/html/client/main.js +1 -1
  59. package/dist/cli/html/client/render-change.d.ts +3 -2
  60. package/dist/cli/html/client/render-code.d.ts +1 -1
  61. package/dist/cli/html/pack-replacement.d.ts +1 -1
  62. package/dist/cli/parse-arguments.js +1 -1
  63. package/dist/cli/report/build-list-report.js +1 -1
  64. package/dist/cli/report/build-run-report.js +1 -1
  65. package/dist/cli/report/format-file-groups.d.ts +1 -1
  66. package/dist/cli/run-mutation.js +31 -31
  67. package/dist/cli/terminal/create-spinner.d.ts +1 -1
  68. package/dist/cli/terminal/get-text-style.js +4 -4
  69. package/dist/core/cache/get-environment-key.js +2 -2
  70. package/dist/core/cache/hash-files.d.ts +7 -3
  71. package/dist/core/cache/hash-files.js +16 -17
  72. package/dist/core/cache/prepare-run-cache.d.ts +29 -7
  73. package/dist/core/cache/prepare-run-cache.js +96 -62
  74. package/dist/core/cache/save-run-cache.d.ts +8 -7
  75. package/dist/core/cache/save-run-cache.js +2 -1
  76. package/dist/core/cache/unknown-hash.d.ts +7 -0
  77. package/dist/core/cache/unknown-hash.js +2 -0
  78. package/dist/core/files/select-changed-mutants.d.ts +11 -6
  79. package/dist/core/files/select-changed-mutants.js +38 -13
  80. package/dist/core/generate/apply-solitary-rule.d.ts +8 -5
  81. package/dist/core/generate/apply-solitary-rule.js +36 -29
  82. package/dist/core/generate/collect-candidates.d.ts +18 -4
  83. package/dist/core/generate/collect-candidates.js +168 -86
  84. package/dist/core/generate/compare-targets.d.ts +14 -0
  85. package/dist/core/generate/compare-targets.js +6 -0
  86. package/dist/core/generate/deduplicate-candidates.d.ts +6 -4
  87. package/dist/core/generate/deduplicate-candidates.js +11 -9
  88. package/dist/core/generate/find-list-removal.d.ts +20 -0
  89. package/dist/core/generate/find-list-removal.js +26 -0
  90. package/dist/core/generate/generate-file-mutants.js +47 -46
  91. package/dist/core/generate/get-mutant-site.d.ts +18 -0
  92. package/dist/core/generate/get-mutant-site.js +4 -0
  93. package/dist/core/generate/get-target.d.ts +14 -0
  94. package/dist/core/generate/get-target.js +4 -0
  95. package/dist/core/generate/pick-host.d.ts +10 -0
  96. package/dist/core/generate/pick-host.js +16 -0
  97. package/dist/core/generate/validate-replacement.d.ts +15 -4
  98. package/dist/core/generate/validate-replacement.js +28 -13
  99. package/dist/core/ignore/find-ignore-rule.d.ts +8 -7
  100. package/dist/core/instrument/find-attribute-values.d.ts +12 -0
  101. package/dist/core/instrument/find-attribute-values.js +13 -0
  102. package/dist/core/instrument/get-site-syntax.d.ts +14 -0
  103. package/dist/core/instrument/get-site-syntax.js +12 -0
  104. package/dist/core/instrument/group-mutant-ranges.d.ts +7 -3
  105. package/dist/core/instrument/group-mutant-ranges.js +25 -19
  106. package/dist/core/instrument/instrument-file.d.ts +5 -3
  107. package/dist/core/instrument/instrument-file.js +10 -9
  108. package/dist/core/instrument/instrumenter-version.d.ts +1 -1
  109. package/dist/core/instrument/render-branch.d.ts +17 -0
  110. package/dist/core/instrument/render-branch.js +81 -0
  111. package/dist/core/instrument/render-mutant-range.d.ts +17 -6
  112. package/dist/core/instrument/render-mutant-range.js +39 -13
  113. package/dist/core/list-mutants.d.ts +7 -5
  114. package/dist/core/list-mutants.js +2 -2
  115. package/dist/core/mutators/array-element.d.ts +7 -6
  116. package/dist/core/mutators/array-element.js +13 -13
  117. package/dist/core/mutators/assignment-operator.js +34 -33
  118. package/dist/core/mutators/boolean-literal.d.ts +3 -2
  119. package/dist/core/mutators/number-literal.d.ts +1 -1
  120. package/dist/core/mutators/object-property.d.ts +4 -3
  121. package/dist/core/mutators/object-property.js +7 -8
  122. package/dist/core/mutators/return-value.js +65 -33
  123. package/dist/core/mutators/shared/get-branch-copy-skip.d.ts +12 -7
  124. package/dist/core/mutators/shared/get-branch-copy-skip.js +34 -35
  125. package/dist/core/mutators/shared/get-canonical-falsy-default.d.ts +32 -0
  126. package/dist/core/mutators/shared/get-canonical-falsy-default.js +11 -0
  127. package/dist/core/mutators/shared/get-comparison-plan.js +86 -85
  128. package/dist/core/mutators/shared/get-condition-constants.d.ts +8 -8
  129. package/dist/core/mutators/shared/get-condition-constants.js +3 -3
  130. package/dist/core/mutators/shared/get-endless-value.d.ts +20 -0
  131. package/dist/core/mutators/shared/get-endless-value.js +25 -0
  132. package/dist/core/mutators/shared/get-forced-test-justifier.d.ts +44 -0
  133. package/dist/core/mutators/shared/get-forced-test-justifier.js +25 -0
  134. package/dist/core/mutators/shared/get-group-constant.d.ts +4 -4
  135. package/dist/core/mutators/shared/get-group-constant.js +2 -2
  136. package/dist/core/mutators/shared/get-literal-skip.d.ts +6 -6
  137. package/dist/core/mutators/shared/get-literal-skip.js +2 -2
  138. package/dist/core/mutators/shared/get-logical-drops.d.ts +8 -8
  139. package/dist/core/mutators/shared/get-logical-drops.js +80 -82
  140. package/dist/core/mutators/shared/get-owner-constant.d.ts +3 -1
  141. package/dist/core/mutators/shared/get-running-value.d.ts +5 -4
  142. package/dist/core/mutators/shared/get-toward-mutant.d.ts +10 -2
  143. package/dist/core/mutators/shared/get-toward-mutant.js +45 -40
  144. package/dist/core/mutators/shared/has-other-exit.js +16 -36
  145. package/dist/core/mutators/shared/is-loop-exit.d.ts +20 -0
  146. package/dist/core/mutators/shared/is-loop-exit.js +32 -0
  147. package/dist/core/mutators/shared/is-read-only.d.ts +26 -0
  148. package/dist/core/mutators/shared/is-read-only.js +53 -0
  149. package/dist/core/mutators/statement-removal.d.ts +4 -3
  150. package/dist/core/mutators/statement-removal.js +69 -73
  151. package/dist/core/mutators/string-literal.d.ts +15 -5
  152. package/dist/core/mutators/string-literal.js +79 -50
  153. package/dist/core/presets/recommended.d.ts +2 -2
  154. package/dist/core/presets/strict.d.ts +4 -2
  155. package/dist/core/run/apply-batch-result.d.ts +23 -22
  156. package/dist/core/run/apply-batch-result.js +5 -5
  157. package/dist/core/run/apply-isolated-result.d.ts +18 -17
  158. package/dist/core/run/apply-isolated-result.js +1 -0
  159. package/dist/core/run/classify-try.d.ts +9 -8
  160. package/dist/core/run/get-test-file-limits.d.ts +13 -0
  161. package/dist/core/run/get-test-file-limits.js +13 -0
  162. package/dist/core/run/get-unit-evidence.d.ts +6 -3
  163. package/dist/core/run/get-unit-evidence.js +1 -1
  164. package/dist/core/run/plan-batch.d.ts +6 -3
  165. package/dist/core/run/plan-batch.js +36 -31
  166. package/dist/core/run/plan-isolated.d.ts +3 -1
  167. package/dist/core/run/plan-isolated.js +8 -14
  168. package/dist/core/run/read-isolated-unit.d.ts +4 -4
  169. package/dist/core/run/run-batch-phases.d.ts +4 -3
  170. package/dist/core/run/run-dry-phase.d.ts +35 -19
  171. package/dist/core/run/run-dry-phase.js +127 -77
  172. package/dist/core/run/run-isolated-rounds.d.ts +6 -5
  173. package/dist/core/run/run-isolated-rounds.js +1 -0
  174. package/dist/core/run-mutants.d.ts +26 -21
  175. package/dist/core/run-mutants.js +72 -64
  176. package/dist/core/runtime/create-hit-limit-error.d.ts +5 -3
  177. package/dist/core/runtime/create-hit-limit-error.js +1 -1
  178. package/dist/core/runtime/install-mutant-runtime.js +23 -6
  179. package/dist/core/runtime/runtime-version.d.ts +4 -4
  180. package/dist/core/skips/skip-rules.d.ts +4 -0
  181. package/dist/core/skips/skip-rules.js +4 -0
  182. package/dist/core/syntax/is-brace-sensitive-attribute.d.ts +18 -0
  183. package/dist/core/syntax/is-brace-sensitive-attribute.js +28 -0
  184. package/dist/core/syntax/is-spread-safe-member.d.ts +18 -0
  185. package/dist/core/syntax/is-spread-safe-member.js +18 -0
  186. package/dist/core/syntax/is-value-position.d.ts +3 -1
  187. package/dist/core/text/get-list-removal-range.d.ts +22 -0
  188. package/dist/core/text/get-list-removal-range.js +46 -0
  189. package/dist/core/text/is-plain-attribute-string.d.ts +10 -0
  190. package/dist/core/text/is-plain-attribute-string.js +5 -0
  191. package/dist/core/text/parse-expression.d.ts +8 -4
  192. package/dist/core/text/parse-expression.js +1 -0
  193. package/dist/core/text/remove-list-element.d.ts +2 -4
  194. package/dist/core/text/remove-list-element.js +4 -45
  195. package/dist/docs/styles/colors.js +1 -1
  196. package/dist/package.js +1 -1
  197. package/dist/types/adapter/dry-file.d.ts +2 -1
  198. package/dist/types/adapter/dry-run-request.d.ts +5 -4
  199. package/dist/types/adapter/mutant-runtime.d.ts +30 -1
  200. package/dist/types/cli/text-style.d.ts +1 -1
  201. package/dist/types/config/preset-settings.d.ts +2 -2
  202. package/dist/types/config/run-config.d.ts +12 -4
  203. package/dist/types/html/indexed-mutant.d.ts +4 -2
  204. package/dist/types/html/shown-change.d.ts +4 -3
  205. package/dist/types/mutant/list-removal.d.ts +37 -0
  206. package/dist/types/mutant/mutant-candidate.d.ts +11 -17
  207. package/dist/types/mutant/mutant-host.d.ts +49 -0
  208. package/dist/types/mutant/mutant-kind.d.ts +18 -0
  209. package/dist/types/mutant/mutant-range.d.ts +15 -8
  210. package/dist/types/mutant/mutant.d.ts +9 -15
  211. package/dist/types/mutant/site-syntax.d.ts +14 -0
  212. package/dist/types/mutant/skip-justifier.d.ts +3 -1
  213. package/dist/types/mutant/skipped-candidate.d.ts +13 -10
  214. package/dist/types/mutant/skipped-mutant.d.ts +9 -6
  215. package/dist/types/mutator/replacement.d.ts +14 -3
  216. package/dist/types/report/html-report.d.ts +10 -7
  217. package/dist/types/report/list-report-focus.d.ts +3 -2
  218. package/dist/types/report/list-report-justifier.d.ts +4 -2
  219. package/dist/types/report/list-report-mutant.d.ts +15 -9
  220. package/dist/types/report/list-report-skipped.d.ts +3 -2
  221. package/dist/types/report/list-report.d.ts +1 -1
  222. package/dist/types/report/run-report.d.ts +2 -2
  223. package/dist/types/report/slim-list-report.d.ts +6 -3
  224. package/dist/types/report/slim-run-report.d.ts +1 -1
  225. package/dist/types/run/isolated-reason.d.ts +4 -3
  226. package/dist/types/run/mutant-state.d.ts +1 -1
  227. package/dist/types/run/run-event.d.ts +1 -1
  228. package/dist/types/run/run-kind.d.ts +3 -2
  229. package/dist/types/run/run-result.d.ts +6 -3
  230. package/dist/types/run/run-state.d.ts +9 -1
  231. package/dist/types/run/run-status.d.ts +2 -2
  232. package/dist/types/run/try-cause.d.ts +8 -6
  233. package/dist/types/syntax/syntax-helpers.d.ts +5 -3
  234. package/package.json +5 -5
  235. package/skills/mootant/SKILL.md +14 -12
  236. package/skills/mootant/references/mutators.md +3 -1
  237. package/dist/core/instrument/get-site-check.d.ts +0 -9
  238. package/dist/core/instrument/get-site-check.js +0 -5
  239. package/dist/core/instrument/get-template-site-check.d.ts +0 -12
  240. package/dist/core/instrument/get-template-site-check.js +0 -5
  241. /package/dist/cli/{built-in-adapters.d.ts → get-built-in-adapters.d.ts} +0 -0
  242. /package/dist/cli/{built-in-adapters.js → get-built-in-adapters.js} +0 -0
  243. /package/dist/cli/terminal/{colors.d.ts → create-colors.d.ts} +0 -0
  244. /package/dist/cli/terminal/{colors.js → create-colors.js} +0 -0
@@ -1,64 +1,63 @@
1
- import { isPlainReturnValue as e } from "./shared/is-plain-return-value.js";
2
- import { getOwnerConstant as t } from "./shared/get-owner-constant.js";
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 { getTowardMutant as r } from "./shared/get-toward-mutant.js";
5
- import { isTailPosition as i } from "./shared/is-tail-position.js";
6
- import { isEffectFree as a } from "../syntax/is-effect-free.js";
7
- import { isTimerWait as o } from "./shared/is-timer-wait.js";
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
- ]), c = /* @__PURE__ */ new Set([
12
+ ]), s = /* @__PURE__ */ new Set([
14
13
  "DoWhileStatement",
15
14
  "ForInStatement",
16
15
  "ForOfStatement",
17
16
  "WhileStatement",
18
17
  "ForStatement"
19
- ]), l = {
20
- create(t) {
21
- let { jumps: n } = t.options;
18
+ ]), c = {
19
+ create(e) {
20
+ let { jumps: n } = e.options;
22
21
  return {
23
- BreakStatement(e, r) {
24
- let i = e.label ? null : p(e, t);
25
- return i ? y(e, r, {
26
- context: t,
27
- skip: h(i, t) ? {
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 ? y(e, r, {
30
+ }) : n ? v(t, r, {
32
31
  skip: null,
33
- context: t
32
+ context: e
34
33
  }) : [];
35
34
  },
36
- ReturnStatement(n, r) {
37
- let a = n.argument ? t.syntax.unwrapExpression(n.argument) : null;
38
- return a && !e(a, t) ? [] : y(n, r, {
39
- context: t,
40
- skip: i(n, t) ? _(a, t) : null
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(e, r) {
44
- return n ? y(e, r, {
45
- context: t,
46
- skip: g(e, t) ? {
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(e, n) {
53
- return d(e, t) ? y(e, n, {
54
- skip: m(e, t),
55
- context: t
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(e, n) {
59
- return y(e, n, {
57
+ ThrowStatement(t, n) {
58
+ return v(t, n, {
60
59
  skip: null,
61
- context: t
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 u(e, i) {
72
- let { sourceCode: a, syntax: o } = i, { parent: s } = a.getSlot(e);
73
- if (s?.type === "BlockStatement" && s.body.length === 1 && ({parent: s} = a.getSlot(s)), s?.type !== "IfStatement" || s.alternate) return null;
74
- let c = o.unwrapParentheses(s.test), l = t(c, !1, i);
75
- if (l) return {
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: i.id,
83
- node: e
76
+ mutator: r.id,
77
+ node: t
84
78
  },
85
- decision: c,
86
79
  value: !1
87
- }, n(i));
88
- return u ? {
89
- reason: `removing the whole then-branch forces the test to false, as ${u.mutator} does on some inputs`,
90
- by: u,
91
- rule: "R4"
92
- } : null;
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 d(e, t) {
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" && x(n.unwrapExpression(r.argument));
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 s.has(r.type);
100
+ default: return o.has(r.type);
105
101
  }
106
102
  }
107
- function f(e, t, n) {
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
- } : u(e, n) || (!n.settings.timeouts && n.syntax.advancesLoop(e) ? {
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 p(e, t) {
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 m(e, t) {
120
+ function p(e, t) {
125
121
  let { syntax: n } = t, r = n.unwrapExpression(e.expression);
126
- return r.type !== "AwaitExpression" || !o(r, t) ? null : n.unwrapExpression(r.argument).arguments.every(a) ? {
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 h(e, t) {
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 g(e, t) {
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)), !c.has(r?.type)) return !1;
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 _(e, t) {
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
- } : v(e, t) ? {
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 v(e, t) {
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 y(e, t, n) {
162
- let { context: r } = n, i = b(e, r) ? {
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 ?? f(e, t, r);
165
+ }, a = n.skip ?? d(e, t, r);
170
166
  return a && (i.skip = a), [i];
171
167
  }
172
- function b(e, t) {
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 x(e) {
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 { l as statementRemoval };
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 strings, the
19
- * pattern and flags of `RegExp` calls the regex mutators read, bare string
20
- * statements, tagged templates, templates without static text and (unless the
21
- * `caseTests` option is set) case labels are skipped, and so are mutants that
22
- * another mutant owns or subsumes (branch pairs, no-op callbacks, emptied `||`
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 { readRegexArgument as e } from "../regex/read-regex-argument.js";
2
- import { createRunContext as t } from "./shared/create-run-context.js";
3
- import { isLookupPosition as n } from "./shared/is-lookup-position.js";
4
- import { getLiteralSkip as r } from "./shared/get-literal-skip.js";
5
- import { readRegexCall as i } from "../regex/read-regex-call.js";
6
- import { isReadChain as a } from "../syntax/is-read-chain.js";
7
- const o = "mootant";
8
- let s = /* @__PURE__ */ new Set([
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
- ]), c = {
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, s = i.some((e) => e.value.cooked !== "");
33
+ let { expressions: r, quasis: i } = n, a = i.some((e) => e.value.cooked !== "");
27
34
  if (r.length === 0) {
28
- let t = s ? "" : o;
29
- return f(n, {
35
+ let t = a ? "" : c;
36
+ return g(n, {
30
37
  text: `\`${t}\``,
31
38
  value: t
32
39
  }, e);
33
40
  }
34
- return s ? r.every(a) && t.getSlot(n).key !== "quasi" ? f(n, {
41
+ return a ? r.every(s) && t.getSlot(n).key !== "quasi" ? g(n, {
35
42
  value: null,
36
43
  text: "''"
37
- }, e) : f(n, {
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 === "" ? o : "";
45
- return f(n, {
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: { caseTests: !1 }
61
+ defaultOptions: {
62
+ jsxAttributes: !1,
63
+ caseTests: !1
64
+ }
55
65
  }
56
66
  };
57
- function l(e, n, i) {
58
- let { sourceCode: a, options: o, syntax: s } = i, { parent: c, key: l } = s.getContextSlot(e), { value: f, text: m } = n;
59
- if (a.getSlot(e).key === "quasi") return {
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
- if (c?.type === "JSXAttribute") return {
76
- reason: "it only changes the quoted value of a JSX attribute",
77
- rule: "jsx-attribute"
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 h = u(e, i);
84
- if (h) return h;
85
- let g = t(i);
86
- if (f === null) return r(e, { change: { text: m } }, g);
87
- function _() {
88
- return f === "" && d(e, i) ? {
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 r(e, {
94
- change: { value: f },
95
- getOwnSkip: _
96
- }, g);
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 u(n, r) {
99
- let { parent: o, index: s, key: c } = r.syntax.getContextSlot(n), l = c === "arguments" && o ? i(o, r) : null;
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 (s === 0) return n.type === "TemplateLiteral" && !n.expressions.every(a) ? null : {
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 = e(l, r.sourceCode.text), d = {
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(r).runs(d, {
138
+ return u && !u.dynamic && r(t).runs(d, {
110
139
  mutator: "string-literal",
111
- node: n
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 d(e, t) {
118
- let { syntax: r } = t, { parent: i, index: a } = r.getContextSlot(e);
119
- if (i?.type !== "CallExpression") return !1;
120
- let o = r.getMemberPath(i.callee), c = r.unwrapExpression(i.callee);
121
- return (a === 0 && c.type === "MemberExpression" && !c.computed && s.has(c.property.name) || a === 1 && o?.join(".") === "Object.hasOwn") && n(i, t);
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 f(e, t, n) {
124
- let { text: r } = t, i = l(e, t, n);
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 p(e, t) {
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 { c as stringLiteral };
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 only a timeout can kill, and the usual loggers, whose message
5
- * texts are not mutated.
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 only a timeout can kill and the coarse mutants that the solitary
5
- * rule would drop.
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 or hit-limit timeout only
7
- * when the control tries right before and right after it both passed, else it
8
- * is doubtful. An accepted kill is heuristic and final: passing controls do not
9
- * prove that the mutant alone fails the test, since state an earlier try left
10
- * can fail it, such as a value a control try set that the mutant no longer
11
- * resets; the default mode decides every mutant isolated instead. A try that
12
- * ran out of time has no control after it, since the worker gives up the unit:
13
- * it counts only after a passing control, and then waits for a confirmation
14
- * with doubled bounds in a fresh run, or is final when the run was one.
15
- * Doubtful tries and late errors send the mutant to the isolated path; a
16
- * reached pass is only noted, since state left by a control try may hide the
17
- * mutant, and the core rechecks it on the isolated path. A unit whose suite
18
- * hook failed sends every mutant it planned that is still undecided to the
19
- * isolated path. A test whose leading control skipped itself ends its repeats
20
- * there, so its mutants count as tried without evidence rather than missing. A
21
- * hung unit gets a `worker-hang` warning and its timed-out try the cause
22
- * `hang`. Accepted kills and passes, whether they reached the mutant or not, go
23
- * to the cache of the run, so a later run reuses a kill only after the same
24
- * passes, unless the kill came from the first test of the mutant
25
- * (`applyCachedBatch`).
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 confirmed timeouts with doubled
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 e = o === "time-limit" && c ? "hang" : o;
45
- e === "hit-limit" || i ? n.verdict = {
46
- cause: e,
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: e,
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" || a === "hit-limit";
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