Skip to content

Commit

Permalink
Add more tests to imports_granularity_one
Browse files Browse the repository at this point in the history
  • Loading branch information
magurotuna committed Mar 20, 2021
1 parent efd030c commit 7e7ceb9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 24 deletions.
24 changes: 24 additions & 0 deletions src/formatting/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1164,6 +1164,16 @@ mod test {
fn test_use_tree_merge_one() {
test_merge!(One, ["a", "b"], ["{a, b}"]);

test_merge!(One, ["a::{aa, ab}", "b", "a"], ["{a::{self, aa, ab}, b}"]);

test_merge!(One, ["a as x", "b as y"], ["{a as x, b as y}"]);

test_merge!(
One,
["a::{aa as xa, ab}", "b", "a"],
["{a::{self, aa as xa, ab}, b}"]
);

test_merge!(
One,
["a", "a::{aa, ab::{aba, abb}}"],
Expand All @@ -1172,11 +1182,25 @@ mod test {

test_merge!(One, ["a", "b::{ba, *}"], ["{a, b::{ba, *}}"]);

test_merge!(One, ["a", "b", "a::aa"], ["{a::{self, aa}, b}"]);

test_merge!(
One,
["a::aa::aaa", "a::ac::aca", "a::aa::*"],
["a::{aa::{aaa, *}, ac::aca}"]
);

test_merge!(
One,
["a", "b::{ba, bb}", "a::{aa::*, ab::aba}"],
["{a::{self, aa::*, ab::aba}, b::{ba, bb}}"]
);

test_merge!(
One,
["b", "a::ac::{aca, acb}", "a::{aa::*, ab}"],
["{a::{aa::*, ab, ac::{aca, acb}}, b}"]
);
}

#[test]
Expand Down
36 changes: 21 additions & 15 deletions tests/source/imports_granularity_one.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
// rustfmt-imports_granularity: One

use a;

use a;
use b;
use a::ac::{aca, acb};
use a::{aa::*, ab};

use a;
use a::{ab, aa::aaa};
use a as x;
use b::ba;
use a::{aa, ab};

use a::aa;
use a::ab::{aba, abb};
use b::ba::{baa as foo, bab};
use a::aa::aaa;
use a::ab::aba as x;
use a::aa::*;

use a::aa;
use a::ad::ada;
#[cfg(test)]
use a::{ab, ac::aca};
#[cfg(test)]
use b::{ba, bb, bc::bca::{bcaa, bcab}};
use a::ad::ada;
use b;
#[cfg(test)]
use b::{
ba, bb,
bc::bca::{bcaa, bcab},
};

pub use a::aa;
use a::{ab, ac, ad};
pub use a::ae;
use a::{ab, ac, ad};
use b::ba;
pub use b::{bb, bc::bca};

use a::{aa::*, ab};
use b::{bb::{self, bba}, ba};
use a::ac::{acb, aca};
use a::aa::aaa;
use a::ac::{aca, acb};
use a::{aa::*, ab};
use b::{
ba,
bb::{self, bba},
};
23 changes: 14 additions & 9 deletions tests/target/imports_granularity_one.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
// rustfmt-imports_granularity: One

use a;

use {a, b};

use a::{self, aa::aaa, ab};

use {
a::{
aa,
ab::{aba, abb},
aa::*,
ab,
ac::{aca, acb},
},
b::ba::{baa as foo, bab},
b,
};

use {
a::{self as x, aa, ab},
b::ba,
};

use a::{
aa::{aaa, *},
ab::aba as x,
};

#[cfg(test)]
Expand Down

0 comments on commit 7e7ceb9

Please sign in to comment.