From fbb2370d66e35029e6e6545f12831d591b1e0cae Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 24 Feb 2017 10:43:53 +1300 Subject: [PATCH] Some tests --- tests/source/trailing-comma-never.rs | 41 +++++++++++++++++ tests/source/trailing_commas.rs | 46 +++++++++++++++++++ tests/target/trailing-comma-never.rs | 31 +++++++++++++ tests/target/trailing_commas.rs | 66 ++++++++++++++++++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 tests/source/trailing-comma-never.rs create mode 100644 tests/source/trailing_commas.rs create mode 100644 tests/target/trailing-comma-never.rs create mode 100644 tests/target/trailing_commas.rs diff --git a/tests/source/trailing-comma-never.rs b/tests/source/trailing-comma-never.rs new file mode 100644 index 00000000000..5985b514724 --- /dev/null +++ b/tests/source/trailing-comma-never.rs @@ -0,0 +1,41 @@ +// rustfmt-trailing_comma: Never + +enum X { + A, + B, +} + +enum Y { + A, + B +} + +enum TupX { + A(u32), + B(i32, u16), +} + +enum TupY { + A(u32), + B(i32, u16) +} + +enum StructX { + A { + s: u16, + }, + B { + u: u32, + i: i32, + }, +} + +enum StructY { + A { + s: u16, + }, + B { + u: u32, + i: i32, + } +} diff --git a/tests/source/trailing_commas.rs b/tests/source/trailing_commas.rs new file mode 100644 index 00000000000..d1c53721652 --- /dev/null +++ b/tests/source/trailing_commas.rs @@ -0,0 +1,46 @@ +// rustfmt-trailing_comma: Always + +fn main() { + match foo { + x => {} + y => { + foo(); + } + _ => x + } +} + +fn f(x: T, y: S) -> T where T: P, S: Q +{ + x +} + +impl Trait for T where T: P +{ + fn f(x: T) -> T where T: Q + R + { + x + } +} + +struct Pair where T: P, S: P + Q { + a: T, + b: S +} + +struct TupPair (S, T) where T: P, S: P + Q; + +enum E where S: P, T: P { + A {a: T}, +} + +type Double where T: P, T: Q = Pair; + +extern "C" { + fn f(x: T, y: S) -> T where T: P, S: Q; +} + +trait Q where T: P, S: R +{ + fn f(self, x: T, y: S, z: U) -> Self where U: P, V: P; +} diff --git a/tests/target/trailing-comma-never.rs b/tests/target/trailing-comma-never.rs new file mode 100644 index 00000000000..3df0c7950eb --- /dev/null +++ b/tests/target/trailing-comma-never.rs @@ -0,0 +1,31 @@ +// rustfmt-trailing_comma: Never + +enum X { + A, + B +} + +enum Y { + A, + B +} + +enum TupX { + A(u32), + B(i32, u16) +} + +enum TupY { + A(u32), + B(i32, u16) +} + +enum StructX { + A { s: u16 }, + B { u: u32, i: i32 } +} + +enum StructY { + A { s: u16 }, + B { u: u32, i: i32 } +} diff --git a/tests/target/trailing_commas.rs b/tests/target/trailing_commas.rs new file mode 100644 index 00000000000..3c707d07dba --- /dev/null +++ b/tests/target/trailing_commas.rs @@ -0,0 +1,66 @@ +// rustfmt-trailing_comma: Always + +fn main() { + match foo { + x => {}, + y => { + foo(); + }, + _ => x, + } +} + +fn f(x: T, y: S) -> T + where T: P, + S: Q, +{ + x +} + +impl Trait for T + where T: P, +{ + fn f(x: T) -> T + where T: Q + R, + { + x + } +} + +struct Pair + where T: P, + S: P + Q, +{ + a: T, + b: S, +} + +struct TupPair(S, T) + where T: P, + S: P + Q; + +enum E + where S: P, + T: P, +{ + A { a: T, }, +} + +type Double + where T: P, + T: Q = Pair; + +extern "C" { + fn f(x: T, y: S) -> T + where T: P, + S: Q; +} + +trait Q + where T: P, + S: R, +{ + fn f(self, x: T, y: S, z: U) -> Self + where U: P, + V: P; +}