From 2a9df8afb951592252d5319c646fdd99ec9891c3 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 28 Jul 2019 16:56:22 +0000 Subject: Fully expand error messages in tests --- test-suite/tests/parser.rs | 252 ++++++++++++++++++++++++++++----------------- 1 file changed, 160 insertions(+), 92 deletions(-) (limited to 'test-suite/tests/parser.rs') diff --git a/test-suite/tests/parser.rs b/test-suite/tests/parser.rs index 56f559d..97fe286 100644 --- a/test-suite/tests/parser.rs +++ b/test-suite/tests/parser.rs @@ -3,15 +3,12 @@ extern crate toml; use toml::Value; macro_rules! bad { - ($s:expr, $msg:expr) => {{ - match $s.parse::() { - Ok(s) => panic!("successfully parsed as {}", s), - Err(e) => { - let e = e.to_string(); - assert!(e.contains($msg), "error: {}", e); - } + ($toml:expr, $msg:expr) => { + match $toml.parse::() { + Ok(s) => panic!("parsed to: {:#?}", s), + Err(e) => assert_eq!(e.to_string(), $msg), } - }}; + }; } #[test] @@ -189,13 +186,22 @@ name = "plantain" #[test] fn stray_cr() { - "\r".parse::().unwrap_err(); - "a = [ \r ]".parse::().unwrap_err(); - "a = \"\"\"\r\"\"\"".parse::().unwrap_err(); - "a = \"\"\"\\ \r \"\"\"".parse::().unwrap_err(); - "a = '''\r'''".parse::().unwrap_err(); - "a = '\r'".parse::().unwrap_err(); - "a = \"\r\"".parse::().unwrap_err(); + bad!("\r", "unexpected character found: `\\r` at line 1"); + bad!("a = [ \r ]", "unexpected character found: `\\r` at line 1"); + bad!( + "a = \"\"\"\r\"\"\"", + "invalid character in string: `\\r` at line 1" + ); + bad!( + "a = \"\"\"\\ \r \"\"\"", + "invalid escape character in string: ` ` at line 1" + ); + bad!( + "a = '''\r'''", + "invalid character in string: `\\r` at line 1" + ); + bad!("a = '\r'", "invalid character in string: `\\r` at line 1"); + bad!("a = \"\r\"", "invalid character in string: `\\r` at line 1"); } #[test] @@ -224,32 +230,32 @@ fn literal_eats_crlf() { #[test] fn string_no_newline() { - "a = \"\n\"".parse::().unwrap_err(); - "a = '\n'".parse::().unwrap_err(); + bad!("a = \"\n\"", "newline in string found at line 1"); + bad!("a = '\n'", "newline in string found at line 1"); } #[test] fn bad_leading_zeros() { - "a = 00".parse::().unwrap_err(); - "a = -00".parse::().unwrap_err(); - "a = +00".parse::().unwrap_err(); - "a = 00.0".parse::().unwrap_err(); - "a = -00.0".parse::().unwrap_err(); - "a = +00.0".parse::().unwrap_err(); - "a = 9223372036854775808".parse::().unwrap_err(); - "a = -9223372036854775809".parse::().unwrap_err(); + bad!("a = 00", "invalid number at line 1"); + bad!("a = -00", "invalid number at line 1"); + bad!("a = +00", "invalid number at line 1"); + bad!("a = 00.0", "invalid number at line 1"); + bad!("a = -00.0", "invalid number at line 1"); + bad!("a = +00.0", "invalid number at line 1"); + bad!("a = 9223372036854775808", "invalid number at line 1"); + bad!("a = -9223372036854775809", "invalid number at line 1"); } #[test] fn bad_floats() { - "a = 0.".parse::().unwrap_err(); - "a = 0.e".parse::().unwrap_err(); - "a = 0.E".parse::().unwrap_err(); - "a = 0.0E".parse::().unwrap_err(); - "a = 0.0e".parse::().unwrap_err(); - "a = 0.0e-".parse::().unwrap_err(); - "a = 0.0e+".parse::().unwrap_err(); - "a = 0.0e+00".parse::().unwrap_err(); + bad!("a = 0.", "invalid number at line 1"); + bad!("a = 0.e", "invalid number at line 1"); + bad!("a = 0.E", "invalid number at line 1"); + bad!("a = 0.0E", "invalid number at line 1"); + bad!("a = 0.0e", "invalid number at line 1"); + bad!("a = 0.0e-", "invalid number at line 1"); + bad!("a = 0.0e+", "invalid number at line 1"); + bad!("a = 0.0e+00", "invalid number at line 1"); } #[test] @@ -310,37 +316,67 @@ fn bare_key_names() { #[test] fn bad_keys() { - "key\n=3".parse::().unwrap_err(); - "key=\n3".parse::().unwrap_err(); - "key|=3".parse::().unwrap_err(); - "\"\"=3".parse::().unwrap_err(); - "=3".parse::().unwrap_err(); - "\"\"|=3".parse::().unwrap_err(); - "\"\n\"|=3".parse::().unwrap_err(); - "\"\r\"|=3".parse::().unwrap_err(); - "''''''=3".parse::().unwrap_err(); - "\"\"\"\"\"\"=3".parse::().unwrap_err(); - "'''key'''=3".parse::().unwrap_err(); - "\"\"\"key\"\"\"=3".parse::().unwrap_err(); + bad!("key\n=3", "expected an equals, found a newline at line 1"); + bad!("key=\n3", "expected a value, found a newline at line 1"); + bad!("key|=3", "unexpected character found: `|` at line 1"); + bad!("\"\"=3", "empty table key found at line 1"); + bad!("=3", "expected a table key, found an equals at line 1"); + bad!("\"\"|=3", "empty table key found at line 1"); + bad!("\"\n\"|=3", "newline in string found at line 1"); + bad!("\"\r\"|=3", "invalid character in string: `\\r` at line 1"); + bad!( + "''''''=3", + "multiline strings are not allowed for key at line 1" + ); + bad!( + "\"\"\"\"\"\"=3", + "multiline strings are not allowed for key at line 1" + ); + bad!( + "'''key'''=3", + "multiline strings are not allowed for key at line 1" + ); + bad!( + "\"\"\"key\"\"\"=3", + "multiline strings are not allowed for key at line 1" + ); } #[test] fn bad_table_names() { - "[]".parse::().unwrap_err(); - "[.]".parse::().unwrap_err(); - "[\"\".\"\"]".parse::().unwrap_err(); - "[a.]".parse::().unwrap_err(); - "[\"\"]".parse::().unwrap_err(); - "[!]".parse::().unwrap_err(); - "[\"\n\"]".parse::().unwrap_err(); - "[a.b]\n[a.\"b\"]".parse::().unwrap_err(); - "[']".parse::().unwrap_err(); - "[''']".parse::().unwrap_err(); - "['''''']".parse::().unwrap_err(); - "['''foo''']".parse::().unwrap_err(); - "[\"\"\"bar\"\"\"]".parse::().unwrap_err(); - "['\n']".parse::().unwrap_err(); - "['\r\n']".parse::().unwrap_err(); + bad!( + "[]", + "expected a table key, found a right bracket at line 1" + ); + bad!("[.]", "expected a table key, found a period at line 1"); + bad!("[\"\".\"\"]", "empty table key found at line 1"); + bad!( + "[a.]", + "expected a table key, found a right bracket at line 1" + ); + bad!("[\"\"]", "empty table key found at line 1"); + bad!("[!]", "unexpected character found: `!` at line 1"); + bad!("[\"\n\"]", "newline in string found at line 1"); + bad!( + "[a.b]\n[a.\"b\"]", + "redefinition of table `a.b` for key `a.b` at line 2" + ); + bad!("[']", "unterminated string at line 1"); + bad!("[''']", "unterminated string at line 1"); + bad!( + "['''''']", + "multiline strings are not allowed for key at line 1" + ); + bad!( + "['''foo''']", + "multiline strings are not allowed for key at line 1" + ); + bad!( + "[\"\"\"bar\"\"\"]", + "multiline strings are not allowed for key at line 1" + ); + bad!("['\n']", "newline in string found at line 1"); + bad!("['\r\n']", "newline in string found at line 1"); } #[test] @@ -365,7 +401,7 @@ fn table_names() { #[test] fn invalid_bare_numeral() { - "4".parse::().unwrap_err(); + bad!("4", "expected an equals, found eof at line 1"); } #[test] @@ -375,11 +411,19 @@ fn inline_tables() { "a = { b = 1 }".parse::().unwrap(); "a = {a=1,b=2}".parse::().unwrap(); "a = {a=1,b=2,c={}}".parse::().unwrap(); - "a = {a=1,}".parse::().unwrap_err(); - "a = {,}".parse::().unwrap_err(); - "a = {a=1,a=1}".parse::().unwrap_err(); - "a = {\n}".parse::().unwrap_err(); - "a = {".parse::().unwrap_err(); + + bad!( + "a = {a=1,}", + "expected a table key, found a right brace at line 1" + ); + bad!("a = {,}", "expected a table key, found a comma at line 1"); + bad!("a = {a=1,a=1}", "duplicate key: `a` for key `a`"); + bad!( + "a = {\n}", + "expected a table key, found a newline at line 1" + ); + bad!("a = {", "expected a table key, found eof at line 1"); + "a = {a=[\n]}".parse::().unwrap(); "a = {\"a\"=[\n]}".parse::().unwrap(); "a = [\n{},\n{},\n]".parse::().unwrap(); @@ -404,23 +448,32 @@ fn number_underscores() { #[test] fn bad_underscores() { - bad!("foo = 0_", "invalid number"); - bad!("foo = 0__0", "invalid number"); - bad!("foo = __0", "invalid number"); - bad!("foo = 1_0_", "invalid number"); + bad!("foo = 0_", "invalid number at line 1"); + bad!("foo = 0__0", "invalid number at line 1"); + bad!("foo = __0", "invalid number at line 1"); + bad!("foo = 1_0_", "invalid number at line 1"); } #[test] fn bad_unicode_codepoint() { - bad!("foo = \"\\uD800\"", "invalid escape value"); + bad!( + "foo = \"\\uD800\"", + "invalid escape value: `55296` at line 1" + ); } #[test] fn bad_strings() { - bad!("foo = \"\\uxx\"", "invalid hex escape"); - bad!("foo = \"\\u\"", "invalid hex escape"); - bad!("foo = \"\\", "unterminated"); - bad!("foo = '", "unterminated"); + bad!( + "foo = \"\\uxx\"", + "invalid hex escape character in string: `x` at line 1" + ); + bad!( + "foo = \"\\u\"", + "invalid hex escape character in string: `\\\"` at line 1" + ); + bad!("foo = \"\\", "unterminated string at line 1"); + bad!("foo = '", "unterminated string at line 1"); } #[test] @@ -441,10 +494,10 @@ fn booleans() { let table = "foo = false".parse::().unwrap(); assert_eq!(table["foo"].as_bool(), Some(false)); - assert!("foo = true2".parse::().is_err()); - assert!("foo = false2".parse::().is_err()); - assert!("foo = t1".parse::().is_err()); - assert!("foo = f2".parse::().is_err()); + bad!("foo = true2", "failed to parse datetime for key `foo`"); + bad!("foo = false2", "invalid number at line 1"); + bad!("foo = t1", "failed to parse datetime for key `foo`"); + bad!("foo = f2", "invalid number at line 1"); } #[test] @@ -485,7 +538,7 @@ fn bad_nesting() { [a.b] c = 2 ", - "duplicate key: `b`" + "duplicate key: `b` for key `a`" ); } @@ -499,7 +552,7 @@ fn bad_table_redefine() { foo=\"bar\" [a] ", - "redefinition of table `a`" + "redefinition of table `a` for key `a` at line 6" ); bad!( " @@ -508,7 +561,7 @@ fn bad_table_redefine() { b = { foo = \"bar\" } [a] ", - "redefinition of table `a`" + "redefinition of table `a` for key `a` at line 5" ); bad!( " @@ -516,7 +569,7 @@ fn bad_table_redefine() { b = {} [a.b] ", - "duplicate key: `b`" + "duplicate key: `b` for key `a`" ); bad!( @@ -525,7 +578,7 @@ fn bad_table_redefine() { b = {} [a] ", - "redefinition of table `a`" + "redefinition of table `a` for key `a` at line 4" ); } @@ -543,11 +596,26 @@ fn datetimes() { t!("2016-09-09T09:09:09.1Z"); t!("2016-09-09T09:09:09.2+10:00"); t!("2016-09-09T09:09:09.123456789-02:00"); - bad!("foo = 2016-09-09T09:09:09.Z", "failed to parse date"); - bad!("foo = 2016-9-09T09:09:09Z", "failed to parse date"); - bad!("foo = 2016-09-09T09:09:09+2:00", "failed to parse date"); - bad!("foo = 2016-09-09T09:09:09-2:00", "failed to parse date"); - bad!("foo = 2016-09-09T09:09:09Z-2:00", "failed to parse date"); + bad!( + "foo = 2016-09-09T09:09:09.Z", + "failed to parse datetime for key `foo`" + ); + bad!( + "foo = 2016-9-09T09:09:09Z", + "failed to parse datetime for key `foo`" + ); + bad!( + "foo = 2016-09-09T09:09:09+2:00", + "failed to parse datetime for key `foo`" + ); + bad!( + "foo = 2016-09-09T09:09:09-2:00", + "failed to parse datetime for key `foo`" + ); + bad!( + "foo = 2016-09-09T09:09:09Z-2:00", + "failed to parse datetime for key `foo`" + ); } #[test] @@ -557,7 +625,7 @@ fn require_newline_after_value() { r#" 0=""o=""m=""r=""00="0"q="""0"""e="""0""" "#, - "expected newline" + "expected newline, found an identifier at line 2" ); bad!( r#" @@ -566,13 +634,13 @@ fn require_newline_after_value() { 0="0"[[0000l0]] 0="0"l="0" "#, - "expected newline" + "expected newline, found a left bracket at line 3" ); bad!( r#" 0=[0]00=[0,0,0]t=["0","0","0"]s=[1000-00-00T00:00:00Z,2000-00-00T00:00:00Z] "#, - "expected newline" + "expected newline, found an identifier at line 2" ); bad!( r#" -- cgit v1.2.3 From 3d08775266eb1979956b03add38e6bd4824f521a Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Sun, 28 Jul 2019 17:40:49 +0000 Subject: Show "column" in Error messages --- test-suite/tests/parser.rs | 193 +++++++++++++++++++++++++++------------------ 1 file changed, 116 insertions(+), 77 deletions(-) (limited to 'test-suite/tests/parser.rs') diff --git a/test-suite/tests/parser.rs b/test-suite/tests/parser.rs index 97fe286..1a684c5 100644 --- a/test-suite/tests/parser.rs +++ b/test-suite/tests/parser.rs @@ -186,22 +186,31 @@ name = "plantain" #[test] fn stray_cr() { - bad!("\r", "unexpected character found: `\\r` at line 1"); - bad!("a = [ \r ]", "unexpected character found: `\\r` at line 1"); + bad!("\r", "unexpected character found: `\\r` at line 1 column 1"); + bad!( + "a = [ \r ]", + "unexpected character found: `\\r` at line 1 column 7" + ); bad!( "a = \"\"\"\r\"\"\"", - "invalid character in string: `\\r` at line 1" + "invalid character in string: `\\r` at line 1 column 8" ); bad!( "a = \"\"\"\\ \r \"\"\"", - "invalid escape character in string: ` ` at line 1" + "invalid escape character in string: ` ` at line 1 column 9" ); bad!( "a = '''\r'''", - "invalid character in string: `\\r` at line 1" + "invalid character in string: `\\r` at line 1 column 8" + ); + bad!( + "a = '\r'", + "invalid character in string: `\\r` at line 1 column 6" + ); + bad!( + "a = \"\r\"", + "invalid character in string: `\\r` at line 1 column 6" ); - bad!("a = '\r'", "invalid character in string: `\\r` at line 1"); - bad!("a = \"\r\"", "invalid character in string: `\\r` at line 1"); } #[test] @@ -230,32 +239,38 @@ fn literal_eats_crlf() { #[test] fn string_no_newline() { - bad!("a = \"\n\"", "newline in string found at line 1"); - bad!("a = '\n'", "newline in string found at line 1"); + bad!("a = \"\n\"", "newline in string found at line 1 column 6"); + bad!("a = '\n'", "newline in string found at line 1 column 6"); } #[test] fn bad_leading_zeros() { - bad!("a = 00", "invalid number at line 1"); - bad!("a = -00", "invalid number at line 1"); - bad!("a = +00", "invalid number at line 1"); - bad!("a = 00.0", "invalid number at line 1"); - bad!("a = -00.0", "invalid number at line 1"); - bad!("a = +00.0", "invalid number at line 1"); - bad!("a = 9223372036854775808", "invalid number at line 1"); - bad!("a = -9223372036854775809", "invalid number at line 1"); + bad!("a = 00", "invalid number at line 1 column 6"); + bad!("a = -00", "invalid number at line 1 column 7"); + bad!("a = +00", "invalid number at line 1 column 7"); + bad!("a = 00.0", "invalid number at line 1 column 6"); + bad!("a = -00.0", "invalid number at line 1 column 7"); + bad!("a = +00.0", "invalid number at line 1 column 7"); + bad!( + "a = 9223372036854775808", + "invalid number at line 1 column 5" + ); + bad!( + "a = -9223372036854775809", + "invalid number at line 1 column 5" + ); } #[test] fn bad_floats() { - bad!("a = 0.", "invalid number at line 1"); - bad!("a = 0.e", "invalid number at line 1"); - bad!("a = 0.E", "invalid number at line 1"); - bad!("a = 0.0E", "invalid number at line 1"); - bad!("a = 0.0e", "invalid number at line 1"); - bad!("a = 0.0e-", "invalid number at line 1"); - bad!("a = 0.0e+", "invalid number at line 1"); - bad!("a = 0.0e+00", "invalid number at line 1"); + bad!("a = 0.", "invalid number at line 1 column 7"); + bad!("a = 0.e", "invalid number at line 1 column 7"); + bad!("a = 0.E", "invalid number at line 1 column 7"); + bad!("a = 0.0E", "invalid number at line 1 column 5"); + bad!("a = 0.0e", "invalid number at line 1 column 5"); + bad!("a = 0.0e-", "invalid number at line 1 column 9"); + bad!("a = 0.0e+", "invalid number at line 1 column 5"); + bad!("a = 0.0e+00", "invalid number at line 1 column 11"); } #[test] @@ -316,29 +331,44 @@ fn bare_key_names() { #[test] fn bad_keys() { - bad!("key\n=3", "expected an equals, found a newline at line 1"); - bad!("key=\n3", "expected a value, found a newline at line 1"); - bad!("key|=3", "unexpected character found: `|` at line 1"); - bad!("\"\"=3", "empty table key found at line 1"); - bad!("=3", "expected a table key, found an equals at line 1"); - bad!("\"\"|=3", "empty table key found at line 1"); - bad!("\"\n\"|=3", "newline in string found at line 1"); - bad!("\"\r\"|=3", "invalid character in string: `\\r` at line 1"); + bad!( + "key\n=3", + "expected an equals, found a newline at line 1 column 4" + ); + bad!( + "key=\n3", + "expected a value, found a newline at line 1 column 5" + ); + bad!( + "key|=3", + "unexpected character found: `|` at line 1 column 4" + ); + bad!("\"\"=3", "empty table key found at line 1 column 1"); + bad!( + "=3", + "expected a table key, found an equals at line 1 column 1" + ); + bad!("\"\"|=3", "empty table key found at line 1 column 1"); + bad!("\"\n\"|=3", "newline in string found at line 1 column 2"); + bad!( + "\"\r\"|=3", + "invalid character in string: `\\r` at line 1 column 2" + ); bad!( "''''''=3", - "multiline strings are not allowed for key at line 1" + "multiline strings are not allowed for key at line 1 column 1" ); bad!( "\"\"\"\"\"\"=3", - "multiline strings are not allowed for key at line 1" + "multiline strings are not allowed for key at line 1 column 1" ); bad!( "'''key'''=3", - "multiline strings are not allowed for key at line 1" + "multiline strings are not allowed for key at line 1 column 1" ); bad!( "\"\"\"key\"\"\"=3", - "multiline strings are not allowed for key at line 1" + "multiline strings are not allowed for key at line 1 column 1" ); } @@ -346,37 +376,40 @@ fn bad_keys() { fn bad_table_names() { bad!( "[]", - "expected a table key, found a right bracket at line 1" + "expected a table key, found a right bracket at line 1 column 2" ); - bad!("[.]", "expected a table key, found a period at line 1"); - bad!("[\"\".\"\"]", "empty table key found at line 1"); + bad!( + "[.]", + "expected a table key, found a period at line 1 column 2" + ); + bad!("[\"\".\"\"]", "empty table key found at line 1 column 2"); bad!( "[a.]", - "expected a table key, found a right bracket at line 1" + "expected a table key, found a right bracket at line 1 column 4" ); - bad!("[\"\"]", "empty table key found at line 1"); - bad!("[!]", "unexpected character found: `!` at line 1"); - bad!("[\"\n\"]", "newline in string found at line 1"); + bad!("[\"\"]", "empty table key found at line 1 column 2"); + bad!("[!]", "unexpected character found: `!` at line 1 column 2"); + bad!("[\"\n\"]", "newline in string found at line 1 column 3"); bad!( "[a.b]\n[a.\"b\"]", - "redefinition of table `a.b` for key `a.b` at line 2" + "redefinition of table `a.b` for key `a.b` at line 2 column 1" ); - bad!("[']", "unterminated string at line 1"); - bad!("[''']", "unterminated string at line 1"); + bad!("[']", "unterminated string at line 1 column 2"); + bad!("[''']", "unterminated string at line 1 column 2"); bad!( "['''''']", - "multiline strings are not allowed for key at line 1" + "multiline strings are not allowed for key at line 1 column 2" ); bad!( "['''foo''']", - "multiline strings are not allowed for key at line 1" + "multiline strings are not allowed for key at line 1 column 2" ); bad!( "[\"\"\"bar\"\"\"]", - "multiline strings are not allowed for key at line 1" + "multiline strings are not allowed for key at line 1 column 2" ); - bad!("['\n']", "newline in string found at line 1"); - bad!("['\r\n']", "newline in string found at line 1"); + bad!("['\n']", "newline in string found at line 1 column 3"); + bad!("['\r\n']", "newline in string found at line 1 column 3"); } #[test] @@ -401,7 +434,7 @@ fn table_names() { #[test] fn invalid_bare_numeral() { - bad!("4", "expected an equals, found eof at line 1"); + bad!("4", "expected an equals, found eof at line 1 column 2"); } #[test] @@ -414,15 +447,21 @@ fn inline_tables() { bad!( "a = {a=1,}", - "expected a table key, found a right brace at line 1" + "expected a table key, found a right brace at line 1 column 10" + ); + bad!( + "a = {,}", + "expected a table key, found a comma at line 1 column 6" ); - bad!("a = {,}", "expected a table key, found a comma at line 1"); bad!("a = {a=1,a=1}", "duplicate key: `a` for key `a`"); bad!( "a = {\n}", - "expected a table key, found a newline at line 1" + "expected a table key, found a newline at line 1 column 6" + ); + bad!( + "a = {", + "expected a table key, found eof at line 1 column 6" ); - bad!("a = {", "expected a table key, found eof at line 1"); "a = {a=[\n]}".parse::().unwrap(); "a = {\"a\"=[\n]}".parse::().unwrap(); @@ -448,17 +487,17 @@ fn number_underscores() { #[test] fn bad_underscores() { - bad!("foo = 0_", "invalid number at line 1"); - bad!("foo = 0__0", "invalid number at line 1"); - bad!("foo = __0", "invalid number at line 1"); - bad!("foo = 1_0_", "invalid number at line 1"); + 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 = 1_0_", "invalid number at line 1 column 7"); } #[test] fn bad_unicode_codepoint() { bad!( "foo = \"\\uD800\"", - "invalid escape value: `55296` at line 1" + "invalid escape value: `55296` at line 1 column 9" ); } @@ -466,14 +505,14 @@ fn bad_unicode_codepoint() { fn bad_strings() { bad!( "foo = \"\\uxx\"", - "invalid hex escape character in string: `x` at line 1" + "invalid hex escape character in string: `x` at line 1 column 10" ); bad!( "foo = \"\\u\"", - "invalid hex escape character in string: `\\\"` at line 1" + "invalid hex escape character in string: `\\\"` at line 1 column 10" ); - bad!("foo = \"\\", "unterminated string at line 1"); - bad!("foo = '", "unterminated string at line 1"); + bad!("foo = \"\\", "unterminated string at line 1 column 7"); + bad!("foo = '", "unterminated string at line 1 column 7"); } #[test] @@ -495,9 +534,9 @@ fn booleans() { assert_eq!(table["foo"].as_bool(), Some(false)); bad!("foo = true2", "failed to parse datetime for key `foo`"); - bad!("foo = false2", "invalid number at line 1"); + bad!("foo = false2", "invalid number at line 1 column 7"); bad!("foo = t1", "failed to parse datetime for key `foo`"); - bad!("foo = f2", "invalid number at line 1"); + bad!("foo = f2", "invalid number at line 1 column 7"); } #[test] @@ -552,7 +591,7 @@ fn bad_table_redefine() { foo=\"bar\" [a] ", - "redefinition of table `a` for key `a` at line 6" + "redefinition of table `a` for key `a` at line 6 column 9" ); bad!( " @@ -561,7 +600,7 @@ fn bad_table_redefine() { b = { foo = \"bar\" } [a] ", - "redefinition of table `a` for key `a` at line 5" + "redefinition of table `a` for key `a` at line 5 column 9" ); bad!( " @@ -578,7 +617,7 @@ fn bad_table_redefine() { b = {} [a] ", - "redefinition of table `a` for key `a` at line 4" + "redefinition of table `a` for key `a` at line 4 column 9" ); } @@ -620,12 +659,12 @@ fn datetimes() { #[test] fn require_newline_after_value() { - bad!("0=0r=false", "invalid number at line 1"); + bad!("0=0r=false", "invalid number at line 1 column 3"); bad!( r#" 0=""o=""m=""r=""00="0"q="""0"""e="""0""" "#, - "expected newline, found an identifier at line 2" + "expected newline, found an identifier at line 2 column 5" ); bad!( r#" @@ -634,24 +673,24 @@ fn require_newline_after_value() { 0="0"[[0000l0]] 0="0"l="0" "#, - "expected newline, found a left bracket at line 3" + "expected newline, found a left bracket at line 3 column 6" ); bad!( r#" 0=[0]00=[0,0,0]t=["0","0","0"]s=[1000-00-00T00:00:00Z,2000-00-00T00:00:00Z] "#, - "expected newline, found an identifier at line 2" + "expected newline, found an identifier at line 2 column 6" ); bad!( r#" 0=0r0=0r=false "#, - "invalid number at line 2" + "invalid number at line 2 column 3" ); bad!( r#" 0=0r0=0r=falsefal=false "#, - "invalid number at line 2" + "invalid number at line 2 column 3" ); } -- cgit v1.2.3