Add some tests for match blocks
This commit is contained in:
parent
abe8e7de99
commit
8e471ece31
@ -8,6 +8,17 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Formatting of chained expressions, i.e. expressions which are chained by
|
||||
// dots: struct and enum field access and method calls.
|
||||
//
|
||||
// Instead of walking these subexpressions one-by-one, as is our usual strategy
|
||||
// for expression formatting, we collect maximal sequences of these expressions
|
||||
// and handle them simultaneously.
|
||||
//
|
||||
// Whenever possible, the entire chain is put on a single line. If that fails,
|
||||
// we put each subexpression on a separate, much like the (default) function
|
||||
// argument function argument strategy.
|
||||
|
||||
use rewrite::{Rewrite, RewriteContext};
|
||||
use utils::{make_indent, extra_offset};
|
||||
use expr::rewrite_call;
|
||||
|
@ -150,17 +150,6 @@ pub fn contains_comment(text: &str) -> bool {
|
||||
CharClasses::new(text.chars()).any(|(kind, _)| kind == CodeCharKind::Comment)
|
||||
}
|
||||
|
||||
pub fn uncommented(text: &str) -> String {
|
||||
CharClasses::new(text.chars())
|
||||
.filter_map(|(s, c)| {
|
||||
match s {
|
||||
CodeCharKind::Normal => Some(c),
|
||||
CodeCharKind::Comment => None,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
struct CharClasses<T>
|
||||
where T: Iterator,
|
||||
T::Item: RichChar
|
||||
@ -321,10 +310,14 @@ mod test {
|
||||
// This is probably intended to be a non-test fn, but it is not used. I'm
|
||||
// keeping it around unless it helps us test stuff.
|
||||
fn uncommented(text: &str) -> String {
|
||||
CharClasses::new(text.chars()).filter_map(|(s, c)| match s {
|
||||
CodeCharKind::Normal => Some(c),
|
||||
CodeCharKind::Comment => None
|
||||
}).collect()
|
||||
CharClasses::new(text.chars())
|
||||
.filter_map(|(s, c)| {
|
||||
match s {
|
||||
CodeCharKind::Normal => Some(c),
|
||||
CodeCharKind::Comment => None,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -21,6 +21,15 @@ fn main() {
|
||||
2
|
||||
});
|
||||
|
||||
fffffffffffffffffffffffffffffffffff(a,
|
||||
{
|
||||
SCRIPT_TASK_ROOT
|
||||
.with(|root| {
|
||||
// Another case of write_list failing us.
|
||||
*root.borrow_mut() = Some(&script_task);
|
||||
});
|
||||
});
|
||||
|
||||
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum = xxxxxxx
|
||||
.map(|x| x + 5)
|
||||
.map(|x| x / 2)
|
||||
|
@ -25,6 +25,14 @@ fn main() {
|
||||
}
|
||||
});
|
||||
|
||||
fffffffffffffffffffffffffffffffffff(a,
|
||||
{
|
||||
SCRIPT_TASK_ROOT.with(|root| {
|
||||
// Another case of write_list failing us.
|
||||
*root.borrow_mut() = Some(&script_task);
|
||||
});
|
||||
});
|
||||
|
||||
let suuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuum = xxxxxxx.map(|x| x + 5)
|
||||
.map(|x| x / 2)
|
||||
.fold(0, |acc, x| acc + x);
|
||||
|
Loading…
x
Reference in New Issue
Block a user