about summary refs log tree commit diff
path: root/tests/source
diff options
context:
space:
mode:
authorNick Cameron <nrc@ncameron.org>2015-07-25 09:51:59 +1200
committerNick Cameron <nrc@ncameron.org>2015-07-25 09:51:59 +1200
commit8461e8a0a8b1dd825f30de9d5bc4f5c1d8d57dbd (patch)
tree388f10a44cff5b08f803549aa78eae35c06caad2 /tests/source
parent4aa24f5962ddfcef3028463f42cf55c047c4e26d (diff)
parentc4101de53d8a0707907cb03c67a9224ab9943d37 (diff)
Merge pull request #147 from marcusklaas/even-more-expr
Format if expressions & loops
Diffstat (limited to 'tests/source')
-rw-r--r--tests/source/expr-visual-indent.rs9
-rw-r--r--tests/source/expr.rs51
-rw-r--r--tests/source/loop.rs16
-rw-r--r--tests/source/struct_lits.rs11
-rw-r--r--tests/source/struct_lits_visual.rs2
5 files changed, 87 insertions, 2 deletions
diff --git a/tests/source/expr-visual-indent.rs b/tests/source/expr-visual-indent.rs
new file mode 100644
index 00000000000..c173d7bd7c4
--- /dev/null
+++ b/tests/source/expr-visual-indent.rs
@@ -0,0 +1,9 @@
+// rustfmt-config: expr_visual_indent.toml
+
+// Visual level block indentation.
+
+fn matcher() {
+    Some(while true {
+        test();
+    })
+}
\ No newline at end of file
diff --git a/tests/source/expr.rs b/tests/source/expr.rs
index f71ebcc9035..74538c13597 100644
--- a/tests/source/expr.rs
+++ b/tests/source/expr.rs
@@ -17,5 +17,54 @@ some_ridiculously_loooooooooooooooooooooong_function(10000 * 30000000000 + 40000
                                                      - 50000 * sqrt(-1),
                                                      trivial_value);
     (((((((((aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + a +
-             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaa)))))))))
+             aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaa)))))))));
+
+    { for _ in 0..10 {} }
+
+    {{{{}}}}
+
+     if  1  + 2 > 0  { let result = 5; result } else { 4};
+
+    if  let   Some(x)  =  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {
+        // Nothing
+    }
+
+    if  let   Some(x)  =  (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
+
+    if let (some_very_large,
+            tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1
+        + 2 + 3 {
+    }
+
+    if let (some_very_large,
+            tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1111 + 2222 {}
+
+    if let (some_very_large, tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple) = 1
+ + 2 + 3 {
+    }
+
+    if cond() {
+        something();
+    } else  if different_cond() {
+        something_else();
+    } else {
+        // Check subformatting
+        aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+    }
+}
+
+fn bar() {
+    let range = (   111111111 + 333333333333333333 + 1111 +   400000000000000000) .. (2222 +  2333333333333333);
+
+    let another_range = 5..some_func( a , b /* comment */);
+
+    for _  in  1 ..{ call_forever(); }
+
+    syntactically_correct(loop { sup( '?'); }, if cond { 0 } else { 1 });
+
+    let third = ..10;
+    let infi_range = ..;
+    let foo = 1..;
+    let bar = 5;
+    let nonsense = (10 .. 0)..(0..10);
 }
diff --git a/tests/source/loop.rs b/tests/source/loop.rs
index ad5ef93521d..36e6ab43de8 100644
--- a/tests/source/loop.rs
+++ b/tests/source/loop.rs
@@ -5,7 +5,21 @@ fn main() {
 
 let x = loop { do_forever(); };
 
-         loop {
+       'label :  loop {
         // Just comments
     }
+
+    'a: while loooooooooooooooooooooooooooooooooong_variable_name + another_value > some_other_value{}
+
+   while aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa > bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {
+   }
+
+    'b: for xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx in some_iter(arg1, arg2) {
+        // do smth
+    }
+
+    while let  Some(i) =     x.find('s')
+    {
+        x.update();
+    }
 }
diff --git a/tests/source/struct_lits.rs b/tests/source/struct_lits.rs
index f2726821e55..54f2ea5441b 100644
--- a/tests/source/struct_lits.rs
+++ b/tests/source/struct_lits.rs
@@ -22,6 +22,8 @@ fn main() {
     Foo { a:Bar,
           b:foo() };
 
+    Quux { x: if cond { bar(); }, y: baz() };
+
     A { 
     // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
     first: item(),
@@ -37,3 +39,12 @@ fn main() {
                *             o o o   o */
               graph: G, }
 }
+
+fn matcher() {
+    TagTerminatedByteMatcher {
+        matcher: ByteMatcher {
+        pattern: b"<HTML",
+        mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
+    },
+    };
+}
diff --git a/tests/source/struct_lits_visual.rs b/tests/source/struct_lits_visual.rs
index b629ffa1263..f14a56397ec 100644
--- a/tests/source/struct_lits_visual.rs
+++ b/tests/source/struct_lits_visual.rs
@@ -22,6 +22,8 @@ fn main() {
     Foo { a:Bar,
           b:foo() };
 
+    Quux { x: if cond { bar(); }, y: baz() };
+
     A { 
     // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
     first: item(),