Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions crates/amalthea/tests/client/dummy_frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ use crossbeam::channel::Sender;
use super::control;
use super::shell;

static AMALTHEA_FRONTEND: OnceLock<
Arc<Mutex<(DummyFrontend, Sender<CommEvent>, Sender<IOPubMessage>)>>,
> = OnceLock::new();
type FrontendState = (DummyFrontend, Sender<CommEvent>, Sender<IOPubMessage>);

static AMALTHEA_FRONTEND: OnceLock<Arc<Mutex<FrontendState>>> = OnceLock::new();

/// Wrapper around `DummyFrontend` that checks sockets are empty on drop
pub struct DummyAmaltheaFrontend {
pub comm_event_tx: Sender<CommEvent>,
pub iopub_tx: Sender<IOPubMessage>,
guard: MutexGuard<'static, (DummyFrontend, Sender<CommEvent>, Sender<IOPubMessage>)>,
guard: MutexGuard<'static, FrontendState>,
}

impl DummyAmaltheaFrontend {
Expand All @@ -50,12 +50,11 @@ impl DummyAmaltheaFrontend {
}
}

fn get_frontend(
) -> &'static Arc<Mutex<(DummyFrontend, Sender<CommEvent>, Sender<IOPubMessage>)>> {
fn get_frontend() -> &'static Arc<Mutex<FrontendState>> {
AMALTHEA_FRONTEND.get_or_init(|| Arc::new(Mutex::new(DummyAmaltheaFrontend::init())))
}

fn init() -> (DummyFrontend, Sender<CommEvent>, Sender<IOPubMessage>) {
fn init() -> FrontendState {
let connection = DummyConnection::new();
let (connection_file, registration_file) = connection.get_connection_files();

Expand Down
8 changes: 4 additions & 4 deletions crates/ark/src/dap/dap_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ mod tests {

dap.did_change_document(&uri);

assert!(dap.breakpoints.get(&uri).is_none());
assert!(!dap.breakpoints.contains_key(&uri));

let event1 = rx.try_recv().unwrap();
let event2 = rx.try_recv().unwrap();
Expand Down Expand Up @@ -848,8 +848,8 @@ mod tests {

dap.did_change_document(&uri1);

assert!(dap.breakpoints.get(&uri1).is_none());
assert!(dap.breakpoints.get(&uri2).is_some());
assert!(!dap.breakpoints.contains_key(&uri1));
assert!(dap.breakpoints.contains_key(&uri2));

let event = rx.try_recv().unwrap();
assert!(matches!(event, DapBackendEvent::BreakpointState {
Expand Down Expand Up @@ -897,6 +897,6 @@ mod tests {
dap.did_change_document(&uri);

// Breakpoints should still be removed
assert!(dap.breakpoints.get(&uri).is_none());
assert!(!dap.breakpoints.contains_key(&uri));
}
}
11 changes: 7 additions & 4 deletions crates/ark/src/lsp/inputs/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,14 @@ mod tests {

#[test]
fn exported_symbols_are_sorted_and_unique() {
let mut ns = Namespace::default();
ns.exports = vec!["b".to_string(), "a".to_string(), "a".to_string()];
let ns = Namespace {
exports: vec!["b".to_string(), "a".to_string(), "a".to_string()],
..Default::default()
};

let mut index = Index::default();
index.names = vec!["c".to_string(), "a".to_string(), "a".to_string()];
let index = Index {
names: vec!["c".to_string(), "a".to_string(), "a".to_string()],
};

let pkg = new_package("foo", ns, index);
assert_eq!(pkg.exported_symbols, vec!["a", "b", "c"]);
Expand Down
14 changes: 9 additions & 5 deletions crates/ark/src/lsp/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,12 +1135,16 @@ outer <- 4

let code = "# Section ----\nfoo <- 1";

let mut config = LspConfig::default();
config.workspace_symbols = WorkspaceSymbolsConfig {
include_comment_sections,
let config = LspConfig {
workspace_symbols: WorkspaceSymbolsConfig {
include_comment_sections,
},
..Default::default()
};
let state = WorldState {
config,
..Default::default()
};
let mut state = WorldState::default();
state.config = config;

// Index the document
let doc = Document::new(code, None);
Expand Down
5 changes: 4 additions & 1 deletion crates/stdext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ macro_rules! assert_match {
};

($expression:expr, $pattern:pat_param) => {
assert!(matches!($expression, $pattern))
#[allow(clippy::redundant_pattern_matching)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know what this one is about?

{
assert!(matches!($expression, $pattern))
}
};
}

Expand Down
Loading