fix tests
This commit is contained in:
parent
762f6452b9
commit
9e59d744ac
1 changed files with 187 additions and 146 deletions
|
@ -12,6 +12,8 @@ fn fmtdflt() -> FormatSpec<'static> {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "",
|
||||
};
|
||||
}
|
||||
|
@ -79,7 +81,8 @@ fn format_position_nothing_else() {
|
|||
}
|
||||
#[test]
|
||||
fn format_type() {
|
||||
same("{3:a}",
|
||||
same(
|
||||
"{3:a}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentIs(3),
|
||||
format: FormatSpec {
|
||||
|
@ -88,13 +91,16 @@ fn format_type() {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "a",
|
||||
},
|
||||
})]);
|
||||
}
|
||||
#[test]
|
||||
fn format_align_fill() {
|
||||
same("{3:>}",
|
||||
same(
|
||||
"{3:>}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentIs(3),
|
||||
format: FormatSpec {
|
||||
|
@ -103,10 +109,13 @@ fn format_align_fill() {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "",
|
||||
},
|
||||
})]);
|
||||
same("{3:0<}",
|
||||
same(
|
||||
"{3:0<}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentIs(3),
|
||||
format: FormatSpec {
|
||||
|
@ -115,10 +124,13 @@ fn format_align_fill() {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "",
|
||||
},
|
||||
})]);
|
||||
same("{3:*<abcd}",
|
||||
same(
|
||||
"{3:*<abcd}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentIs(3),
|
||||
format: FormatSpec {
|
||||
|
@ -127,6 +139,8 @@ fn format_align_fill() {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "abcd",
|
||||
},
|
||||
})]);
|
||||
|
@ -135,7 +149,8 @@ fn format_align_fill() {
|
|||
fn format_counts() {
|
||||
use syntax_pos::{GLOBALS, Globals, edition};
|
||||
GLOBALS.set(&Globals::new(edition::DEFAULT_EDITION), || {
|
||||
same("{:10s}",
|
||||
same(
|
||||
"{:10s}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentImplicitlyIs(0),
|
||||
format: FormatSpec {
|
||||
|
@ -144,10 +159,13 @@ fn format_counts() {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountIs(10),
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "s",
|
||||
},
|
||||
})]);
|
||||
same("{:10$.10s}",
|
||||
same(
|
||||
"{:10$.10s}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentImplicitlyIs(0),
|
||||
format: FormatSpec {
|
||||
|
@ -156,10 +174,13 @@ fn format_counts() {
|
|||
flags: 0,
|
||||
precision: CountIs(10),
|
||||
width: CountIsParam(10),
|
||||
precision_span: None,
|
||||
width_span: Some(InnerSpan::new(3, 6)),
|
||||
ty: "s",
|
||||
},
|
||||
})]);
|
||||
same("{:.*s}",
|
||||
same(
|
||||
"{:.*s}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentImplicitlyIs(1),
|
||||
format: FormatSpec {
|
||||
|
@ -168,10 +189,13 @@ fn format_counts() {
|
|||
flags: 0,
|
||||
precision: CountIsParam(0),
|
||||
width: CountImplied,
|
||||
precision_span: Some(InnerSpan::new(3, 5)),
|
||||
width_span: None,
|
||||
ty: "s",
|
||||
},
|
||||
})]);
|
||||
same("{:.10$s}",
|
||||
same(
|
||||
"{:.10$s}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentImplicitlyIs(0),
|
||||
format: FormatSpec {
|
||||
|
@ -180,10 +204,13 @@ fn format_counts() {
|
|||
flags: 0,
|
||||
precision: CountIsParam(10),
|
||||
width: CountImplied,
|
||||
precision_span: Some(InnerSpan::new(3, 7)),
|
||||
width_span: None,
|
||||
ty: "s",
|
||||
},
|
||||
})]);
|
||||
same("{:a$.b$s}",
|
||||
same(
|
||||
"{:a$.b$s}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentImplicitlyIs(0),
|
||||
format: FormatSpec {
|
||||
|
@ -192,6 +219,8 @@ fn format_counts() {
|
|||
flags: 0,
|
||||
precision: CountIsName(Symbol::intern("b")),
|
||||
width: CountIsName(Symbol::intern("a")),
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "s",
|
||||
},
|
||||
})]);
|
||||
|
@ -199,7 +228,8 @@ fn format_counts() {
|
|||
}
|
||||
#[test]
|
||||
fn format_flags() {
|
||||
same("{:-}",
|
||||
same(
|
||||
"{:-}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentImplicitlyIs(0),
|
||||
format: FormatSpec {
|
||||
|
@ -208,10 +238,13 @@ fn format_flags() {
|
|||
flags: (1 << FlagSignMinus as u32),
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "",
|
||||
},
|
||||
})]);
|
||||
same("{:+#}",
|
||||
same(
|
||||
"{:+#}",
|
||||
&[NextArgument(Argument {
|
||||
position: ArgumentImplicitlyIs(0),
|
||||
format: FormatSpec {
|
||||
|
@ -220,14 +253,18 @@ fn format_flags() {
|
|||
flags: (1 << FlagSignPlus as u32) | (1 << FlagAlternate as u32),
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "",
|
||||
},
|
||||
})]);
|
||||
}
|
||||
#[test]
|
||||
fn format_mixture() {
|
||||
same("abcd {3:a} efg",
|
||||
&[String("abcd "),
|
||||
same(
|
||||
"abcd {3:a} efg",
|
||||
&[
|
||||
String("abcd "),
|
||||
NextArgument(Argument {
|
||||
position: ArgumentIs(3),
|
||||
format: FormatSpec {
|
||||
|
@ -236,8 +273,12 @@ fn format_mixture() {
|
|||
flags: 0,
|
||||
precision: CountImplied,
|
||||
width: CountImplied,
|
||||
precision_span: None,
|
||||
width_span: None,
|
||||
ty: "a",
|
||||
},
|
||||
}),
|
||||
String(" efg")]);
|
||||
String(" efg"),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue