diff options
author | Norbert Preining <norbert@preining.info> | 2023-02-26 03:02:12 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-02-26 03:02:12 +0000 |
commit | e7ae872926eddb0de09ecfe1c578e0680033955a (patch) | |
tree | 01717465b5b26d3b2ccaea9889c720a840e0a16c /support/texlab/src/tests/workspace/symbol.rs | |
parent | 81a9d839224eef4c2bd9bf68410b4049c61cdb14 (diff) |
CTAN sync 202302260302
Diffstat (limited to 'support/texlab/src/tests/workspace/symbol.rs')
-rw-r--r-- | support/texlab/src/tests/workspace/symbol.rs | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/support/texlab/src/tests/workspace/symbol.rs b/support/texlab/src/tests/workspace/symbol.rs deleted file mode 100644 index 626cce3c0b..0000000000 --- a/support/texlab/src/tests/workspace/symbol.rs +++ /dev/null @@ -1,142 +0,0 @@ -use insta::{assert_json_snapshot, internals::Redaction}; -use lsp_types::{ - request::WorkspaceSymbol, ClientCapabilities, SymbolInformation, Url, WorkspaceSymbolParams, -}; - -use crate::tests::{client::Client, fixture}; - -struct SymbolResult { - actual_symbols: Vec<SymbolInformation>, - uri_redaction: Redaction, -} - -fn find_symbols(fixture: &str, query: &str) -> SymbolResult { - let mut client = Client::spawn(); - client.initialize(ClientCapabilities::default(), None); - - let fixture = fixture::parse(fixture); - for file in fixture.files { - client.open(file.name, file.lang, file.text); - } - - let actual_symbols = client - .request::<WorkspaceSymbol>(WorkspaceSymbolParams { - query: query.to_string(), - work_done_progress_params: Default::default(), - partial_result_params: Default::default(), - }) - .unwrap() - .unwrap_or_default(); - - let result = client.shutdown(); - - let uri = Url::from_directory_path(result.directory.path()).unwrap(); - let uri_redaction = insta::dynamic_redaction(move |content, _path| { - content.as_str().unwrap().replace(uri.as_str(), "[tmp]/") - }); - - SymbolResult { - actual_symbols, - uri_redaction, - } -} - -macro_rules! assert_symbols { - ($result:expr) => { - let result = $result; - assert_json_snapshot!(result.actual_symbols, { - "[].location.uri" => result.uri_redaction, - "[]" => insta::sorted_redaction() - }); - }; -} - -const FIXTURE: &str = r#" -%TEX main.tex -%SRC \documentclass{article} -%SRC \usepackage{caption} -%SRC \usepackage{amsmath} -%SRC \usepackage{amsthm} -%SRC -%SRC \begin{document} -%SRC -%SRC \section{Foo}\label{sec:foo} -%SRC -%SRC \begin{equation}\label{eq:foo} -%SRC Foo -%SRC \end{equation} -%SRC -%SRC \section{Bar}\label{sec:bar} -%SRC -%SRC \begin{figure} -%SRC Bar -%SRC \caption{Bar} -%SRC \label{fig:bar} -%SRC \end{figure} -%SRC -%SRC \section{Baz}\label{sec:baz} -%SRC -%SRC \begin{enumerate} -%SRC \item\label{itm:foo} Foo -%SRC \item\label{itm:bar} Bar -%SRC \item\label{itm:baz} Baz -%SRC \end{enumerate} -%SRC -%SRC \section{Qux}\label{sec:qux} -%SRC -%SRC \newtheorem{lemma}{Lemma} -%SRC -%SRC \begin{lemma}[Qux]\label{thm:qux} -%SRC Qux -%SRC \end{lemma} -%SRC -%SRC \end{document} - -%TEX main.aux -%SRC \relax -%SRC \@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Bar\relax }}{1}\protected@file@percent } -%SRC \providecommand*\caption@xref[2]{\@setref\relax\@undefined{#1}} -%SRC \newlabel{fig:bar}{{1}{1}} -%SRC \@writefile{toc}{\contentsline {section}{\numberline {1}Foo}{1}\protected@file@percent } -%SRC \newlabel{sec:foo}{{1}{1}} -%SRC \newlabel{eq:foo}{{1}{1}} -%SRC \@writefile{toc}{\contentsline {section}{\numberline {2}Bar}{1}\protected@file@percent } -%SRC \newlabel{sec:bar}{{2}{1}} -%SRC \@writefile{toc}{\contentsline {section}{\numberline {3}Baz}{1}\protected@file@percent } -%SRC \newlabel{sec:baz}{{3}{1}} -%SRC \newlabel{itm:foo}{{1}{1}} -%SRC \newlabel{itm:bar}{{2}{1}} -%SRC \newlabel{itm:baz}{{3}{1}} -%SRC \@writefile{toc}{\contentsline {section}{\numberline {4}Qux}{1}\protected@file@percent } -%SRC \newlabel{sec:qux}{{4}{1}} -%SRC \newlabel{thm:qux}{{1}{1}} - -%BIB main.bib -%SRC @article{foo,} -%SRC -%SRC @string{bar = "bar"}"#; - -#[test] -fn filter_type_section() { - assert_symbols!(find_symbols(FIXTURE, "section")); -} - -#[test] -fn filter_type_figure() { - assert_symbols!(find_symbols(FIXTURE, "figure")); -} - -#[test] -fn filter_type_item() { - assert_symbols!(find_symbols(FIXTURE, "item")); -} - -#[test] -fn filter_type_math() { - assert_symbols!(find_symbols(FIXTURE, "math")); -} - -#[test] -fn filter_bibtex() { - assert_symbols!(find_symbols(FIXTURE, "bibtex")); -} |