aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/tests.rs
diff options
context:
space:
mode:
authorLaurenČ›iu Nicola <[email protected]>2020-07-20 17:38:52 +0100
committerLaurenČ›iu Nicola <[email protected]>2020-07-20 17:38:52 +0100
commit3b6979be77dcce37edd5f29607c5fd41252e312d (patch)
treec0d45f11daec8264432eead1c0edc0f6439f97d1 /crates/ra_hir_ty/src/tests.rs
parentb82899ad764502eab0ee1410afb42888bbd5099e (diff)
Use expect in never_type tests
Diffstat (limited to 'crates/ra_hir_ty/src/tests.rs')
-rw-r--r--crates/ra_hir_ty/src/tests.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index c972bf845..5eaf25a77 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -10,6 +10,7 @@ mod display_source_code;
10 10
11use std::sync::Arc; 11use std::sync::Arc;
12 12
13use expect::Expect;
13use hir_def::{ 14use hir_def::{
14 body::{BodySourceMap, SyntheticSyntax}, 15 body::{BodySourceMap, SyntheticSyntax},
15 child_by_source::ChildBySource, 16 child_by_source::ChildBySource,
@@ -344,3 +345,29 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
344 assert!(!format!("{:?}", events).contains("infer"), "{:#?}", events) 345 assert!(!format!("{:?}", events).contains("infer"), "{:#?}", events)
345 } 346 }
346} 347}
348
349// Infer with some common definitions and impls.
350fn check_infer(ra_fixture: &str, expect: Expect) {
351 let defs = r#"
352 #[lang = "sized"]
353 pub trait Sized {}
354 #[lang = "unsize"]
355 pub trait Unsize<T: ?Sized> {}
356 #[lang = "coerce_unsized"]
357 pub trait CoerceUnsized<T> {}
358
359 impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {}
360 impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<*mut U> for *mut T {}
361 "#;
362
363 // Append to the end to keep positions unchanged.
364 let mut actual = infer(&format!("{}{}", ra_fixture, defs));
365 actual.push('\n');
366 expect.assert_eq(&actual);
367}
368
369fn check_infer_with_mismatches(ra_fixture: &str, expect: Expect) {
370 let mut actual = infer_with_mismatches(ra_fixture, true);
371 actual.push('\n');
372 expect.assert_eq(&actual);
373}