aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorSimon Vandel Sillesen <[email protected]>2019-01-06 11:24:33 +0000
committerSimon Vandel Sillesen <[email protected]>2019-01-06 11:24:33 +0000
commit4f3bc42349534518940f5a9a4db64287d897c03f (patch)
tree585c2f659a9ab273b4a05d06116e71da35b56325 /crates
parentb0ffa98a005a9d37a168b589506c430692a2432f (diff)
add more tests
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_editor/src/typing.rs55
1 files changed, 54 insertions, 1 deletions
diff --git a/crates/ra_editor/src/typing.rs b/crates/ra_editor/src/typing.rs
index ceef8b879..528c7b200 100644
--- a/crates/ra_editor/src/typing.rs
+++ b/crates/ra_editor/src/typing.rs
@@ -306,7 +306,7 @@ mod tests {
306 use super::*; 306 use super::*;
307 use crate::test_utils::{ 307 use crate::test_utils::{
308 add_cursor, assert_eq_text, check_action, extract_offset, extract_range, 308 add_cursor, assert_eq_text, check_action, extract_offset, extract_range,
309}; 309 };
310 310
311 fn check_join_lines(before: &str, after: &str) { 311 fn check_join_lines(before: &str, after: &str) {
312 check_action(before, after, |file, offset| { 312 check_action(before, after, |file, offset| {
@@ -646,6 +646,7 @@ fn foo() {
646 let actual = result.edit.apply(&before); 646 let actual = result.edit.apply(&before);
647 assert_eq_text!(after, &actual); 647 assert_eq_text!(after, &actual);
648 } 648 }
649 // indent if continuing chain call
649 do_check( 650 do_check(
650 r" 651 r"
651 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> { 652 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
@@ -660,6 +661,58 @@ fn foo() {
660 } 661 }
661", 662",
662 ); 663 );
664
665 // do not indent if already indented
666 do_check(
667 r"
668 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
669 self.child_impl(db, name)
670 .<|>
671 }
672",
673 r"
674 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
675 self.child_impl(db, name)
676 .
677 }
678",
679 );
680
681 // indent if the previous line is already indented
682 do_check(
683 r"
684 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
685 self.child_impl(db, name)
686 .first()
687 .<|>
688 }
689",
690 r"
691 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
692 self.child_impl(db, name)
693 .first()
694 .
695 }
696",
697 );
698
699 // don't indent if indent matches previous line
700 do_check(
701 r"
702 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
703 self.child_impl(db, name)
704 .first()
705 .<|>
706 }
707",
708 r"
709 pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
710 self.child_impl(db, name)
711 .first()
712 .
713 }
714",
715 );
663 } 716 }
664 717
665 #[test] 718 #[test]