From 5ffcf045793d9014f23ea1b9bf20b3ef7796baa4 Mon Sep 17 00:00:00 2001 From: Kevin Amado Date: Sat, 29 Jan 2022 18:16:22 -0500 Subject: [PATCH] feat: increase paren coverage --- src/rules/paren.rs | 16 ++-- tests/cases/paren/in | 19 ++++- tests/cases/paren/out | 178 +++++++++++++++++++++++++++++++++++++++--- 3 files changed, 194 insertions(+), 19 deletions(-) diff --git a/src/rules/paren.rs b/src/rules/paren.rs index 298c1fe..a252b04 100644 --- a/src/rules/paren.rs +++ b/src/rules/paren.rs @@ -12,41 +12,45 @@ pub fn rule( build_ctx.config.layout() }; + // ( let child = children.get_next().unwrap(); steps.push_back(crate::builder::Step::Format(child.element)); match layout { crate::config::Layout::Tall => { steps.push_back(crate::builder::Step::Indent); - steps.push_back(crate::builder::Step::NewLine); - steps.push_back(crate::builder::Step::Pad); - } - crate::config::Layout::Wide => { - steps.push_back(crate::builder::Step::Whitespace); } + crate::config::Layout::Wide => {} } + // /**/ children.drain_comments(|text| { - steps.push_back(crate::builder::Step::Comment(text)); steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); + steps.push_back(crate::builder::Step::Comment(text)); }); + // expr let child = children.get_next().unwrap(); match layout { crate::config::Layout::Tall => { + steps.push_back(crate::builder::Step::NewLine); + steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::FormatWider(child.element)); } crate::config::Layout::Wide => { + steps.push_back(crate::builder::Step::Whitespace); steps.push_back(crate::builder::Step::Format(child.element)); } } + // /**/ children.drain_comments(|text| { steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::Pad); steps.push_back(crate::builder::Step::Comment(text)); }); + // ) let child = children.get_next().unwrap(); match layout { crate::config::Layout::Tall => { diff --git a/tests/cases/paren/in b/tests/cases/paren/in index 3346a37..2d677b2 100644 --- a/tests/cases/paren/in +++ b/tests/cases/paren/in @@ -1 +1,18 @@ -(/*a*/(/*b*/(c))/*d*/) +( + ( ( c ) ) + ( ( c )/*e*/) + ( ( c/*d*/) ) + ( ( c/*d*/)/*e*/) + ( (/*b*/c ) ) + ( (/*b*/c )/*e*/) + ( (/*b*/c/*d*/) ) + ( (/*b*/c/*d*/)/*e*/) + (/*a*/( c ) ) + (/*a*/( c )/*e*/) + (/*a*/( c/*d*/) ) + (/*a*/( c/*d*/)/*e*/) + (/*a*/(/*b*/c ) ) + (/*a*/(/*b*/c )/*e*/) + (/*a*/(/*b*/c/*d*/) ) + (/*a*/(/*b*/c/*d*/)/*e*/) +) diff --git a/tests/cases/paren/out b/tests/cases/paren/out index c4bafd9..f1b66ca 100644 --- a/tests/cases/paren/out +++ b/tests/cases/paren/out @@ -1,14 +1,168 @@ ( - /* - a - */ - ( - /* - b - */ - ( c ) - ) - /* - d - */ + ( ( c ) ) + ( + ( c ) + /* + e + */ + ) + ( + ( + c + /* + d + */ + ) + ) + ( + ( + c + /* + d + */ + ) + /* + e + */ + ) + ( + ( + /* + b + */ + c + ) + ) + ( + ( + /* + b + */ + c + ) + /* + e + */ + ) + ( + ( + /* + b + */ + c + /* + d + */ + ) + ) + ( + ( + /* + b + */ + c + /* + d + */ + ) + /* + e + */ + ) + ( + /* + a + */ + ( c ) + ) + ( + /* + a + */ + ( c ) + /* + e + */ + ) + ( + /* + a + */ + ( + c + /* + d + */ + ) + ) + ( + /* + a + */ + ( + c + /* + d + */ + ) + /* + e + */ + ) + ( + /* + a + */ + ( + /* + b + */ + c + ) + ) + ( + /* + a + */ + ( + /* + b + */ + c + ) + /* + e + */ + ) + ( + /* + a + */ + ( + /* + b + */ + c + /* + d + */ + ) + ) + ( + /* + a + */ + ( + /* + b + */ + c + /* + d + */ + ) + /* + e + */ + ) )