test(highlight): PR #118 round 2 — assert shadowed console keeps @variable
Non-blocking review nit: the shadowing test only proved the `.builtin` captures disappeared. Also assert both `console` occurrences retain an ordinary `@variable` capture, so dropping the locals-predicate pattern loses only the `.builtin` refinement, not all styling for the token. Test-only. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YJ9FQ832QwftJXCD9LeFan
This commit is contained in:
parent
665fd82860
commit
b55f87e96d
|
|
@ -1384,6 +1384,22 @@ mod tests {
|
|||
builtin.is_empty(),
|
||||
"a locally-shadowed `console` must not get a *.builtin capture; got {builtin:?}"
|
||||
);
|
||||
// ...and dropping the builtin pattern must not strip *all* styling:
|
||||
// each `console` occurrence still keeps its ordinary `@variable`
|
||||
// capture (the fallback), so the loss is only the `.builtin` refine.
|
||||
let src = "const console = 5;\nconsole;\n";
|
||||
for (pos, _) in src.match_indices("console") {
|
||||
let (start, end) = (pos as u32, (pos + "console".len()) as u32);
|
||||
let caps: Vec<&str> = spans
|
||||
.iter()
|
||||
.filter(|s| s.start_byte == start && s.end_byte == end)
|
||||
.map(|s| names[s.capture_index as usize])
|
||||
.collect();
|
||||
assert!(
|
||||
caps.iter().any(|n| n.starts_with("variable")),
|
||||
"`console` at byte {pos} keeps a variable capture; got {caps:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in New Issue