diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-17 13:38:52 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-17 13:38:52 +0100 |
commit | 23df3834333a4db1449b2ba52e878ade47d1dfb2 (patch) | |
tree | 33f5b632ed98ffd6cbd7d670b4d9ee79893e31de /crates/ra_ide/src/lib.rs | |
parent | 2ca0e9e00e5a55bd591ae0a85fb00918b111e063 (diff) | |
parent | fcdac030335ba58e8267f3414101d4c2edb3797c (diff) |
Merge #5422
5422: Rewrite def map tests from insta to expect r=matklad a=matklad
Those indentation markers are annoying...
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r-- | crates/ra_ide/src/lib.rs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 353f430ff..dc9192d42 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -526,77 +526,3 @@ fn analysis_is_send() { | |||
526 | fn is_send<T: Send>() {} | 526 | fn is_send<T: Send>() {} |
527 | is_send::<Analysis>(); | 527 | is_send::<Analysis>(); |
528 | } | 528 | } |
529 | |||
530 | #[cfg(test)] | ||
531 | mod tests { | ||
532 | use crate::{display::NavigationTarget, mock_analysis::single_file, Query}; | ||
533 | use ra_syntax::{ | ||
534 | SmolStr, | ||
535 | SyntaxKind::{FN_DEF, STRUCT_DEF}, | ||
536 | }; | ||
537 | |||
538 | #[test] | ||
539 | fn test_world_symbols_with_no_container() { | ||
540 | let code = r#" | ||
541 | enum FooInner { } | ||
542 | "#; | ||
543 | |||
544 | let mut symbols = get_symbols_matching(code, "FooInner"); | ||
545 | |||
546 | let s = symbols.pop().unwrap(); | ||
547 | |||
548 | assert_eq!(s.name, "FooInner"); | ||
549 | assert!(s.container_name.is_none()); | ||
550 | } | ||
551 | |||
552 | #[test] | ||
553 | fn test_world_symbols_include_container_name() { | ||
554 | let code = r#" | ||
555 | fn foo() { | ||
556 | enum FooInner { } | ||
557 | } | ||
558 | "#; | ||
559 | |||
560 | let mut symbols = get_symbols_matching(code, "FooInner"); | ||
561 | |||
562 | let s = symbols.pop().unwrap(); | ||
563 | |||
564 | assert_eq!(s.name, "FooInner"); | ||
565 | assert_eq!(s.container_name, Some(SmolStr::new("foo"))); | ||
566 | |||
567 | let code = r#" | ||
568 | mod foo { | ||
569 | struct FooInner; | ||
570 | } | ||
571 | "#; | ||
572 | |||
573 | let mut symbols = get_symbols_matching(code, "FooInner"); | ||
574 | |||
575 | let s = symbols.pop().unwrap(); | ||
576 | |||
577 | assert_eq!(s.name, "FooInner"); | ||
578 | assert_eq!(s.container_name, Some(SmolStr::new("foo"))); | ||
579 | } | ||
580 | |||
581 | #[test] | ||
582 | fn test_world_symbols_are_case_sensitive() { | ||
583 | let code = r#" | ||
584 | fn foo() {} | ||
585 | |||
586 | struct Foo; | ||
587 | "#; | ||
588 | |||
589 | let symbols = get_symbols_matching(code, "Foo"); | ||
590 | |||
591 | let fn_match = symbols.iter().find(|s| s.name == "foo").map(|s| s.kind); | ||
592 | let struct_match = symbols.iter().find(|s| s.name == "Foo").map(|s| s.kind); | ||
593 | |||
594 | assert_eq!(fn_match, Some(FN_DEF)); | ||
595 | assert_eq!(struct_match, Some(STRUCT_DEF)); | ||
596 | } | ||
597 | |||
598 | fn get_symbols_matching(text: &str, query: &str) -> Vec<NavigationTarget> { | ||
599 | let (analysis, _) = single_file(text); | ||
600 | analysis.symbol_search(Query::new(query.into())).unwrap() | ||
601 | } | ||
602 | } | ||