Add tests for new format! error message
This commit is contained in:
parent
82d5ea4b12
commit
d5cb474f57
@ -11,36 +11,39 @@
|
||||
fn main() {
|
||||
// bad arguments to the format! call
|
||||
|
||||
format!("{}"); //~ ERROR: invalid reference to argument
|
||||
// bad number of arguments, see #44954 (originally #15780)
|
||||
|
||||
format!("{1}", 1); //~ ERROR: invalid reference to argument `1`
|
||||
//~^ ERROR: argument never used
|
||||
format!("{foo}"); //~ ERROR: no argument named `foo`
|
||||
format!("{}");
|
||||
//~^ ERROR: 1 positional argument in format string, but no arguments were given
|
||||
|
||||
format!("", 1, 2); //~ ERROR: multiple unused formatting arguments
|
||||
format!("{}", 1, 2); //~ ERROR: argument never used
|
||||
format!("{1}", 1, 2); //~ ERROR: argument never used
|
||||
format!("{}", 1, foo=2); //~ ERROR: named argument never used
|
||||
format!("{foo}", 1, foo=2); //~ ERROR: argument never used
|
||||
format!("", foo=2); //~ ERROR: named argument never used
|
||||
format!("{1}", 1);
|
||||
//~^ ERROR: 1 positional argument in format string, but there is only 1 argument
|
||||
//~^^ ERROR: argument never used
|
||||
|
||||
format!("{foo}", foo=1, foo=2); //~ ERROR: duplicate argument
|
||||
format!("", foo=1, 2); //~ ERROR: positional arguments cannot follow
|
||||
|
||||
// bad number of arguments, see #15780
|
||||
|
||||
format!("{0}");
|
||||
//~^ ERROR invalid reference to argument `0` (no arguments given)
|
||||
format!("{} {}");
|
||||
//~^ ERROR: 2 positional arguments in format string, but no arguments were given
|
||||
|
||||
format!("{0} {1}", 1);
|
||||
//~^ ERROR invalid reference to argument `1` (there is 1 argument)
|
||||
//~^ ERROR: 2 positional arguments in format string, but there is only 1 argument
|
||||
|
||||
format!("{0} {1} {2}", 1, 2);
|
||||
//~^ ERROR invalid reference to argument `2` (there are 2 arguments)
|
||||
//~^ ERROR: 3 positional arguments in format string, but there are only 2 arguments
|
||||
|
||||
format!("{0} {1}");
|
||||
//~^ ERROR invalid reference to argument `0` (no arguments given)
|
||||
//~^^ ERROR invalid reference to argument `1` (no arguments given)
|
||||
format!("{} {value} {} {}", 1, value=2);
|
||||
//~^ ERROR: invalid reference to positional argument 2 (there are only 2 arguments)
|
||||
format!("{name} {value} {} {} {} {} {} {}", 0, name=1, value=2);
|
||||
//~^ ERROR: invalid reference to positional arguments 3, 4 and 5 (there are only 3 arguments)
|
||||
|
||||
format!("{foo}"); //~ ERROR: no argument named `foo`
|
||||
format!("", 1, 2); //~ ERROR: multiple unused formatting arguments
|
||||
format!("{}", 1, 2); //~ ERROR: argument never used
|
||||
format!("{1}", 1, 2); //~ ERROR: argument never used
|
||||
format!("{}", 1, foo=2); //~ ERROR: named argument never used
|
||||
format!("{foo}", 1, foo=2); //~ ERROR: argument never used
|
||||
format!("", foo=2); //~ ERROR: named argument never used
|
||||
|
||||
format!("{foo}", foo=1, foo=2); //~ ERROR: duplicate argument
|
||||
format!("", foo=1, 2); //~ ERROR: positional arguments cannot follow
|
||||
|
||||
// bad named arguments, #35082
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user