Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add integration test of lsp and Konfig #714

Merged
merged 2 commits into from
Sep 18, 2023
Merged
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
36 changes: 2 additions & 34 deletions kclvm/tools/src/LSP/src/goto_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,45 +374,13 @@ pub(crate) fn get_identifier_last_name(id: &Identifier) -> String {

#[cfg(test)]
mod tests {
use super::goto_definition;
use crate::tests::{compare_goto_res, compile_test_file};
use indexmap::IndexSet;
use kclvm_error::Position as KCLPos;
use lsp_types::{request::GotoTypeDefinitionResponse, Position};
use proc_macro_crate::bench_test;
use std::path::PathBuf;

use crate::tests::compile_test_file;

use super::goto_definition;

fn compare_goto_res(
res: Option<GotoTypeDefinitionResponse>,
pos: (&String, u32, u32, u32, u32),
) {
match res.unwrap() {
lsp_types::GotoDefinitionResponse::Scalar(loc) => {
let got_path = loc.uri.path();
assert_eq!(got_path, pos.0);

let (got_start, got_end) = (loc.range.start, loc.range.end);

let expected_start = Position {
line: pos.1, // zero-based
character: pos.2,
};

let expected_end = Position {
line: pos.3, // zero-based
character: pos.4,
};
assert_eq!(got_start, expected_start);
assert_eq!(got_end, expected_end);
}
_ => {
unreachable!("test error")
}
}
}

#[test]
#[bench_test]
fn goto_import_pkg_test() {
Expand Down
Loading
Loading