added indoc to tests and increased delay to ensure it is longer than change debounce

Signed-off-by: faldor20 <eli.jambu@yahoo.com>
This commit is contained in:
Eli Dowling 2023-12-30 06:00:26 +10:00 committed by faldor20
parent 22b8c77232
commit 9d02662d2c
No known key found for this signature in database
GPG key ID: F2216079B890CD57
3 changed files with 27 additions and 20 deletions

1
Cargo.lock generated
View file

@ -2697,6 +2697,7 @@ dependencies = [
"bumpalo", "bumpalo",
"env_logger 0.10.1", "env_logger 0.10.1",
"expect-test", "expect-test",
"indoc",
"log", "log",
"parking_lot", "parking_lot",
"roc_can", "roc_can",

View file

@ -32,4 +32,5 @@ parking_lot.workspace = true
tower-lsp = "0.17.0" tower-lsp = "0.17.0"
tokio = { version = "1.20.1", features = [ "rt", "rt-multi-thread", "macros", "io-std" ] } tokio = { version = "1.20.1", features = [ "rt", "rt-multi-thread", "macros", "io-std" ] }
log.workspace = true log.workspace = true
indoc.workspace=true
env_logger = "0.10.1" env_logger = "0.10.1"

View file

@ -1,8 +1,8 @@
use analysis::HIGHLIGHT_TOKENS_LEGEND; use analysis::HIGHLIGHT_TOKENS_LEGEND;
use indoc::indoc;
use log::{debug, trace}; use log::{debug, trace};
use registry::Registry; use registry::Registry;
use std::future::Future; use std::future::Future;
use std::time::Duration; use std::time::Duration;
use tower_lsp::jsonrpc::Result; use tower_lsp::jsonrpc::Result;
use tower_lsp::lsp_types::*; use tower_lsp::lsp_types::*;
@ -374,12 +374,12 @@ mod tests {
.map(completion_resp_to_labels) .map(completion_resp_to_labels)
} }
const DOC_LIT: &str = r#" const DOC_LIT: &str = indoc! {r#"
app "fizz-buzz" app "fizz-buzz"
packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" } packages { pf: "https://github.com/roc-lang/basic-cli/releases/download/0.5.0/Cufzl36_SnJ4QbOoEmiJ5dIpUxBvdB3NEySvuH82Wio.tar.br" }
imports [pf.Stdout,pf.Task.{ Task, await },] imports [pf.Stdout,pf.Task.{ Task, await },]
provides [main] to pf provides [main] to pf
"#; "#};
static INIT: Once = Once::new(); static INIT: Once = Once::new();
async fn test_setup(doc: String) -> (RocServerState, Url) { async fn test_setup(doc: String) -> (RocServerState, Url) {
INIT.call_once(|| { INIT.call_once(|| {
@ -399,10 +399,12 @@ app "fizz-buzz"
#[tokio::test] #[tokio::test]
async fn test_completion_with_changes() { async fn test_completion_with_changes() {
let doc = DOC_LIT.to_string() let doc = DOC_LIT.to_string()
+ r#"rec=\a,b->{one:{potato:\d->d,leak:59},two:b} + indoc! {r#"
rectest= rec=\a,b->{one:{potato:\d->d,leak:59},two:b}
value= rec 1 2 rectest=
va"#; value= rec 1 2
va
"#};
let (inner, url) = test_setup(doc.clone()).await; let (inner, url) = test_setup(doc.clone()).await;
static INNER_CELL: OnceLock<RocServerState> = OnceLock::new(); static INNER_CELL: OnceLock<RocServerState> = OnceLock::new();
INNER_CELL.set(inner).unwrap(); INNER_CELL.set(inner).unwrap();
@ -427,7 +429,7 @@ rectest=
}); });
// Simulate two changes coming in with a slight delay // Simulate two changes coming in with a slight delay
let a = spawn(inner.change(&url, doc.clone() + "lue.o", 6)); let a = spawn(inner.change(&url, doc.clone() + "lue.o", 6));
tokio::time::sleep(Duration::from_millis(100)).await; tokio::time::sleep(Duration::from_millis(200)).await;
let rest = spawn(inner.change(&url, doc.clone() + "lue.on", 7)); let rest = spawn(inner.change(&url, doc.clone() + "lue.on", 7));
let done = join!(a1, a2, a3, a4, comp, a, rest); let done = join!(a1, a2, a3, a4, comp, a, rest);
@ -480,10 +482,11 @@ rectest=
#[tokio::test] #[tokio::test]
async fn test_completion_as_identifier() { async fn test_completion_as_identifier() {
let suffix = DOC_LIT.to_string() let suffix = DOC_LIT.to_string()
+ r#" + indoc! {r#"
main = main =
when a is when a is
inn as outer -> "#; inn as outer ->
"#};
let (inner, url) = test_setup(suffix.clone()).await; let (inner, url) = test_setup(suffix.clone()).await;
let position = Position::new(8, 21); let position = Position::new(8, 21);
let reg = &inner.registry; let reg = &inner.registry;
@ -519,10 +522,12 @@ main =
#[tokio::test] #[tokio::test]
async fn test_completion_as_record() { async fn test_completion_as_record() {
let doc = DOC_LIT.to_string() let doc = DOC_LIT.to_string()
+ r#" + indoc! {r#"
main = main =
when a is when a is
{one,two} as outer -> "#; {one,two} as outer ->
"#};
let (inner, url) = test_setup(doc.clone()).await; let (inner, url) = test_setup(doc.clone()).await;
let position = Position::new(8, 27); let position = Position::new(8, 27);
let reg = &inner.registry; let reg = &inner.registry;