1
Fork 0

fix tests

This commit is contained in:
Esteban Küber 2019-07-29 21:51:32 -07:00
parent 762f6452b9
commit 9e59d744ac

View file

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