Merge #409
409: Add Analysis#teype_of test r=matklad a=h-michael Co-authored-by: Hirokazu Hata <h.hata.ai.t@gmail.com>
This commit is contained in:
commit
d29e98dd97
79
crates/ra_analysis/tests/type_of.rs
Normal file
79
crates/ra_analysis/tests/type_of.rs
Normal file
@ -0,0 +1,79 @@
|
||||
use ra_analysis::{
|
||||
mock_analysis::{single_file_with_range},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_type_of_for_function() {
|
||||
let (analysis, range) = single_file_with_range(
|
||||
"
|
||||
pub fn foo() -> u32 { 1 };
|
||||
|
||||
fn main() {
|
||||
let foo_test = <|>foo()<|>;
|
||||
}
|
||||
",
|
||||
);
|
||||
|
||||
let type_name = analysis.type_of(range).unwrap().unwrap();
|
||||
assert_eq!("u32", &type_name);
|
||||
}
|
||||
|
||||
// FIXME: improve type_of to make this work
|
||||
#[test]
|
||||
fn test_type_of_for_num() {
|
||||
let (analysis, range) = single_file_with_range(
|
||||
r#"
|
||||
fn main() {
|
||||
let foo_test = <|>"foo"<|>;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
||||
assert!(analysis.type_of(range).unwrap().is_none());
|
||||
}
|
||||
// FIXME: improve type_of to make this work
|
||||
#[test]
|
||||
fn test_type_of_for_binding() {
|
||||
let (analysis, range) = single_file_with_range(
|
||||
"
|
||||
pub fn foo() -> u32 { 1 };
|
||||
|
||||
fn main() {
|
||||
let <|>foo_test<|> = foo();
|
||||
}
|
||||
",
|
||||
);
|
||||
|
||||
assert!(analysis.type_of(range).unwrap().is_none());
|
||||
}
|
||||
|
||||
// FIXME: improve type_of to make this work
|
||||
#[test]
|
||||
fn test_type_of_for_expr_1() {
|
||||
let (analysis, range) = single_file_with_range(
|
||||
"
|
||||
fn main() {
|
||||
let foo = <|>1 + foo_test<|>;
|
||||
}
|
||||
",
|
||||
);
|
||||
|
||||
let type_name = analysis.type_of(range).unwrap().unwrap();
|
||||
assert_eq!("[unknown]", &type_name);
|
||||
}
|
||||
|
||||
// FIXME: improve type_of to make this work
|
||||
#[test]
|
||||
fn test_type_of_for_expr_2() {
|
||||
let (analysis, range) = single_file_with_range(
|
||||
"
|
||||
fn main() {
|
||||
let foo: usize = 1;
|
||||
let bar = <|>1 + foo_test<|>;
|
||||
}
|
||||
",
|
||||
);
|
||||
|
||||
let type_name = analysis.type_of(range).unwrap().unwrap();
|
||||
assert_eq!("[unknown]", &type_name);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user