test: pin in-file calls to salted Rust functions and Go ids outside a collision group

Two guards for the review questions on #4468: an in-file call to
`ignore()`, `e()` or `E()` binds by the name as written and reaches the
salted node (on v8 the calls to `ignore()` and `E()` bind nowhere, since
those functions had no node), and the other types in a Go file that holds
a case-only pair keep the ids they have without the pair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5c49344807)
This commit is contained in:
samie a. authored and safishamsi committed 2026-10-16 17:12:53 +01:00
1 parent 918483e6a3
commit 5fcdb2d791
2 files changed
+25

No files matched your search

+13
View File
@@ -447,3 +447,16 @@ def test_case_only_sibling_type_ids_do_not_depend_on_declaration_order(tmp_path:
forward = ids(_gin_corpus(tmp_path, _GIN_IFACE, _GIN_STRUCT, _GIN_CONTEXT))
backward = ids(_gin_corpus(tmp_path, _GIN_STRUCT, _GIN_IFACE, _GIN_CONTEXT))
assert forward == backward
def test_non_colliding_types_keep_their_ids_beside_a_colliding_pair(tmp_path: Path) -> None:
"""Only the members of a collision group can move: the other types in the
file, exported or not, keep the ids they have in a file without the pair."""
other = "type node struct {\n\tpath string\n}\n"
def ids(result: dict) -> dict[str, str]:
return {n["label"]: n["id"] for n in result["nodes"]
if n.get("label") in ("Context", "node")}
alone = ids(_gin_corpus(tmp_path, _GIN_CONTEXT, other))
assert ids(_gin_corpus(tmp_path, _GIN_IFACE, _GIN_STRUCT, _GIN_CONTEXT, other)) == alone
+12
View File
@@ -159,3 +159,15 @@ def test_forward_reference_to_the_retained_type_lands_on_it(tmp_path: Path) -> N
assert [(n["label"], Path(n["source_file"]).name if n.get("source_file") else "")
for n in targets] == [("Ignore", "dir.rs")]
def test_calls_to_salted_functions_keep_their_in_file_edges(tmp_path: Path) -> None:
"""In-file calls bind by the name as written, so they reach the salted ids."""
result = _extract(
tmp_path,
_IGNORE_RS
+ "\nfn e(s: &str) -> u32 {\n 1\n}\n"
+ "\nfn E(s: &str) -> u32 {\n 2\n}\n"
+ "\nfn caller() -> u32 {\n let _ = ignore();\n e(\"a\") + E(\"b\")\n}\n",
)
calls = _edges(result, "calls")
assert {("caller()", "ignore()"), ("caller()", "e()"), ("caller()", "E()")} <= calls, calls