Skip to content

Commit

Permalink
test: add integration test of lsp and Konfig (#714)
Browse files Browse the repository at this point in the history
* test: add integration test of lsp and Konfig

* fix konfig integration test path
  • Loading branch information
He1pa authored Sep 18, 2023
1 parent 9286e95 commit 139c3a3
Show file tree
Hide file tree
Showing 3 changed files with 436 additions and 34 deletions.
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

0 comments on commit 139c3a3

Please sign in to comment.