Skip to content

Commit

Permalink
refined tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sjael committed Feb 26, 2024
1 parent 1bcd1e3 commit c48181e
Show file tree
Hide file tree
Showing 13 changed files with 330 additions and 254 deletions.
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 1 addition & 7 deletions src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2353,13 +2353,7 @@ fn rewrite_fn_base(
2
};
let used_width = last_line_used_width(&result, indent.width());
let one_line_budget = std::cmp::min(
context.budget(used_width + overhead),
context
.config
.fn_param_width()
.saturating_sub(used_width + overhead),
);
let one_line_budget = context.budget(used_width + overhead);
let shape = Shape {
width: one_line_budget,
indent,
Expand Down
1 change: 0 additions & 1 deletion tests/config/fn_param_width/0.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
max_width = 100
fn_param_width = 0
1 change: 0 additions & 1 deletion tests/config/fn_param_width/100.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
max_width = 100
fn_param_width = 100
1 change: 0 additions & 1 deletion tests/config/fn_param_width/50.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
max_width = 50
fn_param_width = 50
82 changes: 15 additions & 67 deletions tests/source/config/fn_param_width/0.rs
Original file line number Diff line number Diff line change
@@ -1,93 +1,41 @@
// rustfmt-config: fn_param_width/0.toml



fn lorem(mut commands: Commands, icons: Res<Icons>) {
// block
}

fn ret(mut commands: Commands, icons: Res<Icons>) -> bool {
// block
}

unsafe fn lorem(mut commands: Commands, icons: Res<Icons>) {
// block
}

fn lagging(mut commands: Commands, icons: Res<Icons>) {
// block
}

pub fn public(mut commands: Commands, icons: Res<Icons>) {
// block
}

pub(super) fn up(mut commands: Commands, icons: Res<Icons>) {
// block
}

pub(crate) fn all(mut commands: Commands, icons: Res<Icons>) {
fn lorem(mut commands: Commands) {
// block
}

pub unsafe fn complicated(mut commands: Commands, icons: Res<Icons>) {
fn lorem(mut commands: Commands, icons: Res<Icons>) {
// block
}

extern "C" {
fn foreign(mut commands: Commands, icons: Res<Icons>) {
// block
}
}

fn homura<T: Deref<Target = i32>>(_: T) {}

fn generic<C>(query: Query<C>) {
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}

pub fn setup_arena(
mut commands: Commands,
icons: Res<Icons>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
//models: Res<Models>,
) {
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>) {
// block
}

fn comments(mut commands: Commands, /* intermission */ icons: Res<Icons>) {
fn comments(mut commands: Commands, /**/ icons: Res<Icons>) {
// block
}

fn spacing(mut commands: Commands, icons: Res<Icons>) {
fn comments(mut commands: Commands, /* really loooooong intermission */ icons: Res<Icons>) {
// block
}

impl Trait {
fn lorem(mut commands: Commands);
fn lorem(mut commands: Commands, icons: Res<Icons>);
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>);
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>);

fn lorem(mut commands: Commands) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>) {
// block
}
fn lorem(
mut commands: Commands,
icons: Res<Icons>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
);
}



fn outer(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block

fn inner(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
Expand All @@ -100,4 +48,4 @@ mod example {
// block
}
}
}
}
52 changes: 43 additions & 9 deletions tests/source/config/fn_param_width/100.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
// rustfmt-config: fn_param_width/100.toml

fn lorem(mut commands: Commands) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>) {
// block
}

fn comments(mut commands: Commands, /**/ icons: Res<Icons>) {
// block
}

fn comments(mut commands: Commands, /* really loooooong intermission */ icons: Res<Icons>) {
// block
}

impl Trait {
fn lorem(first: First, second: Second);
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter);
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter, fourth: FourthParameter);
fn lorem(mut commands: Commands);
fn lorem(mut commands: Commands, icons: Res<Icons>);
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>);
fn lorem(
mut commands: Commands,
icons: Res<Icons>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
);
}

fn lorem(first: First, second: Second) {
// block
}
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter) {
fn outer(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block

fn inner(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter, fourth: FourthParameter) {
}

mod example {
fn mod_func(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
fn nested(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
}
}
}
52 changes: 43 additions & 9 deletions tests/source/config/fn_param_width/150.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
// rustfmt-config: fn_param_width/150.toml

fn lorem(mut commands: Commands) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<StandardMaterial>>) {
// block
}

fn comments(mut commands: Commands, /**/ icons: Res<Icons>) {
// block
}

fn comments(mut commands: Commands, /* really loooooong intermission */ icons: Res<Icons>) {
// block
}

impl Trait {
fn lorem(first: First, second: Second);
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter);
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter, fourth: FourthParameter);
fn lorem(mut commands: Commands);
fn lorem(mut commands: Commands, icons: Res<Icons>);
fn lorem(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>);
fn lorem(
mut commands: Commands,
icons: Res<Icons>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
);
}

fn lorem(first: First, second: Second) {
// block
}
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter) {
fn outer(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block

fn inner(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
fn lorem(first: FirstParameter, second: SecondParameter, third: ThirdParameter, fourth: FourthParameter) {
}

mod example {
fn mod_func(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
fn nested(mut commands: Commands, icons: Res<Icons>, mut meshes: ResMut<Assets<Mesh>>) {
// block
}
}
}
}
Loading

0 comments on commit c48181e

Please sign in to comment.