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:
@@ -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
|
||||
`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
|
||||
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
|
||||
planted file has such modules or declarations and Haiku's file lacks one of them, or its modules cannot be told apart, the
|
||||
planted file stands whole; where the planted file has none, or its modules cannot be told apart, Haiku's stands. A Rust mutant
|
||||
names: `name.rs` or `name/mod.rs`, in the declaring file's folder or in a folder named for that file without `.rs`. Where
|
||||
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
|
||||
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
|
||||
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.
|
||||
|
||||
@@ -57,7 +57,7 @@ def modules(source: bytes) -> dict[bytes, tuple[int, int]] | 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."""
|
||||
names = []
|
||||
position = 0
|
||||
@@ -71,9 +71,9 @@ def declared(source: bytes) -> list[str] | None:
|
||||
|
||||
|
||||
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
|
||||
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
|
||||
two the file is depends on what the crate's root is, so both count."""
|
||||
"""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
|
||||
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
|
||||
this doesn't know, so both count."""
|
||||
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")]
|
||||
|
||||
@@ -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
|
||||
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
|
||||
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
|
||||
to put them in. The same holds for the `mod name;` declarations of planted, whose files stand as planted: a fix that drops one
|
||||
would leave its tests uncompiled."""
|
||||
Where copy lacks a `mod name;` declaration of planted's, or cannot have its declarations told apart, planted is returned: the file
|
||||
of that module stands as planted, and a fix that drops the declaration would leave its tests uncompiled. Otherwise, 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 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 to put them in."""
|
||||
if not set(declared(planted) or []) <= set(declared(copy) or []):
|
||||
return planted
|
||||
before, after = modules(planted), modules(copy)
|
||||
|
||||
@@ -6,8 +6,8 @@ import unittest
|
||||
|
||||
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 import rust_test_modules
|
||||
|
||||
LIB = textwrap.dedent("""\
|
||||
pub fn add(a: i32, b: i32) -> i32 {
|
||||
|
||||
Reference in New Issue
Block a user