Answer prose round 2: 0 🔴, 4 🟡 (0 misread); say what with_tests_of returns first, and word the Rust help and docstrings plainly

This commit is contained in:
2026-11-27 17:11:31 +01:00
parent 86efe8fa57
commit ce92bedde9
3 changed files with 13 additions and 12 deletions
+4 -3
View File
@@ -40,9 +40,10 @@ No model judges anything: the bench runs programs, and reads Haiku's own stream.
`*_test.go`, `*.test.*` or `*.spec.*`. A test of any other name counts as code, such as `src/PickTest.php` or `*_test.go`, `*.test.*` or `*.spec.*`. A test of any other name counts as code, such as `src/PickTest.php` or
`src/pick-test.js`, so Haiku's change to it stands. In a Rust file, each inline `#[cfg(test)]` module stands as the planted `src/pick-test.js`, so Haiku's change to it stands. In a Rust file, each inline `#[cfg(test)]` module stands as the planted
file has it, and the rest is as Haiku left it. So does each `#[cfg(test)] mod name;` the planted file declares, and the file it file has it, and the rest is as Haiku left it. So does each `#[cfg(test)] mod name;` the planted file declares, and the file it
names: `name.rs` or `name/mod.rs`, in the declaring file's folder or in a folder named for that file without `.rs`. Where the names: `name.rs` or `name/mod.rs`, in the declaring file's folder or in a folder named for that file without `.rs`. Where
planted file has such modules or declarations and Haiku's file lacks one of them, or its modules cannot be told apart, the Haiku's file lacks a module or declaration of the planted file's, or the planted file has inline modules and Haiku's cannot be
planted file stands whole; where the planted file has none, or its modules cannot be told apart, Haiku's stands. A Rust mutant told apart, the planted file stands whole; where the planted file's inline modules cannot be told apart, or it has none and
Haiku's cannot be told apart, Haiku's stands. A Rust mutant
whose file's modules cannot be told apart, as where two share a name or a brace, string or comment is never closed, is passed whose file's modules cannot be told apart, as where two share a name or a brace, string or comment is never closed, is passed
over. So is each Rust mutant of a tree where a `#[cfg(test)] mod name;` names no file the bench finds, or where a Rust file has a over. So is each Rust mutant of a tree where a `#[cfg(test)] mod name;` names no file the bench finds, or where a Rust file has a
string or comment that is never closed. No bug is planted in a file that such a declaration names. string or comment that is never closed. No bug is planted in a file that such a declaration names.
+8 -8
View File
@@ -57,7 +57,7 @@ def modules(source: bytes) -> dict[bytes, tuple[int, int]] | None:
def declared(source: bytes) -> list[str] | None: def declared(source: bytes) -> list[str] | None:
"""The name of each `#[cfg(test)] mod name;` of source, a test module kept in a file of its own, in the order they stand. None where """The name of each `#[cfg(test)] mod name;` of source, in the order they stand. The module's code is in a file of its own. None where
a string or comment is never closed.""" a string or comment is never closed."""
names = [] names = []
position = 0 position = 0
@@ -71,9 +71,9 @@ def declared(source: bytes) -> list[str] | None:
def homes(path: str, name: str) -> list[str]: def homes(path: str, name: str) -> list[str]:
"""Each place the file of the module `name`, declared in the Rust file at path, may stand, by its path from the same top. Rust keeps """Each place the file of the module `name`, declared in the Rust file at path, may stand, as paths from the same top: beside the
it in the folder of the declaring file, or in a folder of that file's name where it is a module file, `a.rs` for `a/`; which of the declaring file, or in a folder named for it without `.rs`. Which of the two holds depends on the kind of file the declarer is, which
two the file is depends on what the crate's root is, so both count.""" this doesn't know, so both count."""
declaring = pathlib.PurePosixPath(path) declaring = pathlib.PurePosixPath(path)
return [str(folder / part) for folder in (declaring.parent, declaring.parent / declaring.stem) for part in (f"{name}.rs", f"{name}/mod.rs")] return [str(folder / part) for folder in (declaring.parent, declaring.parent / declaring.stem) for part in (f"{name}.rs", f"{name}/mod.rs")]
@@ -115,10 +115,10 @@ def with_tests_of(planted: bytes, copy: bytes) -> bytes:
"""copy with each of its test modules replaced by the one of that name in planted, and each that planted lacks left out. So a test a """copy with each of its test modules replaced by the one of that name in planted, and each that planted lacks left out. So a test a
fix changed, removed or added doesn't count. fix changed, removed or added doesn't count.
Where planted's modules cannot be told apart, or planted has none and copy's cannot be told apart, copy is returned as it is. Where Where copy lacks a `mod name;` declaration of planted's, or cannot have its declarations told apart, planted is returned: the file
planted has some and copy's cannot be told apart, or copy lacks one of planted's, planted is returned: Haiku's file has no module of that module stands as planted, and a fix that drops the declaration would leave its tests uncompiled. Otherwise, where planted's
to put them in. The same holds for the `mod name;` declarations of planted, whose files stand as planted: a fix that drops one modules cannot be told apart, or planted has none and copy's cannot be told apart, copy is returned as it is. Where planted has some
would leave its tests uncompiled.""" and copy's cannot be told apart, or copy lacks one of planted's, planted is returned: Haiku's file has no module to put them in."""
if not set(declared(planted) or []) <= set(declared(copy) or []): if not set(declared(planted) or []) <= set(declared(copy) or []):
return planted return planted
before, after = modules(planted), modules(copy) before, after = modules(planted), modules(copy)
+1 -1
View File
@@ -6,8 +6,8 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from task_bench import rust_test_modules
from task_bench.rust_test_modules import homes, tells_apart from task_bench.rust_test_modules import homes, tells_apart
from task_bench import rust_test_modules
LIB = textwrap.dedent("""\ LIB = textwrap.dedent("""\
pub fn add(a: i32, b: i32) -> i32 { pub fn add(a: i32, b: i32) -> i32 {