Repository navigation
semantic_mutants: leave docstrings alone, so their op names are not reported as surviving mutants (OLD-9432) - #660
Conversation
lixonik
left a comment
There was a problem hiding this comment.
Independent CLI check at e3c4d0c1 with synthetic Python sources and --lines N-N --list. A one-line range inside an ordinary multiline docstring yields zero mutants. Adding a preceding comment containing """ makes the equivalent range yield one mutant, OpIAdd to OpISub. An implicitly concatenated first-statement docstring also yields one mutant: "OpIAdd is an example. " "Emit an instruction.".
Python's ast.get_docstring() recognizes both variants. The first appears to come from counting delimiters in raw lines and the second from treating adjacent string tokens as separate statements. A scan of the checked-in translator's docstrings found zero mutants, so these are synthetic coverage cases. Could both be added to the regression tests? Relevant logic
AI-assisted testing. No game data or GPU used.
|
Ran
No GPU leg (CPU tool). AI-assisted. |
…longer hide or split a docstring Review on ProjectLeonida#660 (lixonik): a comment holding `"""` before a docstring flipped the delimiter count, so a --lines range inside the docstring was mutated as code, and a docstring written as adjacent literals ("a " "b") was not recognised. Follow triple-quote delimiters with a small scanner that skips comments, one-line strings and escaped delimiters, and take a run of adjacent string tokens ending the statement as one docstring. A literal that is read by the code after it stays code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks — both reproduced and fixed in 4a5458b:
Both cases are in |
|
Thanks for the fix. I independently retested AI-assisted testing with synthetic inputs. No game data or GPU used. |
…eported as surviving mutants mutants_for treated any line that starts with a quote as code (meant for `f"... OpIAdd ..."` emit lines), so a docstring that names an opcode or GLSL op produced mutants that can never fail a test and were always reported SURVIVED: `--function nminmax_f32` listed 5 mutants, 4 of them in its docstring, and 47 across rdna2spirv.py. Tokenize the mutated range (dedented) and skip strings that stand alone as a statement; a range that does not tokenize keeps the old behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…idened to the whole string Review on ItsNotRexed/Leonida#9432 (Gevroska): `--lines 595-595` falls inside u16_half's docstring, so the tokenized slice had no opening delimiter and the text was mutated as code. Widen the tokenized span to whole triple-quoted strings, counting delimiters from the enclosing def or class (a text scan, cheap inside the long dispatch method). Every one of the translator's 1,049 docstring lines now gives 0 mutants as a one-line range. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…longer hide or split a docstring Review on ProjectLeonida#660 (lixonik): a comment holding `"""` before a docstring flipped the delimiter count, so a --lines range inside the docstring was mutated as code, and a docstring written as adjacent literals ("a " "b") was not recognised. Follow triple-quote delimiters with a small scanner that skips comments, one-line strings and escaped delimiters, and take a run of adjacent string tokens ending the statement as one docstring. A literal that is read by the code after it stays code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4a5458b to
ea10ffd
Compare
…longer hide or split a docstring Review on ProjectLeonida#660 (lixonik): a comment holding `"""` before a docstring flipped the delimiter count, so a --lines range inside the docstring was mutated as code, and a docstring written as adjacent literals ("a " "b") was not recognised. Follow triple-quote delimiters with a small scanner that skips comments, one-line strings and escaped delimiters, and take a run of adjacent string tokens ending the statement as one docstring. A literal that is read by the code after it stays code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in the coordination issue as: OLD-9432 (restoration of ItsNotRexed/Leonida#9432, closed unmerged when that repository went private)
mutants_fortreated any line starting with a quote as code (meant forf"... OpIAdd ..."emit lines), so a docstring naming an opcode produced mutants that can never fail a test and were always reported SURVIVED:--function nminmax_f32listed 5 mutants, 4 of them in its docstring, and 47 acrossrdna2spirv.py.--linesrange that starts inside a docstring is widened to the whole string (from review on the original PR:--lines 595-595insideu16_half's docstring was mutated as code). Every one of the translator's 1,049 docstring lines now gives 0 mutants as a one-line range.Tested:
python -I tests/test_semantic_mutants.py(13 tests OK) onmain21625bc, Linux, CPU only; no GPU needed. No game files.AI-assisted (Claude Code).
🤖 Generated with Claude Code