From f5992964edb0e6dba7970c344b46bfd75f57e9a0 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Thu, 3 Jan 2019 12:01:52 +0900 Subject: Add Analysis#teype_of test --- crates/ra_analysis/tests/tests.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'crates/ra_analysis/tests') diff --git a/crates/ra_analysis/tests/tests.rs b/crates/ra_analysis/tests/tests.rs index 3045c2e78..ce6f6f3fa 100644 --- a/crates/ra_analysis/tests/tests.rs +++ b/crates/ra_analysis/tests/tests.rs @@ -2,7 +2,7 @@ use ra_syntax::TextRange; use test_utils::{assert_eq_dbg, assert_eq_text}; use ra_analysis::{ - mock_analysis::{analysis_and_position, single_file, single_file_with_position, MockAnalysis}, + mock_analysis::{analysis_and_position, analysis_and_range, single_file, single_file_with_position, MockAnalysis}, AnalysisChange, CrateGraph, FileId, FnSignatureInfo, }; @@ -10,6 +10,22 @@ fn get_signature(text: &str) -> (FnSignatureInfo, Option) { let (analysis, position) = single_file_with_position(text); analysis.resolve_callable(position).unwrap().unwrap() } +#[test] +fn test_type_of() { + let (analysis, range) = analysis_and_range( + " + //- /lib.rs + pub fn foo() -> u32 { + 1 + }; + + let <|>foo_test<|> = foo(); + ", + ); + + let type_name = analysis.type_of(range).unwrap().unwrap(); + assert_eq_dbg("u32", &type_name); +} #[test] fn approximate_resolve_works_in_items() { -- cgit v1.2.3