Решение на Форматиране на импорти от Александър Иванов

Обратно към всички решения

Към профила на Александър Иванов

Резултати

  • 20 точки от тестове
  • 2 бонус точки
  • 22 точки общо
  • 20 успешни тест(а)
  • 0 неуспешни тест(а)

Код

use std::collections::HashSet;
pub struct Import<'a>(pub &'a [&'a str]);
#[derive(PartialEq, Eq)]
pub enum Order {
Original,
Sorted,
}
pub struct Tree {
value: String,
contains_self: bool,
children: Vec<Tree>,
}
impl Tree {
fn new(value: String, contains_self: bool) -> Tree {
Tree {
value,
contains_self,
children: Vec::<Tree>::new(),
}
}
fn dfs_parent<'a>(
&'a mut self,
path: &Vec<String>,
level: usize,
) -> Option<(&'a mut Self, usize)> {
if level >= path.len() {
self.contains_self = true;
return None;
}
match self.children.iter().any(|c| c.value == path[level]) {
true => {
let mut result = None;
for child in self.children.iter_mut() {
if child.value == path[level] {
result = child.dfs_parent(path, level + 1);
break;
}
}
result
}
false => Some((self, level)),
}
}
fn insert(&mut self, path: &mut dyn Iterator<Item = &String>, length: usize) {
if let Some(str) = path.next() {
let mut new_node = Tree::new(str.clone(), length == 1);
new_node.insert(path, length - 1);
self.children.push(new_node);
}
}
fn add_child(&mut self, child_val: &Vec<String>) {
if let Some((parent, level)) = self.dfs_parent(child_val, 0) {
parent.insert(
&mut child_val.iter().skip(level),
child_val.iter().skip(level).len(),
);
}
}
fn add_selfs(&mut self) {
if self.contains_self && !self.children.is_empty() {
self.children
.insert(0, Tree::new(String::from("self"), false));
}
for child in self.children.iter_mut() {
child.add_selfs();
}
}
fn print_imports_helper(&self, result: &mut Vec<String>, level: usize) {
if self.children.is_empty() {
result.push(" ".repeat(level) + self.value.as_str() + ",\n");
} else {
result.push(" ".repeat(level) + self.value.as_str() + "::{\n");
self.children
.iter()
.for_each(|child| child.print_imports_helper(result, level + 1));
result.push(" ".repeat(level) + "},\n");
}
}
// ! ЗАПОМНИ, ЧЕ ИЗПУСКА РОДИТЕЛЯ
fn print_imports(&self, result: &mut Vec<String>) {
for import in self.children.iter() {
let mut buffer = Vec::<String>::new();
import.print_imports_helper(&mut buffer, 0);
if let Some(last) = buffer.last_mut() {
*last = last.replace(",", "");
};
result.push(buffer.concat());
}
}
}
pub fn format_flat(imports: &[Import], order: Order) -> Vec<String> {
// * искам да направя махането на дубликати с линейна по време сложност, затова ползвам хеш таблица
let mut found = HashSet::<String>::new();
let mut result = imports
.iter()
.map(|import| import.0.join("::"))
.filter(|current| found.insert(current.clone()))
.collect::<Vec<String>>();
if order == Order::Sorted {
result.sort();
}
result
}
pub fn format_nested(imports: &[Import], order: Order) -> Vec<String> {
let mut imports: Vec<Vec<String>> = imports
.iter()
.map(|it| {
it.0.iter()
.map(|strr| String::from(*strr))
.collect::<Vec<String>>()
})
.collect::<Vec<Vec<String>>>();
if order == Order::Sorted {
imports.sort();
}
let mut tree = Tree::new(String::from("imports"), false);
imports.iter().for_each(|import| {
tree.add_child(import);
});
tree.add_selfs();
let mut result = Vec::<String>::new();
tree.print_imports(&mut result);
result
}
//////////////////////// ! /////////////////////////
//////////////////////// ! /////////////////////////
//////////////////// ! TESTS ! ////////////////////
//////////////////////// ! /////////////////////////
//////////////////////// ! /////////////////////////
// use solution::*;
// #[test]
// fn test_basic() {
// let imports = &[
// Import(&["my_crate", "a"]),
// Import(&["my_crate", "b", "B1"]),
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "c"]),
// ];
// assert_eq!(
// format_flat(imports, Order::Sorted),
// &[
// "my_crate::a",
// "my_crate::b::B1",
// "my_crate::b::B2",
// "my_crate::c",
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[concat!(
// "my_crate::{\n",
// " a,\n",
// " b::{\n",
// " B1,\n",
// " B2,\n",
// " },\n",
// " c,\n",
// "}\n",
// )]
// );
// }
// ////////////////// ! FORMAT_FLAT ! //////////////////
// #[test]
// fn format_flat_empty() {
// let imports: &[Import] = &[];
// assert_eq!(format_flat(imports, Order::Original), vec!() as Vec<String>);
// assert_eq!(format_flat(imports, Order::Sorted), vec!() as Vec<String>);
// }
// #[test]
// fn format_flat_remove_dublicates() {
// let imports = &[
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "a"]),
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "a"]),
// ];
// assert_eq!(
// format_flat(imports, Order::Original),
// &["my_crate::b::B2", "my_crate::c", "my_crate::a",]
// );
// assert_eq!(
// format_flat(imports, Order::Sorted),
// &["my_crate::a", "my_crate::b::B2", "my_crate::c",]
// );
// }
// #[test]
// fn format_flat_single_element() {
// let imports = &[Import(&["my_crate", "a"])];
// assert_eq!(format_flat(imports, Order::Original), &["my_crate::a",]);
// assert_eq!(format_flat(imports, Order::Sorted), &["my_crate::a",]);
// }
// #[test]
// fn format_flat_happy_path() {
// let imports = &[
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "b", "B1"]),
// Import(&["my_crate", "a"]),
// ];
// assert_eq!(
// format_flat(imports, Order::Original),
// &[
// "my_crate::c",
// "my_crate::b::B2",
// "my_crate::b::B1",
// "my_crate::a",
// ]
// );
// assert_eq!(
// format_flat(imports, Order::Sorted),
// &[
// "my_crate::a",
// "my_crate::b::B1",
// "my_crate::b::B2",
// "my_crate::c",
// ]
// );
// }
// ////////////////// ! FORMAT_NESTED ! //////////////////
// // no imports
// #[test]
// fn format_nested_empty() {
// let imports = &[];
// assert_eq!(
// format_nested(imports, Order::Original),
// vec!() as Vec<String>
// );
// assert_eq!(format_nested(imports, Order::Sorted), vec!() as Vec<String>);
// }
// // remove dublicates
// #[test]
// fn format_nested_remove_dublicates() {
// let imports = &[
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "a"]),
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "b", "B1"]),
// Import(&["my_crate", "a"]),
// Import(&["foo", "c"]),
// Import(&["foo", "b", "B2"]),
// Import(&["foo", "c"]),
// Import(&["foo", "a"]),
// Import(&["foo", "b", "B1"]),
// Import(&["foo", "a"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[
// concat!(
// "my_crate::{\n",
// " b::{\n",
// " B2,\n",
// " B1,\n",
// " },\n",
// " c,\n",
// " a,\n",
// "}\n",
// ),
// concat!(
// "foo::{\n",
// " c,\n",
// " b::{\n",
// " B2,\n",
// " B1,\n",
// " },\n",
// " a,\n",
// "}\n",
// ),
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[
// concat!(
// "foo::{\n",
// " a,\n",
// " b::{\n",
// " B1,\n",
// " B2,\n",
// " },\n",
// " c,\n",
// "}\n",
// ),
// concat!(
// "my_crate::{\n",
// " a,\n",
// " b::{\n",
// " B1,\n",
// " B2,\n",
// " },\n",
// " c,\n",
// "}\n",
// ),
// ]
// );
// }
// // one import self + other imports
// #[test]
// fn format_nested_self_plus_other_submodules() {
// let imports = &[
// Import(&["my_crate", "b"]),
// Import(&["my_crate", "a", "A1"]),
// Import(&["my_crate", "a"]),
// Import(&["foo", "b", "B1"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[
// concat!(
// "my_crate::{\n",
// " b,\n",
// " a::{\n",
// " self,\n",
// " A1,\n",
// " },\n",
// "}\n",
// ),
// concat!("foo::{\n", " b::{\n", " B1,\n", " },\n", "}\n",),
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[
// concat!("foo::{\n", " b::{\n", " B1,\n", " },\n", "}\n",),
// concat!(
// "my_crate::{\n",
// " a::{\n",
// " self,\n",
// " A1,\n",
// " },\n",
// " b,\n",
// "}\n",
// ),
// ]
// );
// }
// // multiple import self + other imports
// #[test]
// fn format_nested_multiple_self_plus_other_submodules() {
// let imports = &[
// Import(&["my_crate", "b"]),
// Import(&["my_crate", "a", "A1"]),
// Import(&["my_crate", "a"]),
// Import(&["foo", "b", "B1"]),
// Import(&["foo", "b"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[
// concat!(
// "my_crate::{\n",
// " b,\n",
// " a::{\n",
// " self,\n",
// " A1,\n",
// " },\n",
// "}\n",
// ),
// concat!(
// "foo::{\n",
// " b::{\n",
// " self,\n",
// " B1,\n",
// " },\n",
// "}\n",
// ),
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[
// concat!(
// "foo::{\n",
// " b::{\n",
// " self,\n",
// " B1,\n",
// " },\n",
// "}\n",
// ),
// concat!(
// "my_crate::{\n",
// " a::{\n",
// " self,\n",
// " A1,\n",
// " },\n",
// " b,\n",
// "}\n",
// ),
// ]
// );
// }
// // self for crates
// #[test]
// fn format_nested_self_for_crates() {
// let imports = &[
// Import(&["my_crate", "a"]),
// Import(&["my_crate"]),
// Import(&["foo", "b", "B1"]),
// Import(&["foo", "b"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[
// concat!("my_crate::{\n", " self,\n", " a,\n", "}\n",),
// concat!(
// "foo::{\n",
// " b::{\n",
// " self,\n",
// " B1,\n",
// " },\n",
// "}\n",
// ),
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[
// concat!(
// "foo::{\n",
// " b::{\n",
// " self,\n",
// " B1,\n",
// " },\n",
// "}\n",
// ),
// concat!("my_crate::{\n", " self,\n", " a,\n", "}\n",),
// ]
// );
// }
// // one crate with no children
// #[test]
// fn format_nested_one_crate_no_children() {
// let imports = &[Import(&["my_crate"])];
// assert_eq!(format_nested(imports, Order::Original), &["my_crate\n"]);
// assert_eq!(format_nested(imports, Order::Sorted), &["my_crate\n"]);
// }
// // multiple crate with no children
// #[test]
// fn format_nested_multiple_crates_no_children() {
// let imports = &[
// Import(&["my_crate"]),
// Import(&["foo"]),
// Import(&["foo"]),
// Import(&["my_crate"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &["my_crate\n", "foo\n"]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &["foo\n", "my_crate\n"]
// );
// }
// // one crate with one children
// #[test]
// fn format_nested_one_crate_one_children() {
// let imports = &[Import(&["my_crate", "a"])];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[concat!("my_crate::{\n", " a,\n", "}\n",),]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[concat!("my_crate::{\n", " a,\n", "}\n",),]
// );
// }
// // multiple crate with one children
// #[test]
// fn format_nested_multiple_crates_one_children() {
// let imports = &[Import(&["my_crate", "a"]), Import(&["foo", "b"])];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[
// concat!("my_crate::{\n", " a,\n", "}\n",),
// concat!("foo::{\n", " b,\n", "}\n",),
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[
// concat!("foo::{\n", " b,\n", "}\n",),
// concat!("my_crate::{\n", " a,\n", "}\n",),
// ]
// );
// }
// // one crate with multiple children
// #[test]
// fn format_nested_one_crate_multiple_children() {
// let imports = &[
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "a"]),
// Import(&["my_crate"]),
// Import(&["my_crate", "b", "B1"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[concat!(
// "my_crate::{\n",
// " self,\n",
// " b::{\n",
// " B2,\n",
// " B1,\n",
// " },\n",
// " c,\n",
// " a,\n",
// "}\n",
// ),]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[concat!(
// "my_crate::{\n",
// " self,\n",
// " a,\n",
// " b::{\n",
// " B1,\n",
// " B2,\n",
// " },\n",
// " c,\n",
// "}\n",
// ),]
// );
// }
// // multiple crate with multiple children
// #[test]
// fn format_nested_multiple_crates_multiple_children() {
// let imports = &[
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "a"]),
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "b", "B1"]),
// Import(&["foo", "c"]),
// Import(&["foo", "b", "B2"]),
// Import(&["foo", "a"]),
// Import(&["foo", "b", "B1"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[
// concat!(
// "my_crate::{\n",
// " b::{\n",
// " B2,\n",
// " B1,\n",
// " },\n",
// " c,\n",
// " a,\n",
// "}\n",
// ),
// concat!(
// "foo::{\n",
// " c,\n",
// " b::{\n",
// " B2,\n",
// " B1,\n",
// " },\n",
// " a,\n",
// "}\n",
// ),
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[
// concat!(
// "foo::{\n",
// " a,\n",
// " b::{\n",
// " B1,\n",
// " B2,\n",
// " },\n",
// " c,\n",
// "}\n",
// ),
// concat!(
// "my_crate::{\n",
// " a,\n",
// " b::{\n",
// " B1,\n",
// " B2,\n",
// " },\n",
// " c,\n",
// "}\n",
// ),
// ]
// );
// }
// // depth 3
// #[test]
// fn format_nested_depth_3() {
// let imports = &[
// Import(&["my_crate", "b", "B2", "BB1"]),
// Import(&["my_crate", "c"]),
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate"]),
// Import(&["my_crate", "a"]),
// Import(&["my_crate", "b", "B2"]),
// Import(&["my_crate", "b"]),
// Import(&["my_crate", "b", "B1"]),
// Import(&["foo", "c"]),
// Import(&["foo"]),
// Import(&["foo", "b", "B2"]),
// Import(&["foo", "a"]),
// Import(&["foo", "b", "B1"]),
// ];
// assert_eq!(
// format_nested(imports, Order::Original),
// &[
// concat!(
// "my_crate::{\n",
// " self,\n",
// " b::{\n",
// " self,\n",
// " B2::{\n",
// " self,\n",
// " BB1,\n",
// " },\n",
// " B1,\n",
// " },\n",
// " c,\n",
// " a,\n",
// "}\n",
// ),
// concat!(
// "foo::{\n",
// " self,\n",
// " c,\n",
// " b::{\n",
// " B2,\n",
// " B1,\n",
// " },\n",
// " a,\n",
// "}\n",
// ),
// ]
// );
// assert_eq!(
// format_nested(imports, Order::Sorted),
// &[
// concat!(
// "foo::{\n",
// " self,\n",
// " a,\n",
// " b::{\n",
// " B1,\n",
// " B2,\n",
// " },\n",
// " c,\n",
// "}\n",
// ),
// concat!(
// "my_crate::{\n",
// " self,\n",
// " a,\n",
// " b::{\n",
// " self,\n",
// " B1,\n",
// " B2::{\n",
// " self,\n",
// " BB1,\n",
// " },\n",
// " },\n",
// " c,\n",
// "}\n",
// ),
// ]
// );
// }

Лог от изпълнението

Compiling solution v0.1.0 (/tmp/d20241203-1739405-1et83n1/solution)
    Finished test [unoptimized + debuginfo] target(s) in 1.38s
     Running tests/solution_test.rs (target/debug/deps/solution_test-1428e1090729d165)

running 20 tests
test solution_test::test_flat_empty ... ok
test solution_test::test_flat_multi_crate ... ok
test solution_test::test_flat_original ... ok
test solution_test::test_flat_original_duplicates ... ok
test solution_test::test_flat_sorted ... ok
test solution_test::test_flat_sorted_duplicates ... ok
test solution_test::test_nested_basic ... ok
test solution_test::test_nested_deep ... ok
test solution_test::test_nested_empty ... ok
test solution_test::test_nested_only_crate ... ok
test solution_test::test_nested_original ... ok
test solution_test::test_nested_original_2 ... ok
test solution_test::test_nested_original_duplicates ... ok
test solution_test::test_nested_original_multi_crate ... ok
test solution_test::test_nested_original_self ... ok
test solution_test::test_nested_sorted ... ok
test solution_test::test_nested_sorted_2 ... ok
test solution_test::test_nested_sorted_duplicates ... ok
test solution_test::test_nested_sorted_multi_crate ... ok
test solution_test::test_nested_sorted_self ... ok

test result: ok. 20 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

История (2 версии и 0 коментара)

Александър качи първо решение на 30.11.2024 16:42 (преди 10 месеца)

Александър качи решение на 02.12.2024 22:59 (преди 9 месеца)

use std::collections::HashSet;
pub struct Import<'a>(pub &'a [&'a str]);
#[derive(PartialEq, Eq)]
pub enum Order {
Original,
Sorted,
}
pub struct Tree {
value: String,
+ contains_self: bool,
children: Vec<Tree>,
}
impl Tree {
- fn new(value: String) -> Tree {
+ fn new(value: String, contains_self: bool) -> Tree {
Tree {
value,
+ contains_self,
children: Vec::<Tree>::new(),
}
}
fn dfs_parent<'a>(
&'a mut self,
path: &Vec<String>,
level: usize,
) -> Option<(&'a mut Self, usize)> {
if level >= path.len() {
+ self.contains_self = true;
return None;
}
match self.children.iter().any(|c| c.value == path[level]) {
true => {
let mut result = None;
for child in self.children.iter_mut() {
if child.value == path[level] {
result = child.dfs_parent(path, level + 1);
break;
}
}
result
}
false => Some((self, level)),
}
}
- fn insert(&mut self, path: &mut dyn Iterator<Item = &String>) {
+ fn insert(&mut self, path: &mut dyn Iterator<Item = &String>, length: usize) {
if let Some(str) = path.next() {
- let mut new_node = Tree::new(str.clone());
- new_node.insert(path);
+ let mut new_node = Tree::new(str.clone(), length == 1);
+ new_node.insert(path, length - 1);
self.children.push(new_node);
}
}
fn add_child(&mut self, child_val: &Vec<String>) {
if let Some((parent, level)) = self.dfs_parent(child_val, 0) {
- parent.insert(&mut child_val.iter().skip(level));
+ parent.insert(
+ &mut child_val.iter().skip(level),
+ child_val.iter().skip(level).len(),
+ );
}
}
+ fn add_selfs(&mut self) {
+ if self.contains_self && !self.children.is_empty() {
+ self.children
+ .insert(0, Tree::new(String::from("self"), false));
+ }
+
+ for child in self.children.iter_mut() {
+ child.add_selfs();
+ }
+ }
+
fn print_imports_helper(&self, result: &mut Vec<String>, level: usize) {
if self.children.is_empty() {
result.push(" ".repeat(level) + self.value.as_str() + ",\n");
} else {
result.push(" ".repeat(level) + self.value.as_str() + "::{\n");
self.children
.iter()
.for_each(|child| child.print_imports_helper(result, level + 1));
result.push(" ".repeat(level) + "},\n");
}
}
// ! ЗАПОМНИ, ЧЕ ИЗПУСКА РОДИТЕЛЯ
fn print_imports(&self, result: &mut Vec<String>) {
for import in self.children.iter() {
let mut buffer = Vec::<String>::new();
import.print_imports_helper(&mut buffer, 0);
if let Some(last) = buffer.last_mut() {
*last = last.replace(",", "");
};
result.push(buffer.concat());
}
}
}
pub fn format_flat(imports: &[Import], order: Order) -> Vec<String> {
// * искам да направя махането на дубликати с линейна по време сложност, затова ползвам хеш таблица
let mut found = HashSet::<String>::new();
let mut result = imports
.iter()
.map(|import| import.0.join("::"))
.filter(|current| found.insert(current.clone()))
.collect::<Vec<String>>();
if order == Order::Sorted {
result.sort();
}
result
}
pub fn format_nested(imports: &[Import], order: Order) -> Vec<String> {
let mut imports: Vec<Vec<String>> = imports
.iter()
.map(|it| {
it.0.iter()
.map(|strr| String::from(*strr))
.collect::<Vec<String>>()
})
.collect::<Vec<Vec<String>>>();
if order == Order::Sorted {
imports.sort();
}
- // добави self за всеки импорт, който се съдържа в друг импорт
- let temp = imports.clone();
- for current_import in imports.iter_mut() {
- if temp.iter().any(|import| {
- import.len() > current_import.len() && import[..current_import.len()] == *current_import
- }) {
- current_import.push(String::from("self"));
- }
- }
+ let mut tree = Tree::new(String::from("imports"), false);
- let mut tree = Tree::new(String::from("imports"));
-
imports.iter().for_each(|import| {
tree.add_child(import);
});
+ tree.add_selfs();
+
let mut result = Vec::<String>::new();
tree.print_imports(&mut result);
result
}
+//////////////////////// ! /////////////////////////
+//////////////////////// ! /////////////////////////
//////////////////// ! TESTS ! ////////////////////
+//////////////////////// ! /////////////////////////
+//////////////////////// ! /////////////////////////
-#[test]
-fn test_basic() {
- let imports = &[
- Import(&["my_crate", "a"]),
- Import(&["my_crate", "b", "B1"]),
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "c"]),
- ];
+// use solution::*;
- assert_eq!(
- format_flat(imports, Order::Sorted),
- &[
- "my_crate::a",
- "my_crate::b::B1",
- "my_crate::b::B2",
- "my_crate::c",
- ]
- );
+// #[test]
+// fn test_basic() {
+// let imports = &[
+// Import(&["my_crate", "a"]),
+// Import(&["my_crate", "b", "B1"]),
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "c"]),
+// ];
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[concat!(
- "my_crate::{\n",
- " a,\n",
- " b::{\n",
- " B1,\n",
- " B2,\n",
- " },\n",
- " c,\n",
- "}\n",
- )]
- );
-}
+// assert_eq!(
+// format_flat(imports, Order::Sorted),
+// &[
+// "my_crate::a",
+// "my_crate::b::B1",
+// "my_crate::b::B2",
+// "my_crate::c",
+// ]
+// );
-////////////////// ! FORMAT_FLAT ! //////////////////
-#[test]
-fn format_flat_empty() {
- let imports: &[Import] = &[];
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[concat!(
+// "my_crate::{\n",
+// " a,\n",
+// " b::{\n",
+// " B1,\n",
+// " B2,\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// )]
+// );
+// }
- assert_eq!(format_flat(imports, Order::Original), vec!() as Vec<String>);
+// ////////////////// ! FORMAT_FLAT ! //////////////////
+// #[test]
+// fn format_flat_empty() {
+// let imports: &[Import] = &[];
- assert_eq!(format_flat(imports, Order::Sorted), vec!() as Vec<String>);
-}
+// assert_eq!(format_flat(imports, Order::Original), vec!() as Vec<String>);
-#[test]
-fn format_flat_remove_dublicates() {
- let imports = &[
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "a"]),
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "a"]),
- ];
+// assert_eq!(format_flat(imports, Order::Sorted), vec!() as Vec<String>);
+// }
- assert_eq!(
- format_flat(imports, Order::Original),
- &["my_crate::b::B2", "my_crate::c", "my_crate::a",]
- );
+// #[test]
+// fn format_flat_remove_dublicates() {
+// let imports = &[
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "a"]),
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "a"]),
+// ];
- assert_eq!(
- format_flat(imports, Order::Sorted),
- &["my_crate::a", "my_crate::b::B2", "my_crate::c",]
- );
-}
+// assert_eq!(
+// format_flat(imports, Order::Original),
+// &["my_crate::b::B2", "my_crate::c", "my_crate::a",]
+// );
-#[test]
-fn format_flat_single_element() {
- let imports = &[Import(&["my_crate", "a"])];
+// assert_eq!(
+// format_flat(imports, Order::Sorted),
+// &["my_crate::a", "my_crate::b::B2", "my_crate::c",]
+// );
+// }
- assert_eq!(format_flat(imports, Order::Original), &["my_crate::a",]);
+// #[test]
+// fn format_flat_single_element() {
+// let imports = &[Import(&["my_crate", "a"])];
- assert_eq!(format_flat(imports, Order::Sorted), &["my_crate::a",]);
-}
+// assert_eq!(format_flat(imports, Order::Original), &["my_crate::a",]);
-#[test]
-fn format_flat_happy_path() {
- let imports = &[
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "b", "B1"]),
- Import(&["my_crate", "a"]),
- ];
+// assert_eq!(format_flat(imports, Order::Sorted), &["my_crate::a",]);
+// }
- assert_eq!(
- format_flat(imports, Order::Original),
- &[
- "my_crate::c",
- "my_crate::b::B2",
- "my_crate::b::B1",
- "my_crate::a",
- ]
- );
+// #[test]
+// fn format_flat_happy_path() {
+// let imports = &[
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "b", "B1"]),
+// Import(&["my_crate", "a"]),
+// ];
- assert_eq!(
- format_flat(imports, Order::Sorted),
- &[
- "my_crate::a",
- "my_crate::b::B1",
- "my_crate::b::B2",
- "my_crate::c",
- ]
- );
-}
+// assert_eq!(
+// format_flat(imports, Order::Original),
+// &[
+// "my_crate::c",
+// "my_crate::b::B2",
+// "my_crate::b::B1",
+// "my_crate::a",
+// ]
+// );
-////////////////// ! FORMAT_NESTED ! //////////////////
+// assert_eq!(
+// format_flat(imports, Order::Sorted),
+// &[
+// "my_crate::a",
+// "my_crate::b::B1",
+// "my_crate::b::B2",
+// "my_crate::c",
+// ]
+// );
+// }
-// no imports
-#[test]
-fn format_nested_empty() {
- let imports = &[];
- assert_eq!(
- format_nested(imports, Order::Original),
- vec!() as Vec<String>
- );
- assert_eq!(format_nested(imports, Order::Sorted), vec!() as Vec<String>);
-}
+// ////////////////// ! FORMAT_NESTED ! //////////////////
-// remove dublicates
-#[test]
-fn format_nested_remove_dublicates() {
- let imports = &[
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "a"]),
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "b", "B1"]),
- Import(&["my_crate", "a"]),
- Import(&["foo", "c"]),
- Import(&["foo", "b", "B2"]),
- Import(&["foo", "c"]),
- Import(&["foo", "a"]),
- Import(&["foo", "b", "B1"]),
- Import(&["foo", "a"]),
- ];
+// // no imports
+// #[test]
+// fn format_nested_empty() {
+// let imports = &[];
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// vec!() as Vec<String>
+// );
+// assert_eq!(format_nested(imports, Order::Sorted), vec!() as Vec<String>);
+// }
- assert_eq!(
- format_nested(imports, Order::Original),
- &[
- concat!(
- "my_crate::{\n",
- " b::{\n",
- " B2,\n",
- " B1,\n",
- " },\n",
- " c,\n",
- " a,\n",
- "}\n",
- ),
- concat!(
- "foo::{\n",
- " c,\n",
- " b::{\n",
- " B2,\n",
- " B1,\n",
- " },\n",
- " a,\n",
- "}\n",
- ),
- ]
- );
+// // remove dublicates
+// #[test]
+// fn format_nested_remove_dublicates() {
+// let imports = &[
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "a"]),
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "b", "B1"]),
+// Import(&["my_crate", "a"]),
+// Import(&["foo", "c"]),
+// Import(&["foo", "b", "B2"]),
+// Import(&["foo", "c"]),
+// Import(&["foo", "a"]),
+// Import(&["foo", "b", "B1"]),
+// Import(&["foo", "a"]),
+// ];
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[
- concat!(
- "foo::{\n",
- " a,\n",
- " b::{\n",
- " B1,\n",
- " B2,\n",
- " },\n",
- " c,\n",
- "}\n",
- ),
- concat!(
- "my_crate::{\n",
- " a,\n",
- " b::{\n",
- " B1,\n",
- " B2,\n",
- " },\n",
- " c,\n",
- "}\n",
- ),
- ]
- );
-}
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[
+// concat!(
+// "my_crate::{\n",
+// " b::{\n",
+// " B2,\n",
+// " B1,\n",
+// " },\n",
+// " c,\n",
+// " a,\n",
+// "}\n",
+// ),
+// concat!(
+// "foo::{\n",
+// " c,\n",
+// " b::{\n",
+// " B2,\n",
+// " B1,\n",
+// " },\n",
+// " a,\n",
+// "}\n",
+// ),
+// ]
+// );
-// one import self + other imports
-#[test]
-fn format_nested_self_plus_other_submodules() {
- let imports = &[
- Import(&["my_crate", "b"]),
- Import(&["my_crate", "a", "A1"]),
- Import(&["my_crate", "a"]),
- Import(&["foo", "b"]),
- Import(&["foo", "b", "B1"]),
- ];
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[
+// concat!(
+// "foo::{\n",
+// " a,\n",
+// " b::{\n",
+// " B1,\n",
+// " B2,\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// ),
+// concat!(
+// "my_crate::{\n",
+// " a,\n",
+// " b::{\n",
+// " B1,\n",
+// " B2,\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// ),
+// ]
+// );
+// }
- assert_eq!(
- format_nested(imports, Order::Original),
- &[
- concat!(
- "my_crate::{\n",
- " b,\n",
- " a::{\n",
- " A1,\n",
- " self,\n",
- " },\n",
- "}\n",
- ),
- concat!(
- "foo::{\n",
- " b::{\n",
- " self,\n",
- " B1,\n",
- " },\n",
- "}\n",
- ),
- ]
- );
+// // one import self + other imports
+// #[test]
+// fn format_nested_self_plus_other_submodules() {
+// let imports = &[
+// Import(&["my_crate", "b"]),
+// Import(&["my_crate", "a", "A1"]),
+// Import(&["my_crate", "a"]),
+// Import(&["foo", "b", "B1"]),
+// ];
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[
- concat!(
- "foo::{\n",
- " b::{\n",
- " self,\n",
- " B1,\n",
- " },\n",
- "}\n",
- ),
- concat!(
- "my_crate::{\n",
- " a::{\n",
- " self,\n",
- " A1,\n",
- " },\n",
- " b,\n",
- "}\n",
- ),
- ]
- );
-}
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[
+// concat!(
+// "my_crate::{\n",
+// " b,\n",
+// " a::{\n",
+// " self,\n",
+// " A1,\n",
+// " },\n",
+// "}\n",
+// ),
+// concat!("foo::{\n", " b::{\n", " B1,\n", " },\n", "}\n",),
+// ]
+// );
-// self for crates
-#[test]
-fn format_nested_self_for_crates() {
- let imports = &[
- Import(&["my_crate", "a"]),
- Import(&["my_crate"]),
- Import(&["foo", "b"]),
- Import(&["foo", "b", "B1"]),
- ];
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[
+// concat!("foo::{\n", " b::{\n", " B1,\n", " },\n", "}\n",),
+// concat!(
+// "my_crate::{\n",
+// " a::{\n",
+// " self,\n",
+// " A1,\n",
+// " },\n",
+// " b,\n",
+// "}\n",
+// ),
+// ]
+// );
+// }
- assert_eq!(
- format_nested(imports, Order::Original),
- &[
- concat!("my_crate::{\n", " a,\n", " self,\n", "}\n",),
- concat!(
- "foo::{\n",
- " b::{\n",
- " self,\n",
- " B1,\n",
- " },\n",
- "}\n",
- ),
- ]
- );
+// // multiple import self + other imports
+// #[test]
+// fn format_nested_multiple_self_plus_other_submodules() {
+// let imports = &[
+// Import(&["my_crate", "b"]),
+// Import(&["my_crate", "a", "A1"]),
+// Import(&["my_crate", "a"]),
+// Import(&["foo", "b", "B1"]),
+// Import(&["foo", "b"]),
+// ];
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[
- concat!(
- "foo::{\n",
- " b::{\n",
- " self,\n",
- " B1,\n",
- " },\n",
- "}\n",
- ),
- concat!("my_crate::{\n", " self,\n", " a,\n", "}\n",),
- ]
- );
-}
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[
+// concat!(
+// "my_crate::{\n",
+// " b,\n",
+// " a::{\n",
+// " self,\n",
+// " A1,\n",
+// " },\n",
+// "}\n",
+// ),
+// concat!(
+// "foo::{\n",
+// " b::{\n",
+// " self,\n",
+// " B1,\n",
+// " },\n",
+// "}\n",
+// ),
+// ]
+// );
-// one crate with no children
-#[test]
-fn format_nested_one_crate_no_children() {
- let imports = &[Import(&["my_crate"])];
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[
+// concat!(
+// "foo::{\n",
+// " b::{\n",
+// " self,\n",
+// " B1,\n",
+// " },\n",
+// "}\n",
+// ),
+// concat!(
+// "my_crate::{\n",
+// " a::{\n",
+// " self,\n",
+// " A1,\n",
+// " },\n",
+// " b,\n",
+// "}\n",
+// ),
+// ]
+// );
+// }
- assert_eq!(format_nested(imports, Order::Original), &["my_crate\n"]);
- assert_eq!(format_nested(imports, Order::Sorted), &["my_crate\n"]);
-}
+// // self for crates
+// #[test]
+// fn format_nested_self_for_crates() {
+// let imports = &[
+// Import(&["my_crate", "a"]),
+// Import(&["my_crate"]),
+// Import(&["foo", "b", "B1"]),
+// Import(&["foo", "b"]),
+// ];
-// multiple crate with no children
-#[test]
-fn format_nested_multiple_crates_no_children() {
- let imports = &[
- Import(&["my_crate"]),
- Import(&["foo"]),
- Import(&["foo"]),
- Import(&["my_crate"]),
- ];
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[
+// concat!("my_crate::{\n", " self,\n", " a,\n", "}\n",),
+// concat!(
+// "foo::{\n",
+// " b::{\n",
+// " self,\n",
+// " B1,\n",
+// " },\n",
+// "}\n",
+// ),
+// ]
+// );
- assert_eq!(
- format_nested(imports, Order::Original),
- &["my_crate\n", "foo\n"]
- );
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &["foo\n", "my_crate\n"]
- );
-}
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[
+// concat!(
+// "foo::{\n",
+// " b::{\n",
+// " self,\n",
+// " B1,\n",
+// " },\n",
+// "}\n",
+// ),
+// concat!("my_crate::{\n", " self,\n", " a,\n", "}\n",),
+// ]
+// );
+// }
-// one crate with one children
-#[test]
-fn format_nested_one_crate_one_children() {
- let imports = &[Import(&["my_crate", "a"])];
+// // one crate with no children
+// #[test]
+// fn format_nested_one_crate_no_children() {
+// let imports = &[Import(&["my_crate"])];
- assert_eq!(
- format_nested(imports, Order::Original),
- &[concat!("my_crate::{\n", " a,\n", "}\n",),]
- );
+// assert_eq!(format_nested(imports, Order::Original), &["my_crate\n"]);
+// assert_eq!(format_nested(imports, Order::Sorted), &["my_crate\n"]);
+// }
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[concat!("my_crate::{\n", " a,\n", "}\n",),]
- );
-}
+// // multiple crate with no children
+// #[test]
+// fn format_nested_multiple_crates_no_children() {
+// let imports = &[
+// Import(&["my_crate"]),
+// Import(&["foo"]),
+// Import(&["foo"]),
+// Import(&["my_crate"]),
+// ];
-// multiple crate with one children
-#[test]
-fn format_nested_multiple_crates_one_children() {
- let imports = &[Import(&["my_crate", "a"]), Import(&["foo", "b"])];
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &["my_crate\n", "foo\n"]
+// );
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &["foo\n", "my_crate\n"]
+// );
+// }
- assert_eq!(
- format_nested(imports, Order::Original),
- &[
- concat!("my_crate::{\n", " a,\n", "}\n",),
- concat!("foo::{\n", " b,\n", "}\n",),
- ]
- );
+// // one crate with one children
+// #[test]
+// fn format_nested_one_crate_one_children() {
+// let imports = &[Import(&["my_crate", "a"])];
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[
- concat!("foo::{\n", " b,\n", "}\n",),
- concat!("my_crate::{\n", " a,\n", "}\n",),
- ]
- );
-}
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[concat!("my_crate::{\n", " a,\n", "}\n",),]
+// );
-// one crate with multiple children
-#[test]
-fn format_nested_one_crate_multiple_children() {
- let imports = &[
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "a"]),
- Import(&["my_crate"]),
- Import(&["my_crate", "b", "B1"]),
- ];
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[concat!("my_crate::{\n", " a,\n", "}\n",),]
+// );
+// }
- assert_eq!(
- format_nested(imports, Order::Original),
- &[concat!(
- "my_crate::{\n",
- " b::{\n",
- " B2,\n",
- " B1,\n",
- " },\n",
- " c,\n",
- " a,\n",
- " self,\n",
- "}\n",
- ),]
- );
+// // multiple crate with one children
+// #[test]
+// fn format_nested_multiple_crates_one_children() {
+// let imports = &[Import(&["my_crate", "a"]), Import(&["foo", "b"])];
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[concat!(
- "my_crate::{\n",
- " self,\n",
- " a,\n",
- " b::{\n",
- " B1,\n",
- " B2,\n",
- " },\n",
- " c,\n",
- "}\n",
- ),]
- );
-}
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[
+// concat!("my_crate::{\n", " a,\n", "}\n",),
+// concat!("foo::{\n", " b,\n", "}\n",),
+// ]
+// );
-// multiple crate with multiple children
-#[test]
-fn format_nested_multiple_crates_multiple_children() {
- let imports = &[
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "a"]),
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "b", "B1"]),
- Import(&["foo", "c"]),
- Import(&["foo", "b", "B2"]),
- Import(&["foo", "a"]),
- Import(&["foo", "b", "B1"]),
- ];
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[
+// concat!("foo::{\n", " b,\n", "}\n",),
+// concat!("my_crate::{\n", " a,\n", "}\n",),
+// ]
+// );
+// }
- assert_eq!(
- format_nested(imports, Order::Original),
- &[
- concat!(
- "my_crate::{\n",
- " b::{\n",
- " B2,\n",
- " B1,\n",
- " },\n",
- " c,\n",
- " a,\n",
- "}\n",
- ),
- concat!(
- "foo::{\n",
- " c,\n",
- " b::{\n",
- " B2,\n",
- " B1,\n",
- " },\n",
- " a,\n",
- "}\n",
- ),
- ]
- );
+// // one crate with multiple children
+// #[test]
+// fn format_nested_one_crate_multiple_children() {
+// let imports = &[
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "a"]),
+// Import(&["my_crate"]),
+// Import(&["my_crate", "b", "B1"]),
+// ];
- assert_eq!(
- format_nested(imports, Order::Sorted),
- &[
- concat!(
- "foo::{\n",
- " a,\n",
- " b::{\n",
- " B1,\n",
- " B2,\n",
- " },\n",
- " c,\n",
- "}\n",
- ),
- concat!(
- "my_crate::{\n",
- " a,\n",
- " b::{\n",
- " B1,\n",
- " B2,\n",
- " },\n",
- " c,\n",
- "}\n",
- ),
- ]
- );
-}
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[concat!(
+// "my_crate::{\n",
+// " self,\n",
+// " b::{\n",
+// " B2,\n",
+// " B1,\n",
+// " },\n",
+// " c,\n",
+// " a,\n",
+// "}\n",
+// ),]
+// );
-// depth 3
-#[test]
-fn format_nested_depth_3() {
- let imports = &[
- Import(&["my_crate", "b", "B2", "BB1"]),
- Import(&["my_crate", "c"]),
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "a"]),
- Import(&["my_crate", "b", "B2"]),
- Import(&["my_crate", "b", "B1"]),
- Import(&["foo", "c"]),
- Import(&["foo", "b", "B2"]),
- Import(&["foo", "a"]),
- Import(&["foo", "b", "B1"]),
- ];
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[concat!(
+// "my_crate::{\n",
+// " self,\n",
+// " a,\n",
+// " b::{\n",
+// " B1,\n",
+// " B2,\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// ),]
+// );
+// }
- assert_eq!(
- format_nested(imports, Order::Original),
- &[
- concat!(
- "my_crate::{\n",
- " b::{\n",
- " B2::{\n",
- " BB1,\n",
- " self,\n",
- " },\n",
- " B1,\n",
- " },\n",
- " c,\n",
- " a,\n",
- "}\n",
- ),
- concat!(
- "foo::{\n",
- " c,\n",
- " b::{\n",
- " B2,\n",
- " B1,\n",
- " },\n",
- " a,\n",
- "}\n",
- ),
- ]
- );
+// // multiple crate with multiple children
+// #[test]
+// fn format_nested_multiple_crates_multiple_children() {
+// let imports = &[
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "a"]),
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "b", "B1"]),
+// Import(&["foo", "c"]),
+// Import(&["foo", "b", "B2"]),
+// Import(&["foo", "a"]),
+// Import(&["foo", "b", "B1"]),
+// ];
- assert_eq!(
- format_nested(imports, Order::Sorted),
+// assert_eq!(
- &[
+// format_nested(imports, Order::Original),
- concat!(
+// &[
- "foo::{\n",
+// concat!(
- " a,\n",
+// "my_crate::{\n",
- " b::{\n",
+// " b::{\n",
- " B1,\n",
+// " B2,\n",
- " B2,\n",
+// " B1,\n",
- " },\n",
+// " },\n",
- " c,\n",
+// " c,\n",
- "}\n",
+// " a,\n",
- ),
+// "}\n",
- concat!(
+// ),
- "my_crate::{\n",
+// concat!(
- " a,\n",
+// "foo::{\n",
- " b::{\n",
+// " c,\n",
- " B1,\n",
+// " b::{\n",
- " B2::{\n",
+// " B2,\n",
- " self,\n",
+// " B1,\n",
- " BB1,\n",
+// " },\n",
- " },\n",
+// " a,\n",
- " },\n",
+// "}\n",
- " c,\n",
+// ),
- "}\n",
+// ]
- ),
+// );
- ]
+
- );
+// assert_eq!(
-}
+// format_nested(imports, Order::Sorted),
+// &[
+// concat!(
+// "foo::{\n",
+// " a,\n",
+// " b::{\n",
+// " B1,\n",
+// " B2,\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// ),
+// concat!(
+// "my_crate::{\n",
+// " a,\n",
+// " b::{\n",
+// " B1,\n",
+// " B2,\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// ),
+// ]
+// );
+// }
+
+// // depth 3
+// #[test]
+// fn format_nested_depth_3() {
+// let imports = &[
+// Import(&["my_crate", "b", "B2", "BB1"]),
+// Import(&["my_crate", "c"]),
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate"]),
+// Import(&["my_crate", "a"]),
+// Import(&["my_crate", "b", "B2"]),
+// Import(&["my_crate", "b"]),
+// Import(&["my_crate", "b", "B1"]),
+// Import(&["foo", "c"]),
+// Import(&["foo"]),
+// Import(&["foo", "b", "B2"]),
+// Import(&["foo", "a"]),
+// Import(&["foo", "b", "B1"]),
+// ];
+
+// assert_eq!(
+// format_nested(imports, Order::Original),
+// &[
+// concat!(
+// "my_crate::{\n",
+// " self,\n",
+// " b::{\n",
+// " self,\n",
+// " B2::{\n",
+// " self,\n",
+// " BB1,\n",
+// " },\n",
+// " B1,\n",
+// " },\n",
+// " c,\n",
+// " a,\n",
+// "}\n",
+// ),
+// concat!(
+// "foo::{\n",
+// " self,\n",
+// " c,\n",
+// " b::{\n",
+// " B2,\n",
+// " B1,\n",
+// " },\n",
+// " a,\n",
+// "}\n",
+// ),
+// ]
+// );
+
+// assert_eq!(
+// format_nested(imports, Order::Sorted),
+// &[
+// concat!(
+// "foo::{\n",
+// " self,\n",
+// " a,\n",
+// " b::{\n",
+// " B1,\n",
+// " B2,\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// ),
+// concat!(
+// "my_crate::{\n",
+// " self,\n",
+// " a,\n",
+// " b::{\n",
+// " self,\n",
+// " B1,\n",
+// " B2::{\n",
+// " self,\n",
+// " BB1,\n",
+// " },\n",
+// " },\n",
+// " c,\n",
+// "}\n",
+// ),
+// ]
+// );
+// }