|
1 | 1 | //! Completion tests for visibility modifiers.
|
2 | 2 | use expect_test::expect;
|
3 | 3 |
|
4 |
| -use crate::tests::{check, check_with_trigger_character}; |
| 4 | +use crate::tests::{check, check_with_private_editable, check_with_trigger_character}; |
5 | 5 |
|
6 | 6 | #[test]
|
7 | 7 | fn empty_pub() {
|
@@ -78,3 +78,90 @@ mod bar {}
|
78 | 78 | "#]],
|
79 | 79 | );
|
80 | 80 | }
|
| 81 | + |
| 82 | +#[test] |
| 83 | +fn use_inner_public_function() { |
| 84 | + check( |
| 85 | + r#" |
| 86 | +//- /inner.rs crate:inner |
| 87 | +pub fn inner_public() {} |
| 88 | +fn inner_private() {} |
| 89 | +//- /foo.rs crate:foo deps:inner |
| 90 | +use inner::inner_public; |
| 91 | +pub fn outer_public() {} |
| 92 | +//- /lib.rs crate:lib deps:foo |
| 93 | +fn x() { |
| 94 | + foo::$0 |
| 95 | +} |
| 96 | + "#, |
| 97 | + expect![[r#" |
| 98 | + fn outer_public() fn() |
| 99 | + "#]], |
| 100 | + ); |
| 101 | +} |
| 102 | + |
| 103 | +#[test] |
| 104 | +fn pub_use_inner_public_function() { |
| 105 | + check( |
| 106 | + r#" |
| 107 | +//- /inner.rs crate:inner |
| 108 | +pub fn inner_public() {} |
| 109 | +fn inner_private() {} |
| 110 | +//- /foo.rs crate:foo deps:inner |
| 111 | +pub use inner::inner_public; |
| 112 | +pub fn outer_public() {} |
| 113 | +//- /lib.rs crate:lib deps:foo |
| 114 | +fn x() { |
| 115 | + foo::$0 |
| 116 | +} |
| 117 | + "#, |
| 118 | + expect![[r#" |
| 119 | + fn inner_public() fn() |
| 120 | + fn outer_public() fn() |
| 121 | + "#]], |
| 122 | + ); |
| 123 | +} |
| 124 | + |
| 125 | +#[test] |
| 126 | +fn use_inner_public_function_private_editable() { |
| 127 | + check_with_private_editable( |
| 128 | + r#" |
| 129 | +//- /inner.rs crate:inner |
| 130 | +pub fn inner_public() {} |
| 131 | +fn inner_private() {} |
| 132 | +//- /foo.rs crate:foo deps:inner |
| 133 | +use inner::inner_public; |
| 134 | +pub fn outer_public() {} |
| 135 | +//- /lib.rs crate:lib deps:foo |
| 136 | +fn x() { |
| 137 | + foo::$0 |
| 138 | +} |
| 139 | + "#, |
| 140 | + expect![[r#" |
| 141 | + fn inner_public() fn() |
| 142 | + fn outer_public() fn() |
| 143 | + "#]], |
| 144 | + ); |
| 145 | +} |
| 146 | + |
| 147 | +#[test] |
| 148 | +fn pub_use_inner_public_function_private_editable() { |
| 149 | + check_with_private_editable( |
| 150 | + r#" |
| 151 | +//- /inner.rs crate:inner |
| 152 | +pub fn inner_public() {} |
| 153 | +fn inner_private() {} |
| 154 | +//- /foo.rs crate:foo deps:inner |
| 155 | +pub use inner::inner_public; |
| 156 | +pub fn outer_public() {} |
| 157 | +//- /lib.rs crate:lib deps:foo |
| 158 | +fn x() { |
| 159 | + foo::$0 |
| 160 | +} |
| 161 | + "#, |
| 162 | + expect![[r#" |
| 163 | + fn inner_public() fn() |
| 164 | + fn outer_public() fn() |
| 165 | + "#]], |
| 166 | + ); |
| 167 | +} |
0 commit comments