about summary refs log tree commit diff
path: root/src/tools/rustfmt/tests/writemode/source
diff options
context:
space:
mode:
authorCaleb Cartwright <caleb.cartwright@outlook.com>2021-05-14 21:53:36 -0500
committerCaleb Cartwright <caleb.cartwright@outlook.com>2021-05-14 21:53:36 -0500
commitb2d45c0d4b2d44789000ebec6d702cc27db19782 (patch)
treec3accc00616767e5de0f89f69ce87519f02de6d5 /src/tools/rustfmt/tests/writemode/source
parente659b6de9170c055b6f2d16e2679b22d67297b13 (diff)
parent7872306edf2e11a69aaffb9434088fd66b46a863 (diff)
downloadrust-b2d45c0d4b2d44789000ebec6d702cc27db19782.tar.gz
rust-b2d45c0d4b2d44789000ebec6d702cc27db19782.zip
Add 'src/tools/rustfmt/' from commit '7872306edf2e11a69aaffb9434088fd66b46a863'
git-subtree-dir: src/tools/rustfmt
git-subtree-mainline: e659b6de9170c055b6f2d16e2679b22d67297b13
git-subtree-split: 7872306edf2e11a69aaffb9434088fd66b46a863
Diffstat (limited to 'src/tools/rustfmt/tests/writemode/source')
-rw-r--r--src/tools/rustfmt/tests/writemode/source/fn-single-line.rs80
-rw-r--r--src/tools/rustfmt/tests/writemode/source/json.rs80
-rw-r--r--src/tools/rustfmt/tests/writemode/source/modified.rs14
3 files changed, 174 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/writemode/source/fn-single-line.rs b/src/tools/rustfmt/tests/writemode/source/fn-single-line.rs
new file mode 100644
index 00000000000..ab1e13e17a7
--- /dev/null
+++ b/src/tools/rustfmt/tests/writemode/source/fn-single-line.rs
@@ -0,0 +1,80 @@
+// rustfmt-fn_single_line: true
+// rustfmt-emit_mode: checkstyle
+// Test single-line functions.
+
+fn foo_expr() {
+    1
+}
+
+fn foo_stmt() {
+    foo();
+}
+
+fn foo_decl_local()  {
+    let z = 5;
+   }
+
+fn    foo_decl_item(x: &mut i32) {
+    x = 3;
+}
+
+   fn empty()     {
+
+}
+
+fn foo_return() -> String {
+    "yay"
+}
+
+fn foo_where() -> T where T: Sync {
+    let x = 2;
+}
+
+fn fooblock() {
+    {
+        "inner-block"
+    }
+}
+
+fn fooblock2(x: i32) {
+    let z = match x {
+        _ => 2,
+    };
+}
+
+fn comment() {
+    // this is a test comment
+    1
+}
+
+fn comment2() {
+    // multi-line comment
+    let z = 2;
+    1
+}
+
+fn only_comment() {
+    // Keep this here
+}
+
+fn aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name() {
+    let z = "aaaaaaawwwwwwwwwwwwwwwwwwwwwwwwwwww";
+}
+
+fn lots_of_space                      ()                                                           {
+                           1                 
+}
+
+fn mac() -> Vec<i32> { vec![] }
+
+trait CoolTypes {
+    fn dummy(&self) {
+    }
+}
+
+trait CoolerTypes { fn dummy(&self) { 
+}
+}
+
+fn Foo<T>() where T: Bar {
+}
diff --git a/src/tools/rustfmt/tests/writemode/source/json.rs b/src/tools/rustfmt/tests/writemode/source/json.rs
new file mode 100644
index 00000000000..89dcf694183
--- /dev/null
+++ b/src/tools/rustfmt/tests/writemode/source/json.rs
@@ -0,0 +1,80 @@
+// rustfmt-fn_single_line: true
+// rustfmt-emit_mode: json
+// Test single-line functions.
+
+fn foo_expr() {
+    1
+}
+
+fn foo_stmt() {
+    foo();
+}
+
+fn foo_decl_local()  {
+    let z = 5;
+   }
+
+fn    foo_decl_item(x: &mut i32) {
+    x = 3;
+}
+
+   fn empty()     {
+
+}
+
+fn foo_return() -> String {
+    "yay"
+}
+
+fn foo_where() -> T where T: Sync {
+    let x = 2;
+}
+
+fn fooblock() {
+    {
+        "inner-block"
+    }
+}
+
+fn fooblock2(x: i32) {
+    let z = match x {
+        _ => 2,
+    };
+}
+
+fn comment() {
+    // this is a test comment
+    1
+}
+
+fn comment2() {
+    // multi-line comment
+    let z = 2;
+    1
+}
+
+fn only_comment() {
+    // Keep this here
+}
+
+fn aaaaaaaaaaaaaaaaa_looooooooooooooooooooooong_name() {
+    let z = "aaaaaaawwwwwwwwwwwwwwwwwwwwwwwwwwww";
+}
+
+fn lots_of_space                      ()                                                           {
+                           1                 
+}
+
+fn mac() -> Vec<i32> { vec![] }
+
+trait CoolTypes {
+    fn dummy(&self) {
+    }
+}
+
+trait CoolerTypes { fn dummy(&self) { 
+}
+}
+
+fn Foo<T>() where T: Bar {
+}
diff --git a/src/tools/rustfmt/tests/writemode/source/modified.rs b/src/tools/rustfmt/tests/writemode/source/modified.rs
new file mode 100644
index 00000000000..948beb348db
--- /dev/null
+++ b/src/tools/rustfmt/tests/writemode/source/modified.rs
@@ -0,0 +1,14 @@
+// rustfmt-write_mode: modified
+// Test "modified" output
+
+fn
+blah
+()
+{ }
+
+
+#[cfg
+(  a , b
+)]
+fn
+main() {}