Fix inline table loading errors (#381)

Fixes #379 #380
This commit is contained in:
x-hgg-x
2020-05-04 19:13:55 +02:00
committed by GitHub
parent d05497900e
commit f1ba6388fb
3 changed files with 153 additions and 31 deletions
+13 -14
View File
@@ -239,7 +239,8 @@ func TestLocalDateTime(t *testing.T) {
Minute: 32,
Second: 0,
Nanosecond: 0,
}},
},
},
})
}
@@ -257,7 +258,8 @@ func TestLocalDateTimeNano(t *testing.T) {
Minute: 32,
Second: 0,
Nanosecond: 999999000,
}},
},
},
})
}
@@ -677,7 +679,7 @@ func TestInlineTableUnterminated(t *testing.T) {
func TestInlineTableCommaExpected(t *testing.T) {
_, err := Load("foo = {hello = 53 test = foo}")
if err.Error() != "(1, 19): comma expected between fields in inline table" {
if err.Error() != "(1, 19): unexpected token type in inline table: no value can start with t" {
t.Error("Bad error message:", err.Error())
}
}
@@ -691,7 +693,7 @@ func TestInlineTableCommaStart(t *testing.T) {
func TestInlineTableDoubleComma(t *testing.T) {
_, err := Load("foo = {hello = 53,, foo = 17}")
if err.Error() != "(1, 19): need field between two commas in inline table" {
if err.Error() != "(1, 19): unexpected token type in inline table: keys cannot contain , character" {
t.Error("Bad error message:", err.Error())
}
}
@@ -928,10 +930,8 @@ func TestTomlValueStringRepresentation(t *testing.T) {
{"hello world", "\"hello world\""},
{"\b\t\n\f\r\"\\", "\"\\b\\t\\n\\f\\r\\\"\\\\\""},
{"\x05", "\"\\u0005\""},
{time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC),
"1979-05-27T07:32:00Z"},
{[]interface{}{"gamma", "delta"},
"[\"gamma\",\"delta\"]"},
{time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC), "1979-05-27T07:32:00Z"},
{[]interface{}{"gamma", "delta"}, "[\"gamma\",\"delta\"]"},
{nil, ""},
} {
result, err := tomlValueStringRepresentation(item.Value, "", "", false)
@@ -1061,7 +1061,7 @@ func TestInvalidFloatParsing(t *testing.T) {
}
_, err = Load("a=_1_2")
if err.Error() != "(1, 3): cannot start number with underscore" {
if err.Error() != "(1, 3): no value can start with _" {
t.Error("Bad error message:", err.Error())
}
}
@@ -1125,11 +1125,10 @@ The quick brown \
the lazy dog."""
str3 = """\
The quick brown \
fox jumps over \
the lazy dog.\
"""`)
The quick brown \
fox jumps over \
the lazy dog.\
"""`)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}