diff --git a/tests/issues.rs b/tests/issues.rs new file mode 100644 index 00000000..2eaff818 --- /dev/null +++ b/tests/issues.rs @@ -0,0 +1,50 @@ +mod support; + +use tokio::io::{AsyncBufRead, AsyncWrite}; + +use lsp_types::{ + DocumentSymbolParams, DocumentSymbolResponse, PublishDiagnosticsParams, TextDocumentIdentifier, +}; + +async fn document_symbols( + stdin: &mut (dyn AsyncWrite + std::marker::Unpin + Send), + stdout: &mut (dyn AsyncBufRead + std::marker::Unpin + Send), + id: u64, + uri: &str, +) -> DocumentSymbolResponse { + support::run_method_call::( + stdin, + stdout, + id, + DocumentSymbolParams { + text_document: TextDocumentIdentifier { + uri: support::test_url(uri), + }, + work_done_progress_params: Default::default(), + partial_result_params: Default::default(), + }, + ) + .await + .unwrap() +} + +#[test] +fn issue_40() { + support::send_rpc(|stdin, stdout| { + Box::pin(async move { + let text = r#" +type U = (Int, Int) + +() +"#; + support::did_open(stdin, "test.glu", text).await; + + let diagnostic: PublishDiagnosticsParams = + support::expect_notification(&mut *stdout).await; + + assert_eq!(diagnostic.uri, support::test_url("test.glu")); + + document_symbols(stdin, stdout, 1, "test.glu").await; + }) + }); +} diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 0cb69b30..8882e5d4 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -55,6 +55,22 @@ where .await } +pub async fn run_method_call( + writer: &mut (dyn AsyncWrite + std::marker::Unpin + Send), + reader: &mut (dyn AsyncBufRead + std::marker::Unpin + Send), + id: u64, + value: T::Params, +) -> T::Result +where + T: lsp_types::request::Request, +{ + let call = method_call(T::METHOD, id, value); + + write_message(writer, call).await.unwrap(); + + expect_response(reader).await +} + pub fn method_call(method: &str, id: u64, value: T) -> Call where T: Serialize,