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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user