aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
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 1650606b7..25a354947 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};
@@ -241,3 +244,44 @@ fn ellipsize(mut text: String, max_len: usize) -> String {
241fn test_data_dir() -> PathBuf { 244fn test_data_dir() -> PathBuf {
242 project_dir().join("crates/ra_hir/src/ty/tests/data") 245 project_dir().join("crates/ra_hir/src/ty/tests/data")
243} 246}
247
248#[test]
249#[should_panic] // TODO this should work once hir::Expr is used
250fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
251 let (mut db, pos) = MockDatabase::with_position(
252 "
253 //- /lib.rs
254 fn foo() -> i32 {
255 <|>1 + 1
256 }
257 ",
258 );
259 let func = source_binder::function_from_position(&db, pos)
260 .unwrap()
261 .unwrap();
262 {
263 let events = db.log_executed(|| {
264 func.infer(&db).unwrap();
265 });
266 assert!(format!("{:?}", events).contains("infer"))
267 }
268
269 let new_text = "
270 fn foo() -> i32 {
271 1
272 +
273 1
274 }
275 "
276 .to_string();
277
278 db.query_mut(ra_db::FileTextQuery)
279 .set(pos.file_id, Arc::new(new_text));
280
281 {
282 let events = db.log_executed(|| {
283 func.infer(&db).unwrap();
284 });
285 assert!(!format!("{:?}", events).contains("infer"), "{:#?}", events)
286 }
287}