diff options
| author | Ian Wrzesinski <133046678+wrzian@users.noreply.github.com> | 2024-12-11 06:28:24 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-11 11:28:24 +0000 |
| commit | a5ade167dd24fe3efdb3391dcb72a09b4dd1a268 (patch) | |
| tree | 29fffc16f164a2b72c9ef76838b21b82ddcd3948 /crates/typst-ide/src | |
| parent | 17f20c6944d569d5f0bb57caee37d9f208d87d0d (diff) | |
More `CapturesVisitor` tests (#5506)
Diffstat (limited to 'crates/typst-ide/src')
| -rw-r--r-- | crates/typst-ide/src/tooltip.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/typst-ide/src/tooltip.rs b/crates/typst-ide/src/tooltip.rs index adfbeda5..4eaaeda1 100644 --- a/crates/typst-ide/src/tooltip.rs +++ b/crates/typst-ide/src/tooltip.rs @@ -337,6 +337,21 @@ mod tests { fn test_tooltip_closure() { test("#let f(x) = x + y", 11, Side::Before) .must_be_text("This closure captures `y`"); + // Same tooltip if `y` is defined first. + test("#let y = 10; #let f(x) = x + y", 24, Side::Before) + .must_be_text("This closure captures `y`"); + // Names are sorted. + test("#let f(x) = x + y + z + a", 11, Side::Before) + .must_be_text("This closure captures `a`, `y`, and `z`"); + // Names are de-duplicated. + test("#let f(x) = x + y + z + y", 11, Side::Before) + .must_be_text("This closure captures `y` and `z`"); + // With arrow syntax. + test("#let f = (x) => x + y", 15, Side::Before) + .must_be_text("This closure captures `y`"); + // No recursion with arrow syntax. + test("#let f = (x) => x + y + f", 13, Side::After) + .must_be_text("This closure captures `f` and `y`"); } #[test] |
