From 45c7bac9080d91b53c686e776fc6217d7f139b86 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 12 Apr 2023 03:01:14 +0000 Subject: CTAN sync 202304120301 --- .../texlab/tests/lsp/text_document/formatting.rs | 134 --------------------- 1 file changed, 134 deletions(-) delete mode 100644 support/texlab/tests/lsp/text_document/formatting.rs (limited to 'support/texlab/tests/lsp/text_document/formatting.rs') diff --git a/support/texlab/tests/lsp/text_document/formatting.rs b/support/texlab/tests/lsp/text_document/formatting.rs deleted file mode 100644 index 295022c76a..0000000000 --- a/support/texlab/tests/lsp/text_document/formatting.rs +++ /dev/null @@ -1,134 +0,0 @@ -use insta::assert_snapshot; -use lsp_types::{ - request::Formatting, ClientCapabilities, DocumentFormattingParams, FormattingOptions, -}; -use texlab::util::{line_index::LineIndex, line_index_ext::LineIndexExt}; - -use crate::fixture::TestBed; - -fn format(fixture: &str) -> String { - let test_bed = TestBed::new(fixture).unwrap(); - test_bed.initialize(ClientCapabilities::default()).unwrap(); - - let text_document = test_bed.cursor().unwrap().text_document; - let edits = test_bed - .client() - .send_request::(DocumentFormattingParams { - text_document, - work_done_progress_params: Default::default(), - options: FormattingOptions { - insert_spaces: true, - tab_size: 4, - ..Default::default() - }, - }) - .unwrap() - .unwrap_or_default(); - - let old_text = &test_bed.documents()[0].text; - let line_index = LineIndex::new(old_text); - let mut new_text = String::from(old_text); - for edit in edits.into_iter().rev() { - let range = line_index.offset_lsp_range(edit.range); - new_text.replace_range::>(range.into(), &edit.new_text); - } - - new_text -} - -#[test] -fn bibtex_internal_wrap_long_lines() { - assert_snapshot!(format( - r#" -%! main.bib -@article{foo, bar = {Lorem ipsum dolor sit amet, consectetur adipiscing elit. -Lorem ipsum dolor sit amet, -consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.},} -|"#, - )); -} - -#[test] -fn bibtex_internal_multiple_entries() { - assert_snapshot!(format( - r#" -%! main.bib -@article{foo, bar = {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, -consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.},} - -@article{foo, bar = {Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, -consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit.},}" -|"#, - )); -} - -#[test] -fn bibtex_internal_trailing_comma() { - assert_snapshot!(format( - r#" -%! main.bib -@article{foo, bar = baz} -|"#, - )); -} - -#[test] -fn bibtex_internal_insert_braces() { - assert_snapshot!(format( - r#" -%! main.bib -@article{foo, bar = baz, -|"#, - )); -} - -#[test] -fn bibtex_internal_command() { - assert_snapshot!(format( - r#" -%! main.bib -@article{foo, bar = "\baz",} -|"#, - )); -} - -#[test] -fn bibtex_internal_join_strings() { - assert_snapshot!(format( - r#" -%! main.bib -@article{foo, bar = "baz" # "qux"} -|"#, - )); -} - -#[test] -fn bibtex_internal_parens() { - assert_snapshot!(format( - r#" -%! main.bib -@article(foo,) -|"#, - )); -} - -#[test] -fn bibtex_internal_string() { - assert_snapshot!(format( - r#" -%! main.bib -@string{foo="bar"} -|"#, - )); -} - -#[test] -fn bibtex_internal_preamble() { - assert_snapshot!(format( - r#" -%! main.bib -@preamble{ - "foo bar baz" } -|"#, - )); -} -- cgit v1.2.3