mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 20:28:33 +00:00
fix tests
This commit is contained in:
parent
be84a112a7
commit
01cf32c46e
@ -167,7 +167,7 @@ impl NavigationTarget {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use ra_syntax::TextRange;
|
use ra_syntax::TextRange;
|
||||||
use crate::mock_analysis::single_file_with_position;
|
use crate::mock_analysis::{single_file_with_position, single_file_with_range};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hover_shows_type_of_an_expression() {
|
fn hover_shows_type_of_an_expression() {
|
||||||
@ -191,4 +191,52 @@ mod tests {
|
|||||||
let hover = analysis.hover(position).unwrap().unwrap();
|
let hover = analysis.hover(position).unwrap().unwrap();
|
||||||
assert_eq!(hover.info, "i32");
|
assert_eq!(hover.info, "i32");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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_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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
mod runnables;
|
mod runnables;
|
||||||
mod type_of;
|
|
||||||
|
|
||||||
use ra_syntax::TextRange;
|
use ra_syntax::TextRange;
|
||||||
use test_utils::{assert_eq_dbg, assert_eq_text};
|
use test_utils::{assert_eq_dbg, assert_eq_text};
|
||||||
|
@ -1,77 +0,0 @@
|
|||||||
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…
Reference in New Issue
Block a user