From c74293f7a87cea3ce60a4df1c905501d4b749067 Mon Sep 17 00:00:00 2001 From: Alex Tokarev Date: Sun, 11 Oct 2020 20:30:55 +0300 Subject: Improve error message when parsing unquoted string (#385) * Improve error message when parsing unquoted string * Remove conversion to lowercase in parse_keylike() Converting keys to lowercase goes against TOML specification for floats. * Change error message for unquoted string --- test-suite/tests/datetime.rs | 6 +++--- test-suite/tests/invalid.rs | 4 ++-- test-suite/tests/parser.rs | 19 ++++++++++++++----- 3 files changed, 19 insertions(+), 10 deletions(-) (limited to 'test-suite') diff --git a/test-suite/tests/datetime.rs b/test-suite/tests/datetime.rs index 74b5939..6c08748 100644 --- a/test-suite/tests/datetime.rs +++ b/test-suite/tests/datetime.rs @@ -68,15 +68,15 @@ fn bad_times() { ); bad!( "foo = T", - "failed to parse datetime for key `foo` at line 1 column 7" + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" ); bad!( "foo = T.", - "expected newline, found a period at line 1 column 8" + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" ); bad!( "foo = TZ", - "failed to parse datetime for key `foo` at line 1 column 7" + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" ); bad!( "foo = 1997-09-09T09:09:09.09+", diff --git a/test-suite/tests/invalid.rs b/test-suite/tests/invalid.rs index ccc9338..f04d860 100644 --- a/test-suite/tests/invalid.rs +++ b/test-suite/tests/invalid.rs @@ -197,7 +197,7 @@ test!( test!( text_after_array_entries, include_str!("invalid/text-after-array-entries.toml"), - "invalid number at line 2 column 46" + "invalid TOML value, did you mean to use a quoted string? at line 2 column 46" ); test!( text_after_integer, @@ -222,5 +222,5 @@ test!( test!( text_in_array, include_str!("invalid/text-in-array.toml"), - "invalid number at line 3 column 3" + "invalid TOML value, did you mean to use a quoted string? at line 3 column 3" ); diff --git a/test-suite/tests/parser.rs b/test-suite/tests/parser.rs index eab9f5a..169df79 100644 --- a/test-suite/tests/parser.rs +++ b/test-suite/tests/parser.rs @@ -491,7 +491,10 @@ fn number_underscores() { fn bad_underscores() { bad!("foo = 0_", "invalid number at line 1 column 7"); bad!("foo = 0__0", "invalid number at line 1 column 7"); - bad!("foo = __0", "invalid number at line 1 column 7"); + bad!( + "foo = __0", + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" + ); bad!("foo = 1_0_", "invalid number at line 1 column 7"); } @@ -537,14 +540,20 @@ fn booleans() { bad!( "foo = true2", - "failed to parse datetime for key `foo` at line 1 column 7" + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" + ); + bad!( + "foo = false2", + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" ); - bad!("foo = false2", "invalid number at line 1 column 7"); bad!( "foo = t1", - "failed to parse datetime for key `foo` at line 1 column 7" + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" + ); + bad!( + "foo = f2", + "invalid TOML value, did you mean to use a quoted string? at line 1 column 7" ); - bad!("foo = f2", "invalid number at line 1 column 7"); } #[test] -- cgit v1.2.3