aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 13:45:22 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-06 13:45:22 +0000
commiteaf553dade9a28b41631387d7c88b09fd0ba64e2 (patch)
treef5043da62c6cf4e2f082f68746843de7dfe53d03 /crates/ra_hir/src/ty
parentcbac31cbdb2168b18fc6fb89f5cf069238cc6ccb (diff)
parent98957f4e6f66469310072dff5dfc3e521a7cd555 (diff)
Merge #441
441: hir::Expr r=matklad a=flodiebold Still a bit to do, but I already adapted `FnScopes` and thought I'd get feedback already. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/tests.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index fb53fcf0b..515c66e85 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -1,7 +1,10 @@
1use std::sync::Arc;
1use std::fmt::Write; 2use std::fmt::Write;
2use std::path::{PathBuf, Path}; 3use std::path::{PathBuf, Path};
3use std::fs; 4use std::fs;
4 5
6use salsa::Database;
7
5use ra_db::{SyntaxDatabase}; 8use ra_db::{SyntaxDatabase};
6use ra_syntax::ast::{self, AstNode}; 9use ra_syntax::ast::{self, AstNode};
7use test_utils::{project_dir, assert_eq_text, read_text}; 10use test_utils::{project_dir, assert_eq_text, read_text};
@@ -217,3 +220,44 @@ fn ellipsize(mut text: String, max_len: usize) -> String {
217fn test_data_dir() -> PathBuf { 220fn test_data_dir() -> PathBuf {
218 project_dir().join("crates/ra_hir/src/ty/tests/data") 221 project_dir().join("crates/ra_hir/src/ty/tests/data")
219} 222}
223
224#[test]
225#[should_panic] // TODO this should work once hir::Expr is used
226fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
227 let (mut db, pos) = MockDatabase::with_position(
228 "
229 //- /lib.rs
230 fn foo() -> i32 {
231 <|>1 + 1
232 }
233 ",
234 );
235 let func = source_binder::function_from_position(&db, pos)
236 .unwrap()
237 .unwrap();
238 {
239 let events = db.log_executed(|| {
240 func.infer(&db).unwrap();
241 });
242 assert!(format!("{:?}", events).contains("infer"))
243 }
244
245 let new_text = "
246 fn foo() -> i32 {
247 1
248 +
249 1
250 }
251 "
252 .to_string();
253
254 db.query_mut(ra_db::FileTextQuery)
255 .set(pos.file_id, Arc::new(new_text));
256
257 {
258 let events = db.log_executed(|| {
259 func.infer(&db).unwrap();
260 });
261 assert!(!format!("{:?}", events).contains("infer"), "{:#?}", events)
262 }
263}