fn same(fmt: &'static str, p: &[Piece<'static>]) {
let parser = Parser::new(fmt, None, vec![], false);
- assert!(parser.collect::<Vec<Piece<'static>>>() == p);
+ assert_eq!(parser.collect::<Vec<Piece<'static>>>(), p);
}
fn fmtdflt() -> FormatSpec<'static> {
precision_span: None,
width_span: None,
ty: "",
+ ty_span: None,
};
}
#[test]
fn format_type() {
same(
- "{3:a}",
+ "{3:x}",
&[NextArgument(Argument {
position: ArgumentIs(3),
format: FormatSpec {
width: CountImplied,
precision_span: None,
width_span: None,
- ty: "a",
+ ty: "x",
+ ty_span: None,
},
})]);
}
precision_span: None,
width_span: None,
ty: "",
+ ty_span: None,
},
})]);
same(
precision_span: None,
width_span: None,
ty: "",
+ ty_span: None,
},
})]);
same(
precision_span: None,
width_span: None,
ty: "abcd",
+ ty_span: Some(InnerSpan::new(6, 10)),
},
})]);
}
use syntax_pos::{GLOBALS, Globals, edition};
GLOBALS.set(&Globals::new(edition::DEFAULT_EDITION), || {
same(
- "{:10s}",
+ "{:10x}",
&[NextArgument(Argument {
position: ArgumentImplicitlyIs(0),
format: FormatSpec {
width: CountIs(10),
precision_span: None,
width_span: None,
- ty: "s",
+ ty: "x",
+ ty_span: None,
},
})]);
same(
- "{:10$.10s}",
+ "{:10$.10x}",
&[NextArgument(Argument {
position: ArgumentImplicitlyIs(0),
format: FormatSpec {
width: CountIsParam(10),
precision_span: None,
width_span: Some(InnerSpan::new(3, 6)),
- ty: "s",
+ ty: "x",
+ ty_span: None,
},
})]);
same(
- "{:.*s}",
+ "{:.*x}",
&[NextArgument(Argument {
position: ArgumentImplicitlyIs(1),
format: FormatSpec {
width: CountImplied,
precision_span: Some(InnerSpan::new(3, 5)),
width_span: None,
- ty: "s",
+ ty: "x",
+ ty_span: None,
},
})]);
same(
- "{:.10$s}",
+ "{:.10$x}",
&[NextArgument(Argument {
position: ArgumentImplicitlyIs(0),
format: FormatSpec {
width: CountImplied,
precision_span: Some(InnerSpan::new(3, 7)),
width_span: None,
- ty: "s",
+ ty: "x",
+ ty_span: None,
},
})]);
same(
- "{:a$.b$s}",
+ "{:a$.b$?}",
&[NextArgument(Argument {
position: ArgumentImplicitlyIs(0),
format: FormatSpec {
width: CountIsName(Symbol::intern("a")),
precision_span: None,
width_span: None,
- ty: "s",
+ ty: "?",
+ ty_span: None,
},
})]);
});
precision_span: None,
width_span: None,
ty: "",
+ ty_span: None,
},
})]);
same(
precision_span: None,
width_span: None,
ty: "",
+ ty_span: None,
},
})]);
}
#[test]
fn format_mixture() {
same(
- "abcd {3:a} efg",
+ "abcd {3:x} efg",
&[
String("abcd "),
NextArgument(Argument {
width: CountImplied,
precision_span: None,
width_span: None,
- ty: "a",
+ ty: "x",
+ ty_span: None,
},
}),
String(" efg"),