From 8455b10eddee92292006c4437cdce39ceeda554d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Fernandes?= Date: Wed, 11 Feb 2026 11:49:40 +0000 Subject: [PATCH] test: regen toml-test tests targetting TOML v1.1.0 --- toml_testgen_support_test.go | 4 +- toml_testgen_test.go | 1662 +++++++++++++++++++++++----------- 2 files changed, 1156 insertions(+), 510 deletions(-) diff --git a/toml_testgen_support_test.go b/toml_testgen_support_test.go index 868fb7d..d278381 100644 --- a/toml_testgen_support_test.go +++ b/toml_testgen_support_test.go @@ -1,5 +1,5 @@ -//go:generate go run github.com/toml-lang/toml-test/cmd/toml-test@v1.6.0 -copy ./tests -//go:generate go run ./cmd/tomltestgen/main.go -r v1.6.0 -o toml_testgen_test.go +//go:generate go run github.com/toml-lang/toml-test/v2/cmd/toml-test@v2.1.0 copy -toml 1.1 ./tests +//go:generate go run ./cmd/tomltestgen/main.go -r v2.1.0 -o toml_testgen_test.go package toml_test diff --git a/toml_testgen_test.go b/toml_testgen_test.go index d060496..338edd5 100644 --- a/toml_testgen_test.go +++ b/toml_testgen_test.go @@ -1,17 +1,17 @@ -// Code generated by tomltestgen for toml-test ref v1.6.0 on 2025-10-22T16:33:06+11:00. DO NOT EDIT. +// Code generated by tomltestgen for toml-test ref v2.1.0 on 2026-02-11T11:39:31Z. DO NOT EDIT. package toml_test import ( "testing" ) -func TestTOMLTest_Invalid_Tests_Invalid_Array_DoubleComma1(t *testing.T) { - input := "double-comma-1 = [1,,2]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_DoubleComma01(t *testing.T) { + input := "double-comma-01 = [1,,2]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_DoubleComma2(t *testing.T) { - input := "double-comma-2 = [1,2,,]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_DoubleComma02(t *testing.T) { + input := "double-comma-02 = [1,2,,]\n" testgenInvalid(t, input) } @@ -25,97 +25,97 @@ func TestTOMLTest_Invalid_Tests_Invalid_Array_ExtendingTable(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_MissingSeparator1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Array_MissingSeparator01(t *testing.T) { input := "arrr = [true false]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_MissingSeparator2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Array_MissingSeparator02(t *testing.T) { input := "wrong = [ 1 2 3 ]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose1(t *testing.T) { - input := "no-close-1 = [ 1, 2, 3\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose01(t *testing.T) { + input := "no-close-01 = [ 1, 2, 3\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose2(t *testing.T) { - input := "no-close-2 = [1,\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose02(t *testing.T) { + input := "no-close-02 = [1,\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose3(t *testing.T) { - input := "no-close-3 = [42 #]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose03(t *testing.T) { + input := "no-close-03 = [42 #]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose4(t *testing.T) { - input := "no-close-4 = [{ key = 42\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose04(t *testing.T) { + input := "no-close-04 = [{ key = 42\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose5(t *testing.T) { - input := "no-close-5 = [{ key = 42}\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose05(t *testing.T) { + input := "no-close-05 = [{ key = 42}\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose6(t *testing.T) { - input := "no-close-6 = [{ key = 42 #}]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose06(t *testing.T) { + input := "no-close-06 = [{ key = 42 #}]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose7(t *testing.T) { - input := "no-close-7 = [{ key = 42} #]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose07(t *testing.T) { + input := "no-close-07 = [{ key = 42} #]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose8(t *testing.T) { - input := "no-close-8 = [\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoClose08(t *testing.T) { + input := "no-close-08 = [\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoCloseTable1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoCloseTable01(t *testing.T) { input := "x = [{ key = 42\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoCloseTable2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoCloseTable02(t *testing.T) { input := "x = [{ key = 42 #\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma1(t *testing.T) { - input := "no-comma-1 = [true false]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma01(t *testing.T) { + input := "no-comma-01 = [true false]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma2(t *testing.T) { - input := "no-comma-2 = [ 1 2 3 ]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma02(t *testing.T) { + input := "no-comma-02 = [ 1 2 3 ]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma3(t *testing.T) { - input := "no-comma-3 = [ 1 #,]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_NoComma03(t *testing.T) { + input := "no-comma-03 = [ 1 #,]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_OnlyComma1(t *testing.T) { - input := "only-comma-1 = [,]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_OnlyComma01(t *testing.T) { + input := "only-comma-01 = [,]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_OnlyComma2(t *testing.T) { - input := "only-comma-2 = [,,]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Array_OnlyComma02(t *testing.T) { + input := "only-comma-02 = [,,]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_Tables1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Array_Tables01(t *testing.T) { input := "# INVALID TOML DOC\nfruit = []\n\n[[fruit]] # Not allowed\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Array_Tables2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Array_Tables02(t *testing.T) { input := "# INVALID TOML DOC\n[[fruit]]\n name = \"apple\"\n\n [[fruit.variety]]\n name = \"red delicious\"\n\n # This table conflicts with the previous table\n [fruit.variety]\n name = \"granny smith\"\n" testgenInvalid(t, input) } @@ -285,6 +285,21 @@ func TestTOMLTest_Invalid_Tests_Invalid_Control_MultiUs(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Control_OnlyFf(t *testing.T) { + input := "\f" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Control_OnlyNull(t *testing.T) { + input := "\x00" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Control_OnlyVt(t *testing.T) { + input := "\v" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Control_RawmultiCr(t *testing.T) { input := "rawmulti-cr = '''null\r'''\n" testgenInvalid(t, input) @@ -365,6 +380,11 @@ func TestTOMLTest_Invalid_Tests_Invalid_Control_StringUs(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_DayZero(t *testing.T) { + input := "foo = 1997-09-00T09:09:09.09Z\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Datetime_Feb29(t *testing.T) { input := "\"not a leap year\" = 2100-02-29T15:15:15Z\n" testgenInvalid(t, input) @@ -405,6 +425,11 @@ func TestTOMLTest_Invalid_Tests_Invalid_Datetime_MonthUnder(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoDateTimeSep(t *testing.T) { + input := "foo = 1997-09-0909:09:09\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoLeadsMonth(t *testing.T) { input := "# Month \"7\" instead of \"07\"; the leading zero is required.\nno-leads = 1987-7-05T17:45:00Z\n" testgenInvalid(t, input) @@ -420,21 +445,78 @@ func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoLeads(t *testing.T) { testgenInvalid(t, input) } -// TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoSecs is removed because -// TOML v1.1.0 makes seconds optional in date-time values. - func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoT(t *testing.T) { input := "# No \"t\" or \"T\" between the date and time.\nno-t = 1987-07-0517:45:00Z\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_NoYearMonthSep(t *testing.T) { + input := "foo = 199709-09\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetMinusMinute1digit(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+09:9\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetMinusNoHourMinuteSep(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+0909\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetMinusNoHourMinute(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetMinusNoMinute(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+09\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetOverflowHour(t *testing.T) { input := "# Hour must be 00-24\nd = 1985-06-18 17:04:07+25:00\n" testgenInvalid(t, input) } func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetOverflowMinute(t *testing.T) { - input := "# Minute must be 00-59; we allow 60 too because some people do write offsets of\n# 60 minutes\nd = 1985-06-18 17:04:07+12:61\n" + input := "d = 1985-06-18 17:04:07+12:60\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetPlusMinute1digit(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+09:9\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetPlusNoHourMinuteSep(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+0909\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetPlusNoHourMinute(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OffsetPlusNoMinute(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.09+09\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OnlyT(t *testing.T) { + input := "foo = T\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OnlyTZ(t *testing.T) { + input := "foo = TZ\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_OnlyTdot(t *testing.T) { + input := "foo = T.\n" testgenInvalid(t, input) } @@ -443,11 +525,26 @@ func TestTOMLTest_Invalid_Tests_Invalid_Datetime_SecondOver(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_SecondTrailingDot(t *testing.T) { + input := "foo = 1997-09-09T09:09:09.\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_SecondTrailingDotz(t *testing.T) { + input := "foo = 2016-09-09T09:09:09.Z\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Datetime_TimeNoLeads(t *testing.T) { input := "# Leading 0 is always required.\nd = 2023-10-01T1:32:00Z\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Datetime_TrailingX(t *testing.T) { + input := "sign=2020-01-01x\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Datetime_Y10k(t *testing.T) { input := "# Maximum RFC3399 year is 9999.\nd = 10000-01-01 00:00:00z\n" testgenInvalid(t, input) @@ -463,6 +560,11 @@ func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8AtEnd(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InArray(t *testing.T) { + input := "# https://github.com/marzer/tomlplusplus/issues/100\nfl =[ [[[[[[[[[[[[[[[6\x80\x86\x00\x00\x00-6\u009f \x00" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InComment(t *testing.T) { input := "# \xc3\n" testgenInvalid(t, input) @@ -488,16 +590,21 @@ func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BadUtf8InString(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BomNotAtStart1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BomNotAtStart01(t *testing.T) { input := "bom-not-at-start \xff\xfd\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BomNotAtStart2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Encoding_BomNotAtStart02(t *testing.T) { input := "bom-not-at-start= \xff\xfd\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Encoding_IdeographicSpace(t *testing.T) { + input := "# First on next line is U+3000 IDEOGRAPHIC SPACE\n\u3000foo = \"bar\"\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Encoding_Utf16Bom(t *testing.T) { input := "\xfe\xff\x00#\x00 \x00U\x00T\x00F\x00-\x001\x006\x00 \x00w\x00i\x00t\x00h\x00 \x00B\x00O\x00M\x00\n" testgenInvalid(t, input) @@ -513,23 +620,38 @@ func TestTOMLTest_Invalid_Tests_Invalid_Encoding_Utf16Key(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_DoublePoint1(t *testing.T) { - input := "double-point-1 = 0..1\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_DoubleDot01(t *testing.T) { + input := "double-dot-01 = 0..1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_DoublePoint2(t *testing.T) { - input := "double-point-2 = 0.1.2\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_DoubleDot02(t *testing.T) { + input := "double-dot-02 = 0.1.2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDoubleE1(t *testing.T) { - input := "exp-double-e-1 = 1ee2\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDot01(t *testing.T) { + input := "exp-dot-01 = 1e2.3\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDoubleE2(t *testing.T) { - input := "exp-double-e-2 = 1e2e3\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDot02(t *testing.T) { + input := "exp-dot-02 = 1.e2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDot03(t *testing.T) { + input := "exp-dot-03 = 3.e+20\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDoubleE01(t *testing.T) { + input := "exp-double-e-01 = 1ee2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpDoubleE02(t *testing.T) { + input := "exp-double-e-02 = 1e2e3\n" testgenInvalid(t, input) } @@ -543,28 +665,13 @@ func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpLeadingUs(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpPoint1(t *testing.T) { - input := "exp-point-1 = 1e2.3\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpTrailingUs01(t *testing.T) { + input := "exp-trailing-us-01 = 1_e2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpPoint2(t *testing.T) { - input := "exp-point-2 = 1.e2\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpPoint3(t *testing.T) { - input := "exp-point-3 = 3.e+20\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpTrailingUs1(t *testing.T) { - input := "exp-trailing-us-1 = 1_e2\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpTrailingUs2(t *testing.T) { - input := "exp-trailing-us-2 = 1.2_e2\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_ExpTrailingUs02(t *testing.T) { + input := "exp-trailing-us-02 = 1.2_e2\n" testgenInvalid(t, input) } @@ -578,18 +685,18 @@ func TestTOMLTest_Invalid_Tests_Invalid_Float_InfCapital(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete1(t *testing.T) { - input := "inf-incomplete-1 = in\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete01(t *testing.T) { + input := "inf-incomplete-01 = in\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete2(t *testing.T) { - input := "inf-incomplete-2 = +in\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete02(t *testing.T) { + input := "inf-incomplete-02 = +in\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete3(t *testing.T) { - input := "inf-incomplete-3 = -in\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_InfIncomplete03(t *testing.T) { + input := "inf-incomplete-03 = -in\n" testgenInvalid(t, input) } @@ -598,18 +705,18 @@ func TestTOMLTest_Invalid_Tests_Invalid_Float_Inf_underscore(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingPointNeg(t *testing.T) { - input := "leading-point-neg = -.12345\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingDotNeg(t *testing.T) { + input := "leading-dot-neg = -.12345\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingPointPlus(t *testing.T) { - input := "leading-point-plus = +.12345\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingDotPlus(t *testing.T) { + input := "leading-dot-plus = +.12345\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingPoint(t *testing.T) { - input := "leading-point = .12345\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_LeadingDot(t *testing.T) { + input := "leading-dot = .12345\n" testgenInvalid(t, input) } @@ -638,18 +745,18 @@ func TestTOMLTest_Invalid_Tests_Invalid_Float_NanCapital(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete1(t *testing.T) { - input := "nan-incomplete-1 = na\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete01(t *testing.T) { + input := "nan-incomplete-01 = na\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete2(t *testing.T) { - input := "nan-incomplete-2 = +na\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete02(t *testing.T) { + input := "nan-incomplete-02 = +na\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete3(t *testing.T) { - input := "nan-incomplete-3 = -na\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_NanIncomplete03(t *testing.T) { + input := "nan-incomplete-03 = -na\n" testgenInvalid(t, input) } @@ -658,27 +765,57 @@ func TestTOMLTest_Invalid_Tests_Invalid_Float_Nan_underscore(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingPointMin(t *testing.T) { - input := "trailing-point-min = -1.\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingPointPlus(t *testing.T) { - input := "trailing-point-plus = +1.\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingPoint(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingDot01(t *testing.T) { input := "trailing-point = 1.\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUsExp1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingDot02(t *testing.T) { + input := "a = 1.\nb = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingDotMin(t *testing.T) { + input := "trailing-dot-min = -1.\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingDotPlus(t *testing.T) { + input := "trailing-dot-plus = +1.\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingDot(t *testing.T) { + input := "trailing-dot = 1.\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingExpDot(t *testing.T) { + input := "trailing-exp-dot = 0.e\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingExpMinus(t *testing.T) { + input := "trailing-exp-minus = 0.0e-\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingExpPlus(t *testing.T) { + input := "trailing-exp-plus = 0.0e+\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingExp(t *testing.T) { + input := "trailing-exp = 0.0E\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUsExp01(t *testing.T) { input := "trailing-us-exp-1 = 1_e2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUsExp2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUsExp02(t *testing.T) { input := "trailing-us-exp-2 = 1.2_e2\n" testgenInvalid(t, input) } @@ -688,13 +825,13 @@ func TestTOMLTest_Invalid_Tests_Invalid_Float_TrailingUs(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_UsAfterPoint(t *testing.T) { - input := "us-after-point = 1._2\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_UsAfterDot(t *testing.T) { + input := "us-after-dot = 1._2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Float_UsBeforePoint(t *testing.T) { - input := "us-before-point = 1_.2\n" +func TestTOMLTest_Invalid_Tests_Invalid_Float_UsBeforeDot(t *testing.T) { + input := "us-before-dot = 1_.2\n" testgenInvalid(t, input) } @@ -708,60 +845,57 @@ func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DoubleComma(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey01(t *testing.T) { input := "# Duplicate keys within an inline table are invalid\na={b=1, b=2}\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey02(t *testing.T) { input := "table1 = { table2.dupe = 1, table2.dupe = 2 }\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey03(t *testing.T) { input := "tbl = { fruit = { apple.color = \"red\" }, fruit.apple.texture = { smooth = true } }\n\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_DuplicateKey04(t *testing.T) { input := "tbl = { a.b = \"a_b\", a.b.c = \"a_b_c\" }\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty01(t *testing.T) { input := "t = {,}\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty02(t *testing.T) { input := "t = {,\n}\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Empty03(t *testing.T) { input := "t = {\n,\n}\n" testgenInvalid(t, input) } -// TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Linebreak1 through Linebreak4 -// are removed because TOML v1.1.0 allows newlines in inline tables. - -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoClose1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoClose01(t *testing.T) { input := "a={\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoClose2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoClose02(t *testing.T) { input := "a={b=1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoComma1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoComma01(t *testing.T) { input := "t = {x = 3 y = 4}\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoComma2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_NoComma02(t *testing.T) { input := "arrr = { comma-missing = true valid-toml = false }\n" testgenInvalid(t, input) } @@ -816,9 +950,6 @@ func TestTOMLTest_Invalid_Tests_Invalid_InlineTable_Overwrite10(t *testing.T) { testgenInvalid(t, input) } -// TestTOMLTest_Invalid_Tests_Invalid_InlineTable_TrailingComma is removed -// because TOML v1.1.0 allows trailing commas in inline tables. - func TestTOMLTest_Invalid_Tests_Invalid_Integer_CapitalBin(t *testing.T) { input := "capital-bin = 0B0\n" testgenInvalid(t, input) @@ -869,18 +1000,18 @@ func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidBin(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex1(t *testing.T) { - input := "invalid-hex-1 = 0xaafz\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex01(t *testing.T) { + input := "invalid-hex-01 = 0xaafz\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex2(t *testing.T) { - input := "invalid-hex-2 = 0xgabba00f1\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex02(t *testing.T) { + input := "invalid-hex-02 = 0xgabba00f1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex(t *testing.T) { - input := "invalid-hex = 0xaafz\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_InvalidHex03(t *testing.T) { + input := "a = 0x-1\n" testgenInvalid(t, input) } @@ -909,33 +1040,33 @@ func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingUs(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero1(t *testing.T) { - input := "leading-zero-1 = 01\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero01(t *testing.T) { + input := "leading-zero-01 = 01\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero2(t *testing.T) { - input := "leading-zero-2 = 00\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero02(t *testing.T) { + input := "leading-zero-02 = 00\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero3(t *testing.T) { - input := "leading-zero-3 = 0_0\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZero03(t *testing.T) { + input := "leading-zero-03 = 0_0\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign1(t *testing.T) { - input := "leading-zero-sign-1 = -01\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign01(t *testing.T) { + input := "leading-zero-sign-01 = -01\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign2(t *testing.T) { - input := "leading-zero-sign-2 = +01\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign02(t *testing.T) { + input := "leading-zero-sign-02 = +01\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign3(t *testing.T) { - input := "leading-zero-sign-3 = +0_1\n" +func TestTOMLTest_Invalid_Tests_Invalid_Integer_LeadingZeroSign03(t *testing.T) { + input := "leading-zero-sign-03 = +0_1\n" testgenInvalid(t, input) } @@ -1024,41 +1155,81 @@ func TestTOMLTest_Invalid_Tests_Invalid_Key_AfterValue(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_BareInvalidCharacter(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_BareInvalidCharacter01(t *testing.T) { + input := "! = 123\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_BareInvalidCharacter02(t *testing.T) { input := "bare!key = 123\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_DottedRedefineTable1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_Dot(t *testing.T) { + input := ". = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_Dotdot(t *testing.T) { + input := ".. = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_DottedRedefineTable01(t *testing.T) { input := "a = false\na.b = true\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_DottedRedefineTable2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_DottedRedefineTable02(t *testing.T) { input := "# Defined a.b as int\na.b = 1\n# Tries to access it as table: error\na.b.c = 2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys01(t *testing.T) { input := "name = \"Tom\"\nname = \"Pradyun\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys02(t *testing.T) { input := "dupe = false\ndupe = true\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys03(t *testing.T) { input := "spelling = \"favorite\"\n\"spelling\" = \"favourite\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys04(t *testing.T) { input := "spelling = \"favorite\"\n'spelling' = \"favourite\"\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys05(t *testing.T) { + input := "a = 1\n\"\\u0061\" = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys06(t *testing.T) { + input := "\"a'b\" = 1\n\"a\\u0027b\" = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys07(t *testing.T) { + input := "\"\" = 1\n\"\" = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys08(t *testing.T) { + input := "arr = [1]\narr = [2]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_DuplicateKeys09(t *testing.T) { + input := "tbl = {k=1}\ntbl = {kk=2}\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Key_Empty(t *testing.T) { input := " = 1\n" testgenInvalid(t, input) @@ -1079,36 +1250,106 @@ func TestTOMLTest_Invalid_Tests_Invalid_Key_Hash(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_MultilineKey01(t *testing.T) { + input := "\"\"\"key\"\"\" = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_MultilineKey02(t *testing.T) { + input := "'''key''' = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_MultilineKey03(t *testing.T) { + input := "\"\"\"key\"\"\" = \"\"\"v\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_MultilineKey04(t *testing.T) { + input := "'''key''' = '''v'''\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline01(t *testing.T) { input := "barekey\n = 1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline02(t *testing.T) { input := "\"quoted\nkey\" = 1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline03(t *testing.T) { input := "'quoted\nkey' = 1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline04(t *testing.T) { input := "\"\"\"long\nkey\"\"\" = 1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline5(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline05(t *testing.T) { input := "'''long\nkey''' = 1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_Newline06(t *testing.T) { + input := "key =\n1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol01(t *testing.T) { input := "a = 1 b = 2\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol02(t *testing.T) { + input := "0=0r=false\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol03(t *testing.T) { + input := "0=\"\"o=\"\"m=\"\"r=\"\"00=\"0\"q=\"\"\"0\"\"\"e=\"\"\"0\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol04(t *testing.T) { + input := "[[0000l0]]\n0=\"0\"[[0000l0]]\n0=\"0\"[[0000l0]]\n0=\"0\"l=\"0\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol05(t *testing.T) { + input := "0=[0]00=[0,0,0]t=[\"0\",\"0\",\"0\"]s=[1000-00-00T00:00:00Z,2000-00-00T00:00:00Z]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol06(t *testing.T) { + input := "0=0r0=0r=false\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_NoEol07(t *testing.T) { + input := "0=0r0=0r=falsefal=false\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_OnlyFloat(t *testing.T) { + input := "1.1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_OnlyInt(t *testing.T) { + input := "1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Key_OnlyStr(t *testing.T) { + input := "\"\"\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Key_OpenBracket(t *testing.T) { input := "[abc = 1\n" testgenInvalid(t, input) @@ -1119,12 +1360,12 @@ func TestTOMLTest_Invalid_Tests_Invalid_Key_PartialQuoted(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_QuotedUnclosed1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_QuotedUnclosed01(t *testing.T) { input := "\"key = x\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_QuotedUnclosed2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_QuotedUnclosed02(t *testing.T) { input := "\"key\n" testgenInvalid(t, input) } @@ -1154,56 +1395,61 @@ func TestTOMLTest_Invalid_Tests_Invalid_Key_StartDot(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals01(t *testing.T) { input := "key= = 1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals02(t *testing.T) { input := "a==1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_TwoEquals03(t *testing.T) { input := "a=b=1\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue01(t *testing.T) { input := "key\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue02(t *testing.T) { input := "key = \n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue03(t *testing.T) { input := "\"key\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue04(t *testing.T) { input := "\"key\" = \n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue5(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue05(t *testing.T) { input := "fs.fw\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue6(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue06(t *testing.T) { input := "fs.fw =\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue7(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Key_WithoutValue07(t *testing.T) { input := "fs.\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_Day1digit(t *testing.T) { + input := "foo = 1997-09-9\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_Feb29(t *testing.T) { input := "\"not a leap year\" = 2100-02-29\n" testgenInvalid(t, input) @@ -1254,6 +1500,11 @@ func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_Y10k(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_LocalDate_Year3digits(t *testing.T) { + input := "foo = 199-09-09\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_Feb29(t *testing.T) { input := "\"not a leap year\" = 2100-02-29T15:15:15\n" testgenInvalid(t, input) @@ -1304,9 +1555,6 @@ func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_NoLeads(t *testing.T) { testgenInvalid(t, input) } -// TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_NoSecs is removed because -// TOML v1.1.0 makes seconds optional in date-time values. - func TestTOMLTest_Invalid_Tests_Invalid_LocalDatetime_NoT(t *testing.T) { input := "# No \"t\" or \"T\" between the date and time.\nno-t = 1987-07-0517:45:00\n" testgenInvalid(t, input) @@ -1337,64 +1585,71 @@ func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_MinuteOver(t *testing.T) { testgenInvalid(t, input) } -// TestTOMLTest_Invalid_Tests_Invalid_LocalTime_NoSecs is removed because -// TOML v1.1.0 makes seconds optional in time values. - func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_SecondOver(t *testing.T) { input := "# time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap second\n# ; rules\nd = 00:00:61\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TimeNoLeads2(t *testing.T) { - input := "# Leading 0 is always required.\nd = 01:32:0\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TimeNoLeads(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TimeNoLeads01(t *testing.T) { input := "# Leading 0 is always required.\nd = 1:32:00\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Spec_InlineTable20(t *testing.T) { - input := "[product]\ntype = { name = \"Nail\" }\ntype.edible = false # INVALID\n" +func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TimeNoLeads02(t *testing.T) { + input := "# Leading 0 is always required.\nd = 01:32:0\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Spec_InlineTable30(t *testing.T) { - input := "[product]\ntype.name = \"Nail\"\ntype = { edible = false } # INVALID\n" +func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TrailingDot(t *testing.T) { + input := "t = 12:13:14.\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Spec_KeyValuePair1(t *testing.T) { - input := "key = # INVALID\n" +func TestTOMLTest_Invalid_Tests_Invalid_LocalTime_TrailingDotdot(t *testing.T) { + input := "t = 12:13:14..\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Spec_Keys2(t *testing.T) { - input := "= \"no key name\" # INVALID\n\"\" = \"blank\" # VALID but discouraged\n'' = 'blank' # VALID but discouraged\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_Spec_String40(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common160(t *testing.T) { input := "str4 = \"\"\"Here are two quotation marks: \"\". Simple enough.\"\"\"\nstr5 = \"\"\"Here are three quotation marks: \"\"\".\"\"\" # INVALID\nstr5 = \"\"\"Here are three quotation marks: \"\"\\\".\"\"\"\nstr6 = \"\"\"Here are fifteen quotation marks: \"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\".\"\"\"\n\n# \"This,\" she said, \"is just a pointless statement.\"\nstr7 = \"\"\"\"This,\" she said, \"is just a pointless statement.\"\"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Spec_String70(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common190(t *testing.T) { input := "quot15 = '''Here are fifteen quotation marks: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"'''\n\napos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID\napos15 = \"Here are fifteen apostrophes: '''''''''''''''\"\n\n# 'That,' she said, 'is still pointless.'\nstr = ''''That,' she said, 'is still pointless.''''\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Spec_Table90(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common2(t *testing.T) { + input := "key = # INVALID\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common460(t *testing.T) { input := "[fruit]\napple.color = \"red\"\napple.taste.sweet = true\n\n[fruit.apple] # INVALID\n# [fruit.apple.taste] # INVALID\n\n[fruit.apple.texture] # you can add sub-tables\nsmooth = true\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Spec_Table91(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common461(t *testing.T) { input := "[fruit]\napple.color = \"red\"\napple.taste.sweet = true\n\n# [fruit.apple] # INVALID\n[fruit.apple.taste] # INVALID\n\n[fruit.apple.texture] # you can add sub-tables\nsmooth = true\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common490(t *testing.T) { + input := "[product]\ntype = { name = \"Nail\" }\ntype.edible = false # INVALID\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common5(t *testing.T) { + input := "= \"no key name\" # INVALID\n\"\"\"key\"\"\" = \"not allowed\" # INVALID\n\"\" = \"blank\" # VALID but discouraged\n'' = 'blank' # VALID but discouraged\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Spec1_1_0_Common500(t *testing.T) { + input := "[product]\ntype.name = \"Nail\"\ntype = { edible = false } # INVALID\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_String_BadByteEscape(t *testing.T) { input := "naughty = \"\\xAg\"\n" testgenInvalid(t, input) @@ -1405,42 +1660,52 @@ func TestTOMLTest_Invalid_Tests_Invalid_String_BadConcat(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape01(t *testing.T) { input := "invalid-escape = \"This string has a bad \\a escape character.\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape02(t *testing.T) { input := "invalid-escape = \"This string has a bad \\ escape character.\"\n\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape03(t *testing.T) { input := "backslash = \"\\\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc1(t *testing.T) { - input := "bad-hex-esc-1 = \"\\x0g\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape04(t *testing.T) { + input := "a = \"a \\\\\\ b\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc2(t *testing.T) { - input := "bad-hex-esc-2 = \"\\xG0\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadEscape05(t *testing.T) { + input := "a = \"a \\\\\\\\\\ b\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc3(t *testing.T) { - input := "bad-hex-esc-3 = \"\\x\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc01(t *testing.T) { + input := "bad-hex-esc-01 = \"\\x0g\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc4(t *testing.T) { - input := "bad-hex-esc-4 = \"\\x 50\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc02(t *testing.T) { + input := "bad-hex-esc-02 = \"\\xG0\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc5(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc03(t *testing.T) { + input := "bad-hex-esc-03 = \"\\x\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc04(t *testing.T) { + input := "bad-hex-esc-04 = \"\\x 50\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BadHexEsc05(t *testing.T) { input := "bad-hex-esc-5 = \"\\x 50\"\n" testgenInvalid(t, input) } @@ -1455,50 +1720,82 @@ func TestTOMLTest_Invalid_Tests_Invalid_String_BadSlashEscape(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc1(t *testing.T) { - input := "bad-uni-esc-1 = \"val\\ue\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc01(t *testing.T) { + input := "bad-uni-esc-01 = \"val\\ue\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc2(t *testing.T) { - input := "bad-uni-esc-2 = \"val\\Ux\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc02(t *testing.T) { + input := "bad-uni-esc-02 = \"val\\Ux\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc3(t *testing.T) { - input := "bad-uni-esc-3 = \"val\\U0000000\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc03(t *testing.T) { + input := "bad-uni-esc-03 = \"val\\U0000000\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc4(t *testing.T) { - input := "bad-uni-esc-4 = \"val\\U0000\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc04(t *testing.T) { + input := "bad-uni-esc-04 = \"val\\U0000\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc5(t *testing.T) { - input := "bad-uni-esc-5 = \"val\\Ugggggggg\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc05(t *testing.T) { + input := "bad-uni-esc-05 = \"val\\Ugggggggg\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc6(t *testing.T) { - input := "bad-uni-esc-6 = \"This string contains a non scalar unicode codepoint \\uD801\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc06(t *testing.T) { + input := "bad-uni-esc-06 = \"This string contains a non scalar unicode codepoint \\uD801\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc7(t *testing.T) { - input := "bad-uni-esc-7 = \"\\uabag\"\n" +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEsc07(t *testing.T) { + input := "bad-uni-esc-07 = \"\\uabag\"\n" testgenInvalid(t, input) } -// TestTOMLTest_Invalid_Tests_Invalid_String_BasicByteEscapes is removed because -// TOML v1.1.0 adds \xHH escape sequence support. +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEscMl01(t *testing.T) { + input := "bad-uni-esc-ml-01 = \"\"\"val\\ue\"\"\"\n" + testgenInvalid(t, input) +} -func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEscMl02(t *testing.T) { + input := "bad-uni-esc-ml-02 = \"\"\"val\\Ux\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEscMl03(t *testing.T) { + input := "bad-uni-esc-ml-03 = \"\"\"val\\U0000000\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEscMl04(t *testing.T) { + input := "bad-uni-esc-ml-04 = \"\"\"val\\U0000\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEscMl05(t *testing.T) { + input := "bad-uni-esc-ml-05 = \"\"\"val\\Ugggggggg\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEscMl06(t *testing.T) { + input := "bad-uni-esc-ml-06 = \"\"\"This string contains a non scalar unicode codepoint \\uD801\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BadUniEscMl07(t *testing.T) { + input := "bad-uni-esc-ml-07 = \"\"\"\\uabag\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape01(t *testing.T) { input := "a = \"\"\"\\UFFFFFFFF\"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineOutOfRangeUnicodeEscape02(t *testing.T) { input := "a = \"\"\"\\U00D80000\"\"\"\n" testgenInvalid(t, input) } @@ -1513,12 +1810,12 @@ func TestTOMLTest_Invalid_Tests_Invalid_String_BasicMultilineUnknownEscape(t *te testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BasicOutOfRangeUnicodeEscape1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BasicOutOfRangeUnicodeEscape01(t *testing.T) { input := "a = \"\\UFFFFFFFF\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_BasicOutOfRangeUnicodeEscape2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_BasicOutOfRangeUnicodeEscape02(t *testing.T) { input := "a = \"\\U00D80000\"\n" testgenInvalid(t, input) } @@ -1528,121 +1825,201 @@ func TestTOMLTest_Invalid_Tests_Invalid_String_BasicUnknownEscape(t *testing.T) testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_LiteralMultilineQuotes1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_LiteralMultilineQuotes01(t *testing.T) { input := "a = '''6 apostrophes: ''''''\n\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_LiteralMultilineQuotes2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_LiteralMultilineQuotes02(t *testing.T) { input := "a = '''15 apostrophes: ''''''''''''''''''\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_String_MissingQuotesArray(t *testing.T) { + input := "name = [value]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_MissingQuotesInlineTable(t *testing.T) { + input := "name = { key = value }\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_String_MissingQuotes(t *testing.T) { input := "name = value\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape01(t *testing.T) { input := "k = \"\"\"t\\a\"\"\"\n\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape02(t *testing.T) { input := "# \\ is not a valid escape.\nk = \"\"\"t\\ t\"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape03(t *testing.T) { input := "# \\ is not a valid escape.\nk = \"\"\"t\\ \"\"\"\n\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineBadEscape04(t *testing.T) { input := "backslash = \"\"\"\\\"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineEscapeSpace1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineEscapeSpace01(t *testing.T) { input := "a = \"\"\"\n foo \\ \\n\n bar\"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineEscapeSpace2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineEscapeSpace02(t *testing.T) { input := "bee = \"\"\"\nhee \\\n\ngee \\ \"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose01(t *testing.T) { input := "invalid = '''\n this will fail\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose02(t *testing.T) { input := "x='''\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose03(t *testing.T) { input := "not-closed= '''\ndiibaa\nblibae ete\neteta\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineLitNoClose04(t *testing.T) { input := "bee = '''\nhee\ngee ''\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose01(t *testing.T) { input := "invalid = \"\"\"\n this will fail\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose02(t *testing.T) { input := "x=\"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose03(t *testing.T) { input := "not-closed= \"\"\"\ndiibaa\nblibae ete\neteta\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose04(t *testing.T) { input := "bee = \"\"\"\nhee\ngee \"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose5(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineNoClose05(t *testing.T) { input := "bee = \"\"\"\nhee\ngee\\\t \n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineQuotes1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_MultilineQuotes01(t *testing.T) { input := "a = \"\"\"6 quotes: \"\"\"\"\"\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose01(t *testing.T) { input := "no-ending-quote = \"One time, at band camp\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose02(t *testing.T) { input := "\"a-string\".must-be = \"closed\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose03(t *testing.T) { input := "no-ending-quote = 'One time, at band camp\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose04(t *testing.T) { input := "'a-string'.must-be = 'closed\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose05(t *testing.T) { + input := "# No newline at end\nno-ending-quote = \"One time, at band camp" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose06(t *testing.T) { + input := "# No newline at end\n\"a-string\".must-be = \"closed" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose07(t *testing.T) { + input := "# No newline at end\nno-ending-quote = 'One time, at band camp" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose08(t *testing.T) { + input := "# No newline at end\n'a-string'.must-be = 'closed" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose09(t *testing.T) { + input := "# Newlines are not allowed in \"-strings.\na = \"\n\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoClose10(t *testing.T) { + input := "# Newlines are not allowed in '-strings.\na = '\n'\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen01(t *testing.T) { + input := "s = a\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen02(t *testing.T) { + input := "a = [a\"]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen03(t *testing.T) { + input := "s = a'\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen04(t *testing.T) { + input := "a = [a']\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen05(t *testing.T) { + input := "a = a\"\"\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen06(t *testing.T) { + input := "a = [a\"\"\"]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen07(t *testing.T) { + input := "a = a'''\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_String_NoOpen08(t *testing.T) { + input := "a = [a''']\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_String_TextAfterString(t *testing.T) { input := "string = \"Is there life after strings?\" No.\n" testgenInvalid(t, input) @@ -1653,21 +2030,41 @@ func TestTOMLTest_Invalid_Tests_Invalid_String_WrongClose(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendToArrayWithDottedKeys(t *testing.T) { - input := "[[a.b]]\n\n[a]\nb.y = 2\n" - testgenInvalid(t, input) -} - -func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys01(t *testing.T) { input := "# First a.b.c defines a table: a.b.c = {z=9}\n#\n# Then we define a.b.c.t = \"str\" to add a str to the above table, making it:\n#\n# a.b.c = {z=9, t=\"...\"}\n#\n# While this makes sense, logically, it was decided this is not valid TOML as\n# it's too confusing/convoluted.\n# \n# See: https://github.com/toml-lang/toml/issues/846\n# https://github.com/toml-lang/toml/pull/859\n\n[a.b.c]\n z = 9\n\n[a]\n b.c.t = \"Using dotted keys to add to [a.b.c] after explicitly defining it above is not allowed\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys02(t *testing.T) { input := "# This is the same issue as in injection-1.toml, except that nests one level\n# deeper. See that file for a more complete description.\n\n[a.b.c.d]\n z = 9\n\n[a]\n b.c.d.k.t = \"Using dotted keys to add to [a.b.c.d] after explicitly defining it above is not allowed\"\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys03(t *testing.T) { + input := "[[a.b]]\n\n[a]\nb.y = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys04(t *testing.T) { + input := "[dependencies.foo]\nversion = \"0.16\"\n\n[dependencies]\nlibc = \"0.2\"\n\n[dependencies]\nrand = \"0.3.14\"\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys05(t *testing.T) { + input := "a.b.c = 1\na.b = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys06(t *testing.T) { + input := "a = 1\na.b = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_AppendWithDottedKeys07(t *testing.T) { + input := "a = {k1 = 1, k1.name = \"joe\"}\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayEmpty(t *testing.T) { input := "[[]]\nname = \"Born to Run\"\n" testgenInvalid(t, input) @@ -1678,48 +2075,93 @@ func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayImplicit(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose01(t *testing.T) { input := "[[albums]\nname = \"Born to Run\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose02(t *testing.T) { input := "[[closing-bracket.missing]\nblaa=2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyDottedArray(t *testing.T) { - input := "[fruit]\napple.color = \"red\"\n\n[[fruit.apple]]\n" +func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose03(t *testing.T) { + input := "[[a\n[[b]]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyDottedTable(t *testing.T) { - input := "[fruit]\napple.color = \"red\"\n\n[fruit.apple] # INVALID\n" +func TestTOMLTest_Invalid_Tests_Invalid_Table_ArrayNoClose04(t *testing.T) { + input := "[[a\nb = 2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyDottedTable2(t *testing.T) { - input := "[fruit]\napple.taste.sweet = true\n\n[fruit.apple.taste] # INVALID\n" +func TestTOMLTest_Invalid_Tests_Invalid_Table_BareInvalidCharacter01(t *testing.T) { + input := "[!]\nk = 123\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKeyTable(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_BareInvalidCharacter02(t *testing.T) { + input := "[bare!key]\nk = 123\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_Dot(t *testing.T) { + input := "[.]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_Dotdot(t *testing.T) { + input := "[..]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey01(t *testing.T) { + input := "[a]\nb = 1\n\n[a]\nc = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey02(t *testing.T) { input := "[fruit]\ntype = \"apple\"\n\n[fruit.type]\napple = \"yes\"\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateTableArray(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey03(t *testing.T) { + input := "[fruit]\napple.color = \"red\"\n\n[[fruit.apple]]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey04(t *testing.T) { + input := "[fruit]\napple.color = \"red\"\n\n[fruit.apple] # INVALID\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey05(t *testing.T) { + input := "[fruit]\napple.taste.sweet = true\n\n[fruit.apple.taste] # INVALID\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey06(t *testing.T) { input := "[tbl]\n[[tbl]]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateTableArray2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey07(t *testing.T) { input := "[[tbl]]\n[tbl]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_Duplicate(t *testing.T) { - input := "[a]\nb = 1\n\n[a]\nc = 2\n" +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey08(t *testing.T) { + input := "[a]\nb = { c = 2, d = {} }\n[a.b]\nc = 2\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey09(t *testing.T) { + input := "[a]\nfoo=\"bar\"\n[a.b]\nfoo=\"bar\"\n[a]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_DuplicateKey10(t *testing.T) { + input := "a = []\n[[a.b]]\n" testgenInvalid(t, input) } @@ -1743,6 +2185,16 @@ func TestTOMLTest_Invalid_Tests_Invalid_Table_Llbrace(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Table_MultilineKey01(t *testing.T) { + input := "[\"\"\"tbl\"\"\"]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_MultilineKey02(t *testing.T) { + input := "['''tbl''']\nk = 1\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Table_NestedBracketsClose(t *testing.T) { input := "[a]b]\nzyx = 42\n" testgenInvalid(t, input) @@ -1753,31 +2205,76 @@ func TestTOMLTest_Invalid_Tests_Invalid_Table_NestedBracketsOpen(t *testing.T) { testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_Newline01(t *testing.T) { + input := "[tbl\n]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_Newline02(t *testing.T) { + input := "[\"tbl\n\"]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_Newline03(t *testing.T) { + input := "[\"tbl\"\n]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_Newline04(t *testing.T) { + input := "[tbl.\n]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_Newline05(t *testing.T) { + input := "[tbl\n.sub]\nk = 1\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose01(t *testing.T) { input := "[where will it end\nname = value\n\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose02(t *testing.T) { input := "[closing-bracket.missingö\nblaa=2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose03(t *testing.T) { input := "[\"where will it end]\nname = value\n\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose4(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose04(t *testing.T) { input := "[\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose5(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose05(t *testing.T) { input := "[fwfw.wafw\n" testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose06(t *testing.T) { + input := "[a\n[b]\n[c\n[d]\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose07(t *testing.T) { + input := "[']\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose08(t *testing.T) { + input := "[''']\n" + testgenInvalid(t, input) +} + +func TestTOMLTest_Invalid_Tests_Invalid_Table_NoClose09(t *testing.T) { + input := "[\"where will it end\"\"]\nname = value\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Table_OverwriteArrayInParent(t *testing.T) { input := "[[parent-table.arr]]\n[parent-table]\nnot-arr = 1\narr = 2\n" testgenInvalid(t, input) @@ -1793,17 +2290,17 @@ func TestTOMLTest_Invalid_Tests_Invalid_Table_OverwriteWithDeepTable(t *testing. testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine1(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine01(t *testing.T) { input := "# Define b as int, and try to use it as a table: error\n[a]\nb = 1\n\n[a.b]\nc = 2\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine2(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine02(t *testing.T) { input := "[t1]\nt2.t3.v = 0\n[t1.t2]\n" testgenInvalid(t, input) } -func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine3(t *testing.T) { +func TestTOMLTest_Invalid_Tests_Invalid_Table_Redefine03(t *testing.T) { input := "[t1]\nt2.t3.v = 0\n[t1.t2.t3]\n" testgenInvalid(t, input) } @@ -1823,6 +2320,11 @@ func TestTOMLTest_Invalid_Tests_Invalid_Table_TextAfterTable(t *testing.T) { testgenInvalid(t, input) } +func TestTOMLTest_Invalid_Tests_Invalid_Table_TrailingDot(t *testing.T) { + input := "[a.]\n" + testgenInvalid(t, input) +} + func TestTOMLTest_Invalid_Tests_Invalid_Table_Whitespace(t *testing.T) { input := "[invalid key]\n" testgenInvalid(t, input) @@ -1840,8 +2342,8 @@ func TestTOMLTest_Valid_Array_ArraySubtables(t *testing.T) { } func TestTOMLTest_Valid_Array_Array(t *testing.T) { - input := "ints = [1, 2, 3, ]\nfloats = [1.1, 2.1, 3.1]\nstrings = [\"a\", \"b\", \"c\"]\ndates = [\n 1987-07-05T17:45:00Z,\n 1979-05-27T07:32:00Z,\n 2006-06-01T11:00:00Z,\n]\ncomments = [\n 1,\n 2, #this is ok\n]\n" - jsonRef := "{\n \"comments\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n \"dates\": [\n {\"type\": \"datetime\", \"value\": \"1987-07-05T17:45:00Z\"},\n {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00Z\"},\n {\"type\": \"datetime\", \"value\": \"2006-06-01T11:00:00Z\"}\n ],\n \"floats\": [\n {\"type\": \"float\", \"value\": \"1.1\"},\n {\"type\": \"float\", \"value\": \"2.1\"},\n {\"type\": \"float\", \"value\": \"3.1\"}\n ],\n \"ints\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"strings\": [\n {\"type\": \"string\", \"value\": \"a\"},\n {\"type\": \"string\", \"value\": \"b\"},\n {\"type\": \"string\", \"value\": \"c\"}\n ]\n}\n" + input := "ints = [1, 2, 3, ]\nfloats = [1.1, 2.1, 3.1]\nstrings = [\"a\", \"b\", \"c\"]\ndates = [\n\t1987-07-05T17:45:00Z,\n\t1979-05-27T07:32:00,\n\t2006-06-01,\n\t11:00:00,\n]\ncomments = [\n 1,\n 2, #this is ok\n]\n" + jsonRef := "{\n \"comments\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n \"dates\": [\n {\"type\": \"datetime\", \"value\": \"1987-07-05T17:45:00Z\"},\n {\"type\": \"datetime-local\", \"value\": \"1979-05-27T07:32:00\"},\n {\"type\": \"date-local\", \"value\": \"2006-06-01\"},\n {\"type\": \"time-local\", \"value\": \"11:00:00\"}\n ],\n \"floats\": [\n {\"type\": \"float\", \"value\": \"1.1\"},\n {\"type\": \"float\", \"value\": \"2.1\"},\n {\"type\": \"float\", \"value\": \"3.1\"}\n ],\n \"ints\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"strings\": [\n {\"type\": \"string\", \"value\": \"a\"},\n {\"type\": \"string\", \"value\": \"b\"},\n {\"type\": \"string\", \"value\": \"c\"}\n ]\n}\n" testgenValid(t, input, jsonRef) } @@ -1917,30 +2419,30 @@ func TestTOMLTest_Valid_Array_OpenParentTable(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Array_StringQuoteComma2(t *testing.T) { - input := "title = [ \" \\\", \",]\n" - jsonRef := "{\n \"title\": [{\"type\": \"string\", \"value\": \" \\\", \"}]\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Array_StringQuoteComma(t *testing.T) { +func TestTOMLTest_Valid_Array_StringQuoteComma01(t *testing.T) { input := "title = [\n\"Client: \\\"XXXX\\\", Job: XXXX\",\n\"Code: XXXX\"\n]\n" jsonRef := "{\n \"title\": [\n {\"type\": \"string\", \"value\": \"Client: \\\"XXXX\\\", Job: XXXX\"},\n {\"type\": \"string\", \"value\": \"Code: XXXX\"}\n ]\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Array_StringWithComma2(t *testing.T) { - input := "title = [\n\"\"\"Client: XXXX,\nJob: XXXX\"\"\",\n\"Code: XXXX\"\n]\n" - jsonRef := "{\n \"title\": [\n {\"type\": \"string\", \"value\": \"Client: XXXX,\\nJob: XXXX\"},\n {\"type\": \"string\", \"value\": \"Code: XXXX\"}\n ]\n}\n" +func TestTOMLTest_Valid_Array_StringQuoteComma02(t *testing.T) { + input := "title = [ \" \\\", \",]\n" + jsonRef := "{\n \"title\": [{\"type\": \"string\", \"value\": \" \\\", \"}]\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Array_StringWithComma(t *testing.T) { +func TestTOMLTest_Valid_Array_StringWithComma01(t *testing.T) { input := "title = [\n\"Client: XXXX, Job: XXXX\",\n\"Code: XXXX\"\n]\n" jsonRef := "{\n \"title\": [\n {\"type\": \"string\", \"value\": \"Client: XXXX, Job: XXXX\"},\n {\"type\": \"string\", \"value\": \"Code: XXXX\"}\n ]\n}\n" testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_Array_StringWithComma02(t *testing.T) { + input := "title = [\n\"\"\"Client: XXXX,\nJob: XXXX\"\"\",\n\"Code: XXXX\"\n]\n" + jsonRef := "{\n \"title\": [\n {\"type\": \"string\", \"value\": \"Client: XXXX,\\nJob: XXXX\"},\n {\"type\": \"string\", \"value\": \"Code: XXXX\"}\n ]\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_Array_Strings(t *testing.T) { input := "string_array = [ \"all\", 'strings', \"\"\"are the same\"\"\", '''type''']\n" jsonRef := "{\n \"string_array\": [\n {\"type\": \"string\", \"value\": \"all\"},\n {\"type\": \"string\", \"value\": \"strings\"},\n {\"type\": \"string\", \"value\": \"are the same\"},\n {\"type\": \"string\", \"value\": \"type\"}\n ]\n}\n" @@ -1984,8 +2486,8 @@ func TestTOMLTest_Valid_Comment_AtEof2(t *testing.T) { } func TestTOMLTest_Valid_Comment_Everywhere(t *testing.T) { - input := "# Top comment.\n # Top comment.\n# Top comment.\n\n# [no-extraneous-groups-please]\n\n[group] # Comment\nanswer = 42 # Comment\n# no-extraneous-keys-please = 999\n# Inbetween comment.\nmore = [ # Comment\n # What about multiple # comments?\n # Can you handle it?\n #\n # Evil.\n# Evil.\n 42, 42, # Comments within arrays are fun.\n # What about multiple # comments?\n # Can you handle it?\n #\n # Evil.\n# Evil.\n# ] Did I fool you?\n] # Hopefully not.\n\n# Make sure the space between the datetime and \"#\" isn't lexed.\ndt = 1979-05-27T07:32:12-07:00 # c\nd = 1979-05-27 # Comment\n" - jsonRef := "{\n \"group\": {\n \"answer\": {\"type\": \"integer\", \"value\": \"42\"},\n \"d\": {\"type\": \"date-local\", \"value\": \"1979-05-27\"},\n \"dt\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:12-07:00\"},\n \"more\": [\n {\"type\": \"integer\", \"value\": \"42\"},\n {\"type\": \"integer\", \"value\": \"42\"}\n ]\n }\n}\n" + input := "# Top comment.\n # Top comment.\n# Top comment.\n\n# [no-extraneous-groups-please]\n\n[group] # Comment\nanswer = 42 # Comment\n# no-extraneous-keys-please = 999\n# Inbetween comment.\nmore = [ # Comment\n # What about multiple # comments?\n # Can you handle it?\n #\n # Evil.\n# Evil.\n 42, 42, # Comments within arrays are fun.\n # What about multiple # comments?\n # Can you handle it?\n #\n # Evil.\n# Evil.\n# ] Did I fool you?\n] # Hopefully not.\n\n# Make sure the space between the datetime and \"#\" isn't lexed.\ndt = 1979-05-27T07:32:12-07:00 # c\nd = 1979-05-27 # Comment\n\n[[aot]] # Comment\nk = 98 # Comment\n[[aot]]# Comment\nk = 99# Comment\n" + jsonRef := "{\n \"aot\": [\n {\n \"k\": {\"type\": \"integer\", \"value\": \"98\"}\n },\n {\n \"k\": {\"type\": \"integer\", \"value\": \"99\"}\n }\n ],\n \"group\": {\n \"answer\": {\"type\": \"integer\", \"value\": \"42\"},\n \"d\": {\"type\": \"date-local\", \"value\": \"1979-05-27\"},\n \"dt\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:12-07:00\"},\n \"more\": [\n {\"type\": \"integer\", \"value\": \"42\"},\n {\"type\": \"integer\", \"value\": \"42\"}\n ]\n }\n}\n" testgenValid(t, input, jsonRef) } @@ -2019,6 +2521,12 @@ func TestTOMLTest_Valid_Datetime_Edge(t *testing.T) { testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_Datetime_InvalidDateInString(t *testing.T) { + input := "s = '2020-01-01x'\n" + jsonRef := "{\n \"s\": {\"type\": \"string\", \"value\": \"2020-01-01x\"}\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_Datetime_LeapYear(t *testing.T) { input := "2000-datetime = 2000-02-29 15:15:15Z\n2000-datetime-local = 2000-02-29 15:15:15\n2000-date = 2000-02-29\n\n2024-datetime = 2024-02-29 15:15:15Z\n2024-datetime-local = 2024-02-29 15:15:15\n2024-date = 2024-02-29\n" jsonRef := "{\n \"2000-date\": {\"type\": \"date-local\", \"value\": \"2000-02-29\"},\n \"2000-datetime\": {\"type\": \"datetime\", \"value\": \"2000-02-29T15:15:15Z\"},\n \"2000-datetime-local\": {\"type\": \"datetime-local\", \"value\": \"2000-02-29T15:15:15\"},\n \"2024-date\": {\"type\": \"date-local\", \"value\": \"2024-02-29\"},\n \"2024-datetime\": {\"type\": \"datetime\", \"value\": \"2024-02-29T15:15:15Z\"},\n \"2024-datetime-local\": {\"type\": \"datetime-local\", \"value\": \"2024-02-29T15:15:15\"}\n}\n" @@ -2049,6 +2557,12 @@ func TestTOMLTest_Valid_Datetime_Milliseconds(t *testing.T) { testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_Datetime_NoSeconds(t *testing.T) { + input := "# Seconds are optional in date-time and time.\nwithout-seconds-1 = 13:37\nwithout-seconds-2 = 1979-05-27 07:32Z\nwithout-seconds-3 = 1979-05-27 07:32-07:00\nwithout-seconds-4 = 1979-05-27T07:32\n" + jsonRef := "{\n \"without-seconds-1\": {\"type\": \"time-local\", \"value\": \"13:37:00\"},\n \"without-seconds-2\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00Z\"},\n \"without-seconds-3\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00-07:00\"},\n \"without-seconds-4\": {\"type\": \"datetime-local\", \"value\": \"1979-05-27T07:32:00\"}\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_Datetime_Timezone(t *testing.T) { input := "utc = 1987-07-05T17:45:56Z\npdt = 1987-07-05T17:45:56-05:00\nnzst = 1987-07-05T17:45:56+12:00\nnzdt = 1987-07-05T17:45:56+13:00 # DST\n" jsonRef := "{\n \"nzdt\": {\"type\": \"datetime\", \"value\": \"1987-07-05T17:45:56+13:00\"},\n \"nzst\": {\"type\": \"datetime\", \"value\": \"1987-07-05T17:45:56+12:00\"},\n \"pdt\": {\"type\": \"datetime\", \"value\": \"1987-07-05T17:45:56-05:00\"},\n \"utc\": {\"type\": \"datetime\", \"value\": \"1987-07-05T17:45:56Z\"}\n}\n" @@ -2097,15 +2611,21 @@ func TestTOMLTest_Valid_Float_Zero(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_ArrayValues(t *testing.T) { - input := "# \"No newlines are allowed between the curly braces unless they are valid within\n# a value\"\n\na = { a = [\n]}\n\nb = { a = [\n\t\t1,\n\t\t2,\n\t], b = [\n\t\t3,\n\t\t4,\n\t]}\n" - jsonRef := "{\n \"a\": {\"a\": []},\n \"b\": {\n \"a\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n \"b\": [\n {\"type\": \"integer\", \"value\": \"3\"},\n {\"type\": \"integer\", \"value\": \"4\"}\n ]\n }\n}\n" +func TestTOMLTest_Valid_InlineTable_Array01(t *testing.T) { + input := "arr = [ {'a'= 1}, {'a'= 2} ]\n\npeople = [{first_name = \"Bruce\", last_name = \"Springsteen\"},\n {first_name = \"Eric\", last_name = \"Clapton\"},\n {first_name = \"Bob\", last_name = \"Seger\"}]\n" + jsonRef := "{\n \"arr\": [\n {\n \"a\": {\"type\": \"integer\", \"value\": \"1\"}\n },\n {\n \"a\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n ],\n \"people\": [\n {\n \"first_name\": {\"type\": \"string\", \"value\": \"Bruce\"},\n \"last_name\": {\"type\": \"string\", \"value\": \"Springsteen\"}\n },\n {\n \"first_name\": {\"type\": \"string\", \"value\": \"Eric\"},\n \"last_name\": {\"type\": \"string\", \"value\": \"Clapton\"}\n },\n {\n \"first_name\": {\"type\": \"string\", \"value\": \"Bob\"},\n \"last_name\": {\"type\": \"string\", \"value\": \"Seger\"}\n }\n ]\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_Array(t *testing.T) { - input := "arr = [ {'a'= 1}, {'a'= 2} ]\n\npeople = [{first_name = \"Bruce\", last_name = \"Springsteen\"},\n {first_name = \"Eric\", last_name = \"Clapton\"},\n {first_name = \"Bob\", last_name = \"Seger\"}]\n" - jsonRef := "{\n \"arr\": [\n {\n \"a\": {\"type\": \"integer\", \"value\": \"1\"}\n },\n {\n \"a\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n ],\n \"people\": [\n {\n \"first_name\": {\"type\": \"string\", \"value\": \"Bruce\"},\n \"last_name\": {\"type\": \"string\", \"value\": \"Springsteen\"}\n },\n {\n \"first_name\": {\"type\": \"string\", \"value\": \"Eric\"},\n \"last_name\": {\"type\": \"string\", \"value\": \"Clapton\"}\n },\n {\n \"first_name\": {\"type\": \"string\", \"value\": \"Bob\"},\n \"last_name\": {\"type\": \"string\", \"value\": \"Seger\"}\n }\n ]\n}\n" +func TestTOMLTest_Valid_InlineTable_Array02(t *testing.T) { + input := "# \"No newlines are allowed between the curly braces unless they are valid within\n# a value\"\n\na = { a = [\n]}\n" + jsonRef := "{\n \"a\": {\"a\": []}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_InlineTable_Array03(t *testing.T) { + input := "b = { a = [\n\t\t1,\n\t\t2,\n\t], b = [\n\t\t3,\n\t\t4,\n\t]}\n" + jsonRef := "{\n \"b\": {\n \"a\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n \"b\": [\n {\"type\": \"integer\", \"value\": \"3\"},\n {\"type\": \"integer\", \"value\": \"4\"}\n ]\n }\n}\n" testgenValid(t, input, jsonRef) } @@ -2133,43 +2653,43 @@ func TestTOMLTest_Valid_InlineTable_InlineTable(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_KeyDotted1(t *testing.T) { +func TestTOMLTest_Valid_InlineTable_KeyDotted01(t *testing.T) { input := "a = { a.b = 1 }\nb = { \"a\".\"b\" = 1 }\nc = { a . b = 1 }\nd = { 'a' . \"b\" = 1 }\ne = {a.b=1}\n" jsonRef := "{\n \"a\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n \"b\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n \"c\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n \"d\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n \"e\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_KeyDotted2(t *testing.T) { +func TestTOMLTest_Valid_InlineTable_KeyDotted02(t *testing.T) { input := "many.dots.here.dot.dot.dot = {a.b.c = 1, a.b.d = 2}\n" jsonRef := "{\n \"many\": {\n \"dots\": {\n \"here\": {\n \"dot\": {\n \"dot\": {\n \"dot\": {\n \"a\": {\n \"b\": {\n \"c\": {\"type\": \"integer\", \"value\": \"1\"},\n \"d\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n }\n }\n }\n }\n }\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_KeyDotted3(t *testing.T) { +func TestTOMLTest_Valid_InlineTable_KeyDotted03(t *testing.T) { input := "[tbl]\na.b.c = {d.e=1}\n\n[tbl.x]\na.b.c = {d.e=1}\n" jsonRef := "{\n \"tbl\": {\n \"a\": {\n \"b\": {\n \"c\": {\n \"d\": {\n \"e\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }\n }\n },\n \"x\": {\n \"a\": {\n \"b\": {\n \"c\": {\n \"d\": {\n \"e\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }\n }\n }\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_KeyDotted4(t *testing.T) { +func TestTOMLTest_Valid_InlineTable_KeyDotted04(t *testing.T) { input := "[[arr]]\nt = {a.b=1}\nT = {a.b=1}\n\n[[arr]]\nt = {a.b=2}\nT = {a.b=2}\n" jsonRef := "{\n \"arr\": [\n {\n \"T\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n \"t\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }\n },\n {\n \"T\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n },\n \"t\": {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n }\n }\n ]\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_KeyDotted5(t *testing.T) { +func TestTOMLTest_Valid_InlineTable_KeyDotted05(t *testing.T) { input := "arr-1 = [{a.b = 1}]\narr-2 = [\"str\", {a.b = 1}]\n\narr-3 = [{a.b = 1}, {a.b = 2}]\narr-4 = [\"str\", {a.b = 1}, {a.b = 2}]\n" jsonRef := "{\n \"arr-1\": [{\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }],\n \"arr-2\": [\n {\"type\": \"string\", \"value\": \"str\"},\n {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }\n ],\n \"arr-3\": [\n {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n }\n ],\n \"arr-4\": [\n {\"type\": \"string\", \"value\": \"str\"},\n {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n {\n \"a\": {\n \"b\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n }\n ]\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_KeyDotted6(t *testing.T) { +func TestTOMLTest_Valid_InlineTable_KeyDotted06(t *testing.T) { input := "top.dot.dot = [\n\t{dot.dot.dot = 1},\n\t{dot.dot.dot = 2},\n]\n" jsonRef := "{\n \"top\": {\n \"dot\": {\n \"dot\": [\n {\n \"dot\": {\n \"dot\": {\n \"dot\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }\n },\n {\n \"dot\": {\n \"dot\": {\n \"dot\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n }\n }\n ]\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_InlineTable_KeyDotted7(t *testing.T) { +func TestTOMLTest_Valid_InlineTable_KeyDotted07(t *testing.T) { input := "arr = [\n\t{a.b = [{c.d = 1}]}\n]\n" jsonRef := "{\n \"arr\": [{\n \"a\": {\"b\": [{\n \"c\": {\n \"d\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n }]}\n }]\n}\n" testgenValid(t, input, jsonRef) @@ -2187,6 +2707,18 @@ func TestTOMLTest_Valid_InlineTable_Nest(t *testing.T) { testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_InlineTable_NewlineComment(t *testing.T) { + input := "# Identical to newline.toml, but with comments that shouldn't affect the\n# results.\n\ntrailing-comma-1 = {#comment\n\t# comment\n\tc = 1,#comment\n\t#comment\n}#comment\ntrailing-comma-2 = { c = 1, }#comment\n\ntbl-1 = {#comment\n\thello = \"world\",#comment\n\t1 = 2,#comment\n\tarr = [1,#comment\n\t 2,#comment\n\t 3,#comment\n\t ],#comment\n\ttbl = {#comment\n\t\t k = 1,#comment\n\t}#comment\n}#comment\n\ntbl-2 = {#comment\n\tk = \"\"\"\n\tHello\n\t\"\"\"#comment\n}#comment\n" + jsonRef := "{\n \"tbl-1\": {\n \"1\": {\"type\": \"integer\", \"value\": \"2\"},\n \"hello\": {\"type\": \"string\", \"value\": \"world\"},\n \"arr\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"tbl\": {\n \"k\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n \"tbl-2\": {\n \"k\": {\"type\": \"string\", \"value\": \"\\tHello\\n\\t\"}\n },\n \"trailing-comma-1\": {\n \"c\": {\"type\": \"integer\", \"value\": \"1\"}\n },\n \"trailing-comma-2\": {\n \"c\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_InlineTable_Newline(t *testing.T) { + input := "# TOML 1.1 supports newlines in inline tables and trailing commas.\n\ntrailing-comma-1 = {\n\tc = 1,\n}\ntrailing-comma-2 = { c = 1, }\n\ntbl-1 = {\n\thello = \"world\",\n\t1 = 2,\n\tarr = [1,\n\t 2,\n\t 3,\n\t ],\n\ttbl = {\n\t\t k = 1,\n\t}\n}\n\ntbl-2 = {\n\tk = \"\"\"\n\tHello\n\t\"\"\"\n}\n\nno-newline-before-brace = {\na = 1,\nb = 2}\n\nno-newline-before-brace-with-comma = {\na = 1,\nb = 2,}\n" + jsonRef := "{\n \"no-newline-before-brace\": {\n \"a\": {\"type\": \"integer\", \"value\": \"1\"},\n \"b\": {\"type\": \"integer\", \"value\": \"2\"}\n },\n \"no-newline-before-brace-with-comma\": {\n \"a\": {\"type\": \"integer\", \"value\": \"1\"},\n \"b\": {\"type\": \"integer\", \"value\": \"2\"}\n },\n \"tbl-1\": {\n \"1\": {\"type\": \"integer\", \"value\": \"2\"},\n \"hello\": {\"type\": \"string\", \"value\": \"world\"},\n \"arr\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"tbl\": {\n \"k\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n },\n \"tbl-2\": {\n \"k\": {\"type\": \"string\", \"value\": \"\\tHello\\n\\t\"}\n },\n \"trailing-comma-1\": {\n \"c\": {\"type\": \"integer\", \"value\": \"1\"}\n },\n \"trailing-comma-2\": {\n \"c\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_InlineTable_Spaces(t *testing.T) { input := "# https://github.com/toml-lang/toml-test/issues/146\nclap-1 = { version = \"4\" , features = [\"derive\", \"cargo\"] }\n\n# Contains some literal tabs!\nclap-2 = { version = \"4\"\t \t,\t \tfeatures = [ \"derive\" \t , \t \"cargo\" ] , nest = { \t \"a\" = 'x' , \t 'b' = [ 1.5 , 9.0 ] } }\n" jsonRef := "{\n \"clap-1\": {\n \"version\": {\"type\": \"string\", \"value\": \"4\"},\n \"features\": [\n {\"type\": \"string\", \"value\": \"derive\"},\n {\"type\": \"string\", \"value\": \"cargo\"}\n ]\n },\n \"clap-2\": {\n \"version\": {\"type\": \"string\", \"value\": \"4\"},\n \"features\": [\n {\"type\": \"string\", \"value\": \"derive\"},\n {\"type\": \"string\", \"value\": \"cargo\"}\n ],\n \"nest\": {\n \"a\": {\"type\": \"string\", \"value\": \"x\"},\n \"b\": [\n {\"type\": \"float\", \"value\": \"1.5\"},\n {\"type\": \"float\", \"value\": \"9\"}\n ]\n }\n }\n}\n" @@ -2241,25 +2773,25 @@ func TestTOMLTest_Valid_Key_CaseSensitive(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Dotted1(t *testing.T) { +func TestTOMLTest_Valid_Key_Dotted01(t *testing.T) { input := "name.first = \"Arthur\"\n\"name\".'last' = \"Dent\"\n\nmany.dots.dot.dot.dot = 42\n" jsonRef := "{\n \"many\": {\n \"dots\": {\n \"dot\": {\n \"dot\": {\n \"dot\": {\"type\": \"integer\", \"value\": \"42\"}\n }\n }\n }\n },\n \"name\": {\n \"first\": {\"type\": \"string\", \"value\": \"Arthur\"},\n \"last\": {\"type\": \"string\", \"value\": \"Dent\"}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Dotted2(t *testing.T) { +func TestTOMLTest_Valid_Key_Dotted02(t *testing.T) { input := "# Note: this file contains literal tab characters.\n\n# Space are ignored, and key parts can be quoted.\ncount.a = 1\ncount . b = 2\n\"count\".\"c\" = 3\n\"count\" . \"d\" = 4\n'count'.'e' = 5\n'count' . 'f' = 6\n\"count\".'g' = 7\n\"count\" . 'h' = 8\ncount.'i' = 9\ncount \t.\t 'j'\t = 10\n\"count\".k = 11\n\"count\" . l = 12\n" jsonRef := "{\n \"count\": {\n \"a\": {\"type\": \"integer\", \"value\": \"1\"},\n \"b\": {\"type\": \"integer\", \"value\": \"2\"},\n \"c\": {\"type\": \"integer\", \"value\": \"3\"},\n \"d\": {\"type\": \"integer\", \"value\": \"4\"},\n \"e\": {\"type\": \"integer\", \"value\": \"5\"},\n \"f\": {\"type\": \"integer\", \"value\": \"6\"},\n \"g\": {\"type\": \"integer\", \"value\": \"7\"},\n \"h\": {\"type\": \"integer\", \"value\": \"8\"},\n \"i\": {\"type\": \"integer\", \"value\": \"9\"},\n \"j\": {\"type\": \"integer\", \"value\": \"10\"},\n \"k\": {\"type\": \"integer\", \"value\": \"11\"},\n \"l\": {\"type\": \"integer\", \"value\": \"12\"}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Dotted3(t *testing.T) { +func TestTOMLTest_Valid_Key_Dotted03(t *testing.T) { input := "top.key = 1\n\n[tbl]\na.b.c = 42.666\n\n[a.few.dots]\npolka.dot = \"again?\"\npolka.dance-with = \"Dot\"\n\n" jsonRef := "{\n \"a\": {\n \"few\": {\n \"dots\": {\n \"polka\": {\n \"dance-with\": {\"type\": \"string\", \"value\": \"Dot\"},\n \"dot\": {\"type\": \"string\", \"value\": \"again?\"}\n }\n }\n }\n },\n \"tbl\": {\n \"a\": {\n \"b\": {\n \"c\": {\"type\": \"float\", \"value\": \"42.666\"}\n }\n }\n },\n \"top\": {\n \"key\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Dotted4(t *testing.T) { +func TestTOMLTest_Valid_Key_Dotted04(t *testing.T) { input := "top.key = 1\n\n[[arr]]\na.b.c=1\na.b.d=2\n\n[[arr]]\na.b.c=3\na.b.d=4\n\n" jsonRef := "{\n \"arr\": [\n {\n \"a\": {\n \"b\": {\n \"c\": {\"type\": \"integer\", \"value\": \"1\"},\n \"d\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n }\n },\n {\n \"a\": {\n \"b\": {\n \"c\": {\"type\": \"integer\", \"value\": \"3\"},\n \"d\": {\"type\": \"integer\", \"value\": \"4\"}\n }\n }\n }\n ],\n \"top\": {\n \"key\": {\"type\": \"integer\", \"value\": \"1\"}\n }\n}\n" testgenValid(t, input, jsonRef) @@ -2271,19 +2803,19 @@ func TestTOMLTest_Valid_Key_DottedEmpty(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Empty1(t *testing.T) { +func TestTOMLTest_Valid_Key_Empty01(t *testing.T) { input := "\"\" = \"blank\"\n" jsonRef := "{\n \"\": {\"type\": \"string\", \"value\": \"blank\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Empty2(t *testing.T) { +func TestTOMLTest_Valid_Key_Empty02(t *testing.T) { input := "'' = \"blank\"\n" jsonRef := "{\n \"\": {\"type\": \"string\", \"value\": \"blank\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Empty3(t *testing.T) { +func TestTOMLTest_Valid_Key_Empty03(t *testing.T) { input := "''=0\n" jsonRef := "{\n \"\": {\"type\": \"integer\", \"value\": \"0\"}\n}\n" testgenValid(t, input, jsonRef) @@ -2301,21 +2833,63 @@ func TestTOMLTest_Valid_Key_Escapes(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_NumericDotted(t *testing.T) { - input := "1.2 = 3\n" - jsonRef := "{\n \"1\": {\n \"2\": {\"type\": \"integer\", \"value\": \"3\"}\n }\n}\n" +func TestTOMLTest_Valid_Key_LikeDate(t *testing.T) { + input := "# '-' is a valid character in keys: make a key that looks like a date.\n2001-02-03 = 1\n\"2001-02-04\" = 2\n'2001-02-05' = 3\n\n# Also include datetime and time for good measure; these need to be quoted as\n# ':' isn't a valid bare key.\n\"2001-02-06T15:16:17+01:00\" = 4\n\"2001-02-07T15:16:17\" = 5\n\"15:16:17\" = 6\n\n# Dotted keys\na.2001-02-08 = 7\na.2001-02-09.2001-02-10 = 8\n2001-02-11.a.2001-02-12 = 9\n\n# Table names\n[2002-01-02]\nk = 10\n\n[2002-01-02.2024-01-03]\nk = 11\n\n[[2002-01-04]]\nk = 12\n" + jsonRef := "{\n \"15:16:17\": {\"type\": \"integer\", \"value\": \"6\"},\n \"2001-02-03\": {\"type\": \"integer\", \"value\": \"1\"},\n \"2001-02-04\": {\"type\": \"integer\", \"value\": \"2\"},\n \"2001-02-05\": {\"type\": \"integer\", \"value\": \"3\"},\n \"2001-02-06T15:16:17+01:00\": {\"type\": \"integer\", \"value\": \"4\"},\n \"2001-02-07T15:16:17\": {\"type\": \"integer\", \"value\": \"5\"},\n \"2002-01-04\": [{\n \"k\": {\"type\": \"integer\", \"value\": \"12\"}\n }],\n \"2001-02-11\": {\n \"a\": {\n \"2001-02-12\": {\"type\": \"integer\", \"value\": \"9\"}\n }\n },\n \"2002-01-02\": {\n \"k\": {\"type\": \"integer\", \"value\": \"10\"},\n \"2024-01-03\": {\n \"k\": {\"type\": \"integer\", \"value\": \"11\"}\n }\n },\n \"a\": {\n \"2001-02-08\": {\"type\": \"integer\", \"value\": \"7\"},\n \"2001-02-09\": {\n \"2001-02-10\": {\"type\": \"integer\", \"value\": \"8\"}\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Key_Numeric(t *testing.T) { - input := "1 = 1\n" - jsonRef := "{\n \"1\": {\"type\": \"integer\", \"value\": \"1\"}\n}\n" +func TestTOMLTest_Valid_Key_Numeric01(t *testing.T) { + input := "1 = true\n" + jsonRef := "{\n \"1\": {\"type\": \"bool\", \"value\": \"true\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Key_Numeric02(t *testing.T) { + input := "1.2 = true\n" + jsonRef := "{\n \"1\": {\n \"2\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Key_Numeric03(t *testing.T) { + input := "0123 = true\n" + jsonRef := "{\n \"0123\": {\"type\": \"bool\", \"value\": \"true\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Key_Numeric04(t *testing.T) { + input := "01.23 = true\n" + jsonRef := "{\n \"01\": {\n \"23\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Key_Numeric05(t *testing.T) { + input := "23.01 = true\n" + jsonRef := "{\n \"23\": {\n \"01\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Key_Numeric06(t *testing.T) { + input := "-1 = true\n" + jsonRef := "{\n \"-1\": {\"type\": \"bool\", \"value\": \"true\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Key_Numeric07(t *testing.T) { + input := "-01 = true\n" + jsonRef := "{\n \"-01\": {\"type\": \"bool\", \"value\": \"true\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Key_Numeric08(t *testing.T) { + input := "1 = 'one'\n01 = 'zero one'\n" + jsonRef := "{\n \"01\": {\"type\": \"string\", \"value\": \"zero one\"},\n \"1\": {\"type\": \"string\", \"value\": \"one\"}\n}\n" testgenValid(t, input, jsonRef) } func TestTOMLTest_Valid_Key_QuotedDots(t *testing.T) { - input := "plain = 1\n\"with.dot\" = 2\n\n[plain_table]\nplain = 3\n\"with.dot\" = 4\n\n[table.withdot]\nplain = 5\n\"key.with.dots\" = 6\n" - jsonRef := "{\n \"plain\": {\"type\": \"integer\", \"value\": \"1\"},\n \"with.dot\": {\"type\": \"integer\", \"value\": \"2\"},\n \"plain_table\": {\n \"plain\": {\"type\": \"integer\", \"value\": \"3\"},\n \"with.dot\": {\"type\": \"integer\", \"value\": \"4\"}\n },\n \"table\": {\n \"withdot\": {\n \"key.with.dots\": {\"type\": \"integer\", \"value\": \"6\"},\n \"plain\": {\"type\": \"integer\", \"value\": \"5\"}\n }\n }\n}\n" + input := "plain = 1\n\"with.dot\" = 2\n\n[plain_table]\nplain = 3\n\"with.dot\" = 4\n\n[table.withdot]\nplain = 5\n\"key.with.dots\" = 6\n\"escaped\\u002edot\" = 7\n" + jsonRef := "{\n \"plain\": {\"type\": \"integer\", \"value\": \"1\"},\n \"with.dot\": {\"type\": \"integer\", \"value\": \"2\"},\n \"plain_table\": {\n \"plain\": {\"type\": \"integer\", \"value\": \"3\"},\n \"with.dot\": {\"type\": \"integer\", \"value\": \"4\"}\n },\n \"table\": {\n \"withdot\": {\n \"escaped.dot\": {\"type\": \"integer\", \"value\": \"7\"},\n \"key.with.dots\": {\"type\": \"integer\", \"value\": \"6\"},\n \"plain\": {\"type\": \"integer\", \"value\": \"5\"}\n }\n }\n}\n" testgenValid(t, input, jsonRef) } @@ -2326,8 +2900,8 @@ func TestTOMLTest_Valid_Key_QuotedUnicode(t *testing.T) { } func TestTOMLTest_Valid_Key_Space(t *testing.T) { - input := "# Keep whitespace inside quotes keys at all positions.\n\"a b\" = 1\n\" c d \" = 2\n\n[ \" tbl \" ]\n\"\\ttab\\ttab\\t\" = \"tab\"\n" - jsonRef := "{\n \" c d \": {\"type\": \"integer\", \"value\": \"2\"},\n \"a b\": {\"type\": \"integer\", \"value\": \"1\"},\n \" tbl \": {\n \"\\ttab\\ttab\\t\": {\"type\": \"string\", \"value\": \"tab\"}\n }\n}\n" + input := "# Keep whitespace inside quotes keys at all positions.\n\"a b\" = 1\n\" c d \" = 2\n\" much \t\t whitespace \t\\n \\r\\n \" = 3\n\n[ \" tbl \" ]\n\"\\ttab\\ttab\\t\" = \"tab\"\n" + jsonRef := "{\n \" much \\t\\t whitespace \\t\\n \\r\\n \": {\"type\": \"integer\", \"value\": \"3\"},\n \" c d \": {\"type\": \"integer\", \"value\": \"2\"},\n \"a b\": {\"type\": \"integer\", \"value\": \"1\"},\n \" tbl \": {\n \"\\ttab\\ttab\\t\": {\"type\": \"string\", \"value\": \"tab\"}\n }\n}\n" testgenValid(t, input, jsonRef) } @@ -2355,300 +2929,336 @@ func TestTOMLTest_Valid_Key_Zero(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Array0(t *testing.T) { - input := "integers = [ 1, 2, 3 ]\ncolors = [ \"red\", \"yellow\", \"green\" ]\nnested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ]\nnested_mixed_array = [ [ 1, 2 ], [\"a\", \"b\", \"c\"] ]\nstring_array = [ \"all\", 'strings', \"\"\"are the same\"\"\", '''type''' ]\n\n# Mixed-type arrays are allowed\nnumbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]\ncontributors = [\n \"Foo Bar \",\n { name = \"Baz Qux\", email = \"bazqux@example.com\", url = \"https://example.com/bazqux\" }\n]\n" - jsonRef := "{\n \"colors\": [\n {\"type\": \"string\", \"value\": \"red\"},\n {\"type\": \"string\", \"value\": \"yellow\"},\n {\"type\": \"string\", \"value\": \"green\"}\n ],\n \"contributors\": [\n {\"type\": \"string\", \"value\": \"Foo Bar \\u003cfoo@example.com\\u003e\"},\n {\n \"email\": {\"type\": \"string\", \"value\": \"bazqux@example.com\"},\n \"name\": {\"type\": \"string\", \"value\": \"Baz Qux\"},\n \"url\": {\"type\": \"string\", \"value\": \"https://example.com/bazqux\"}\n }\n ],\n \"integers\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"nested_arrays_of_ints\": [\n [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n [\n {\"type\": \"integer\", \"value\": \"3\"},\n {\"type\": \"integer\", \"value\": \"4\"},\n {\"type\": \"integer\", \"value\": \"5\"}\n ]\n ],\n \"nested_mixed_array\": [\n [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n [\n {\"type\": \"string\", \"value\": \"a\"},\n {\"type\": \"string\", \"value\": \"b\"},\n {\"type\": \"string\", \"value\": \"c\"}\n ]\n ],\n \"numbers\": [\n {\"type\": \"float\", \"value\": \"0.1\"},\n {\"type\": \"float\", \"value\": \"0.2\"},\n {\"type\": \"float\", \"value\": \"0.5\"},\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"5\"}\n ],\n \"string_array\": [\n {\"type\": \"string\", \"value\": \"all\"},\n {\"type\": \"string\", \"value\": \"strings\"},\n {\"type\": \"string\", \"value\": \"are the same\"},\n {\"type\": \"string\", \"value\": \"type\"}\n ]\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Array1(t *testing.T) { - input := "integers2 = [\n 1, 2, 3\n]\n\nintegers3 = [\n 1,\n 2, # this is ok\n]\n" - jsonRef := "{\n \"integers2\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"integers3\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ]\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_ArrayOfTables0(t *testing.T) { - input := "[[products]]\nname = \"Hammer\"\nsku = 738594937\n\n[[products]] # empty table within the array\n\n[[products]]\nname = \"Nail\"\nsku = 284758393\n\ncolor = \"gray\"\n" - jsonRef := "{\n \"products\": [\n {\n \"name\": {\"type\": \"string\", \"value\": \"Hammer\"},\n \"sku\": {\"type\": \"integer\", \"value\": \"738594937\"}\n },\n {},\n {\n \"color\": {\"type\": \"string\", \"value\": \"gray\"},\n \"name\": {\"type\": \"string\", \"value\": \"Nail\"},\n \"sku\": {\"type\": \"integer\", \"value\": \"284758393\"}\n }\n ]\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_ArrayOfTables1(t *testing.T) { - input := "[[fruits]]\nname = \"apple\"\n\n[fruits.physical] # subtable\ncolor = \"red\"\nshape = \"round\"\n\n[[fruits.varieties]] # nested array of tables\nname = \"red delicious\"\n\n[[fruits.varieties]]\nname = \"granny smith\"\n\n\n[[fruits]]\nname = \"banana\"\n\n[[fruits.varieties]]\nname = \"plantain\"\n" - jsonRef := "{\n \"fruits\": [\n {\n \"name\": {\"type\": \"string\", \"value\": \"apple\"},\n \"physical\": {\n \"color\": {\"type\": \"string\", \"value\": \"red\"},\n \"shape\": {\"type\": \"string\", \"value\": \"round\"}\n },\n \"varieties\": [\n {\n \"name\": {\"type\": \"string\", \"value\": \"red delicious\"}\n },\n {\n \"name\": {\"type\": \"string\", \"value\": \"granny smith\"}\n }\n ]\n },\n {\n \"name\": {\"type\": \"string\", \"value\": \"banana\"},\n \"varieties\": [{\n \"name\": {\"type\": \"string\", \"value\": \"plantain\"}\n }]\n }\n ]\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_ArrayOfTables2(t *testing.T) { - input := "points = [ { x = 1, y = 2, z = 3 },\n { x = 7, y = 8, z = 9 },\n { x = 2, y = 4, z = 8 } ]\n" - jsonRef := "{\n \"points\": [\n {\n \"x\": {\"type\": \"integer\", \"value\": \"1\"},\n \"y\": {\"type\": \"integer\", \"value\": \"2\"},\n \"z\": {\"type\": \"integer\", \"value\": \"3\"}\n },\n {\n \"x\": {\"type\": \"integer\", \"value\": \"7\"},\n \"y\": {\"type\": \"integer\", \"value\": \"8\"},\n \"z\": {\"type\": \"integer\", \"value\": \"9\"}\n },\n {\n \"x\": {\"type\": \"integer\", \"value\": \"2\"},\n \"y\": {\"type\": \"integer\", \"value\": \"4\"},\n \"z\": {\"type\": \"integer\", \"value\": \"8\"}\n }\n ]\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Boolean0(t *testing.T) { - input := "bool1 = true\nbool2 = false\n" - jsonRef := "{\n \"bool1\": {\"type\": \"bool\", \"value\": \"true\"},\n \"bool2\": {\"type\": \"bool\", \"value\": \"false\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Comment0(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common0(t *testing.T) { input := "# This is a full-line comment\nkey = \"value\" # This is a comment at the end of a line\nanother = \"# This is not a comment\"\n" jsonRef := "{\n \"another\": {\"type\": \"string\", \"value\": \"# This is not a comment\"},\n \"key\": {\"type\": \"string\", \"value\": \"value\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Float0(t *testing.T) { - input := "# fractional\nflt1 = +1.0\nflt2 = 3.1415\nflt3 = -0.01\n\n# exponent\nflt4 = 5e+22\nflt5 = 1e06\nflt6 = -2E-2\n\n# both\nflt7 = 6.626e-34\n" - jsonRef := "{\n \"flt1\": {\"type\": \"float\", \"value\": \"1\"},\n \"flt2\": {\"type\": \"float\", \"value\": \"3.1415\"},\n \"flt3\": {\"type\": \"float\", \"value\": \"-0.01\"},\n \"flt4\": {\"type\": \"float\", \"value\": \"5e+22\"},\n \"flt5\": {\"type\": \"float\", \"value\": \"1e+06\"},\n \"flt6\": {\"type\": \"float\", \"value\": \"-0.02\"},\n \"flt7\": {\"type\": \"float\", \"value\": \"6.626e-34\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Float1(t *testing.T) { - input := "flt8 = 224_617.445_991_228\n" - jsonRef := "{\n \"flt8\": {\"type\": \"float\", \"value\": \"224617.445991228\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Float2(t *testing.T) { - input := "# infinity\nsf1 = inf # positive infinity\nsf2 = +inf # positive infinity\nsf3 = -inf # negative infinity\n\n# not a number\nsf4 = nan # actual sNaN/qNaN encoding is implementation-specific\nsf5 = +nan # same as `nan`\nsf6 = -nan # valid, actual encoding is implementation-specific\n" - jsonRef := "{\n \"sf1\": {\"type\": \"float\", \"value\": \"inf\"},\n \"sf2\": {\"type\": \"float\", \"value\": \"inf\"},\n \"sf3\": {\"type\": \"float\", \"value\": \"-inf\"},\n \"sf4\": {\"type\": \"float\", \"value\": \"nan\"},\n \"sf5\": {\"type\": \"float\", \"value\": \"nan\"},\n \"sf6\": {\"type\": \"float\", \"value\": \"nan\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_InlineTable0(t *testing.T) { - input := "name = { first = \"Tom\", last = \"Preston-Werner\" }\npoint = { x = 1, y = 2 }\nanimal = { type.name = \"pug\" }\n" - jsonRef := "{\n \"animal\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"pug\"}\n }\n },\n \"name\": {\n \"first\": {\"type\": \"string\", \"value\": \"Tom\"},\n \"last\": {\"type\": \"string\", \"value\": \"Preston-Werner\"}\n },\n \"point\": {\n \"x\": {\"type\": \"integer\", \"value\": \"1\"},\n \"y\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_InlineTable1(t *testing.T) { - input := "[name]\nfirst = \"Tom\"\nlast = \"Preston-Werner\"\n\n[point]\nx = 1\ny = 2\n\n[animal]\ntype.name = \"pug\"\n" - jsonRef := "{\n \"animal\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"pug\"}\n }\n },\n \"name\": {\n \"first\": {\"type\": \"string\", \"value\": \"Tom\"},\n \"last\": {\"type\": \"string\", \"value\": \"Preston-Werner\"}\n },\n \"point\": {\n \"x\": {\"type\": \"integer\", \"value\": \"1\"},\n \"y\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_InlineTable2(t *testing.T) { - input := "[product]\ntype = { name = \"Nail\" }\n# type.edible = false # INVALID\n" - jsonRef := "{\n \"product\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"Nail\"}\n }\n }\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_InlineTable3(t *testing.T) { - input := "[product]\ntype.name = \"Nail\"\n# type = { edible = false } # INVALID\n" - jsonRef := "{\n \"product\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"Nail\"}\n }\n }\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Integer0(t *testing.T) { - input := "int1 = +99\nint2 = 42\nint3 = 0\nint4 = -17\n" - jsonRef := "{\n \"int1\": {\"type\": \"integer\", \"value\": \"99\"},\n \"int2\": {\"type\": \"integer\", \"value\": \"42\"},\n \"int3\": {\"type\": \"integer\", \"value\": \"0\"},\n \"int4\": {\"type\": \"integer\", \"value\": \"-17\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Integer1(t *testing.T) { - input := "int5 = 1_000\nint6 = 5_349_221\nint7 = 53_49_221 # Indian number system grouping\nint8 = 1_2_3_4_5 # VALID but discouraged\n" - jsonRef := "{\n \"int5\": {\"type\": \"integer\", \"value\": \"1000\"},\n \"int6\": {\"type\": \"integer\", \"value\": \"5349221\"},\n \"int7\": {\"type\": \"integer\", \"value\": \"5349221\"},\n \"int8\": {\"type\": \"integer\", \"value\": \"12345\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Integer2(t *testing.T) { - input := "# hexadecimal with prefix `0x`\nhex1 = 0xDEADBEEF\nhex2 = 0xdeadbeef\nhex3 = 0xdead_beef\n\n# octal with prefix `0o`\noct1 = 0o01234567\noct2 = 0o755 # useful for Unix file permissions\n\n# binary with prefix `0b`\nbin1 = 0b11010110\n" - jsonRef := "{\n \"bin1\": {\"type\": \"integer\", \"value\": \"214\"},\n \"hex1\": {\"type\": \"integer\", \"value\": \"3735928559\"},\n \"hex2\": {\"type\": \"integer\", \"value\": \"3735928559\"},\n \"hex3\": {\"type\": \"integer\", \"value\": \"3735928559\"},\n \"oct1\": {\"type\": \"integer\", \"value\": \"342391\"},\n \"oct2\": {\"type\": \"integer\", \"value\": \"493\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_KeyValuePair0(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common1(t *testing.T) { input := "key = \"value\"\n" jsonRef := "{\n \"key\": {\"type\": \"string\", \"value\": \"value\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Keys0(t *testing.T) { - input := "key = \"value\"\nbare_key = \"value\"\nbare-key = \"value\"\n1234 = \"value\"\n" - jsonRef := "{\n \"1234\": {\"type\": \"string\", \"value\": \"value\"},\n \"bare-key\": {\"type\": \"string\", \"value\": \"value\"},\n \"bare_key\": {\"type\": \"string\", \"value\": \"value\"},\n \"key\": {\"type\": \"string\", \"value\": \"value\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Keys1(t *testing.T) { - input := "\"127.0.0.1\" = \"value\"\n\"character encoding\" = \"value\"\n\"ʎǝʞ\" = \"value\"\n'key2' = \"value\"\n'quoted \"value\"' = \"value\"\n" - jsonRef := "{\n \"127.0.0.1\": {\"type\": \"string\", \"value\": \"value\"},\n \"character encoding\": {\"type\": \"string\", \"value\": \"value\"},\n \"key2\": {\"type\": \"string\", \"value\": \"value\"},\n \"quoted \\\"value\\\"\": {\"type\": \"string\", \"value\": \"value\"},\n \"ʎǝʞ\": {\"type\": \"string\", \"value\": \"value\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Keys3(t *testing.T) { - input := "name = \"Orange\"\nphysical.color = \"orange\"\nphysical.shape = \"round\"\nsite.\"google.com\" = true\n" - jsonRef := "{\n \"name\": {\"type\": \"string\", \"value\": \"Orange\"},\n \"physical\": {\n \"color\": {\"type\": \"string\", \"value\": \"orange\"},\n \"shape\": {\"type\": \"string\", \"value\": \"round\"}\n },\n \"site\": {\n \"google.com\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Keys4(t *testing.T) { - input := "fruit.name = \"banana\" # this is best practice\nfruit. color = \"yellow\" # same as fruit.color\nfruit . flavor = \"banana\" # same as fruit.flavor\n" - jsonRef := "{\n \"fruit\": {\n \"color\": {\"type\": \"string\", \"value\": \"yellow\"},\n \"flavor\": {\"type\": \"string\", \"value\": \"banana\"},\n \"name\": {\"type\": \"string\", \"value\": \"banana\"}\n }\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Keys5(t *testing.T) { - input := "# VALID BUT DISCOURAGED\n\napple.type = \"fruit\"\norange.type = \"fruit\"\n\napple.skin = \"thin\"\norange.skin = \"thick\"\n\napple.color = \"red\"\norange.color = \"orange\"\n" - jsonRef := "{\n \"apple\": {\n \"color\": {\"type\": \"string\", \"value\": \"red\"},\n \"skin\": {\"type\": \"string\", \"value\": \"thin\"},\n \"type\": {\"type\": \"string\", \"value\": \"fruit\"}\n },\n \"orange\": {\n \"color\": {\"type\": \"string\", \"value\": \"orange\"},\n \"skin\": {\"type\": \"string\", \"value\": \"thick\"},\n \"type\": {\"type\": \"string\", \"value\": \"fruit\"}\n }\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_Keys6(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common10(t *testing.T) { input := "# RECOMMENDED\n\napple.type = \"fruit\"\napple.skin = \"thin\"\napple.color = \"red\"\n\norange.type = \"fruit\"\norange.skin = \"thick\"\norange.color = \"orange\"\n" jsonRef := "{\n \"apple\": {\n \"color\": {\"type\": \"string\", \"value\": \"red\"},\n \"skin\": {\"type\": \"string\", \"value\": \"thin\"},\n \"type\": {\"type\": \"string\", \"value\": \"fruit\"}\n },\n \"orange\": {\n \"color\": {\"type\": \"string\", \"value\": \"orange\"},\n \"skin\": {\"type\": \"string\", \"value\": \"thick\"},\n \"type\": {\"type\": \"string\", \"value\": \"fruit\"}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Keys7(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common11(t *testing.T) { input := "3.14159 = \"pi\"\n" jsonRef := "{\n \"3\": {\n \"14159\": {\"type\": \"string\", \"value\": \"pi\"}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_LocalDate0(t *testing.T) { - input := "ld1 = 1979-05-27\n" - jsonRef := "{\n \"ld1\": {\"type\": \"date-local\", \"value\": \"1979-05-27\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_LocalDateTime0(t *testing.T) { - input := "ldt1 = 1979-05-27T07:32:00\nldt2 = 1979-05-27T00:32:00.999\n" - jsonRef := "{\n \"ldt1\": {\"type\": \"datetime-local\", \"value\": \"1979-05-27T07:32:00\"},\n \"ldt2\": {\"type\": \"datetime-local\", \"value\": \"1979-05-27T00:32:00.999\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_LocalTime0(t *testing.T) { - input := "lt1 = 07:32:00\nlt2 = 00:32:00.999\n" - jsonRef := "{\n \"lt1\": {\"type\": \"time-local\", \"value\": \"07:32:00\"},\n \"lt2\": {\"type\": \"time-local\", \"value\": \"00:32:00.999\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_OffsetDateTime0(t *testing.T) { - input := "odt1 = 1979-05-27T07:32:00Z\nodt2 = 1979-05-27T00:32:00-07:00\nodt3 = 1979-05-27T00:32:00.999-07:00\n" - jsonRef := "{\n \"odt1\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00Z\"},\n \"odt2\": {\"type\": \"datetime\", \"value\": \"1979-05-27T00:32:00-07:00\"},\n \"odt3\": {\"type\": \"datetime\", \"value\": \"1979-05-27T00:32:00.999-07:00\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_OffsetDateTime1(t *testing.T) { - input := "odt4 = 1979-05-27 07:32:00Z\n" - jsonRef := "{\n \"odt4\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00Z\"}\n}\n" - testgenValid(t, input, jsonRef) -} - -func TestTOMLTest_Valid_Spec_String0(t *testing.T) { - input := "str = \"I'm a string. \\\"You can quote me\\\". Name\\tJos\\u00E9\\nLocation\\tSF.\"\n" +func TestTOMLTest_Valid_Spec1_1_0_Common12(t *testing.T) { + input := "str = \"I'm a string. \\\"You can quote me\\\". Name\\tJos\\xE9\\nLocation\\tSF.\"\n" jsonRef := "{\n \"str\": {\"type\": \"string\", \"value\": \"I'm a string. \\\"You can quote me\\\". Name\\tJosé\\nLocation\\tSF.\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_String1(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common13(t *testing.T) { input := "str1 = \"\"\"\nRoses are red\nViolets are blue\"\"\"\n" jsonRef := "{\n \"str1\": {\"type\": \"string\", \"value\": \"Roses are red\\nViolets are blue\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_String2(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common14(t *testing.T) { input := "# On a Unix system, the above multi-line string will most likely be the same as:\nstr2 = \"Roses are red\\nViolets are blue\"\n\n# On a Windows system, it will most likely be equivalent to:\nstr3 = \"Roses are red\\r\\nViolets are blue\"\n" jsonRef := "{\n \"str2\": {\"type\": \"string\", \"value\": \"Roses are red\\nViolets are blue\"},\n \"str3\": {\"type\": \"string\", \"value\": \"Roses are red\\r\\nViolets are blue\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_String3(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common15(t *testing.T) { input := "# The following strings are byte-for-byte equivalent:\nstr1 = \"The quick brown fox jumps over the lazy dog.\"\n\nstr2 = \"\"\"\nThe quick brown \\\n\n\n fox jumps over \\\n the lazy dog.\"\"\"\n\nstr3 = \"\"\"\\\n The quick brown \\\n fox jumps over \\\n the lazy dog.\\\n \"\"\"\n" jsonRef := "{\n \"str1\": {\"type\": \"string\", \"value\": \"The quick brown fox jumps over the lazy dog.\"},\n \"str2\": {\"type\": \"string\", \"value\": \"The quick brown fox jumps over the lazy dog.\"},\n \"str3\": {\"type\": \"string\", \"value\": \"The quick brown fox jumps over the lazy dog.\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_String4(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common16(t *testing.T) { input := "str4 = \"\"\"Here are two quotation marks: \"\". Simple enough.\"\"\"\n# str5 = \"\"\"Here are three quotation marks: \"\"\".\"\"\" # INVALID\nstr5 = \"\"\"Here are three quotation marks: \"\"\\\".\"\"\"\nstr6 = \"\"\"Here are fifteen quotation marks: \"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\"\"\"\\\".\"\"\"\n\n# \"This,\" she said, \"is just a pointless statement.\"\nstr7 = \"\"\"\"This,\" she said, \"is just a pointless statement.\"\"\"\"\n" jsonRef := "{\n \"str4\": {\"type\": \"string\", \"value\": \"Here are two quotation marks: \\\"\\\". Simple enough.\"},\n \"str5\": {\"type\": \"string\", \"value\": \"Here are three quotation marks: \\\"\\\"\\\".\"},\n \"str6\": {\"type\": \"string\", \"value\": \"Here are fifteen quotation marks: \\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\".\"},\n \"str7\": {\"type\": \"string\", \"value\": \"\\\"This,\\\" she said, \\\"is just a pointless statement.\\\"\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_String5(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common17(t *testing.T) { input := "# What you see is what you get.\nwinpath = 'C:\\Users\\nodejs\\templates'\nwinpath2 = '\\\\ServerX\\admin$\\system32\\'\nquoted = 'Tom \"Dubs\" Preston-Werner'\nregex = '<\\i\\c*\\s*>'\n" jsonRef := "{\n \"quoted\": {\"type\": \"string\", \"value\": \"Tom \\\"Dubs\\\" Preston-Werner\"},\n \"regex\": {\"type\": \"string\", \"value\": \"\\u003c\\\\i\\\\c*\\\\s*\\u003e\"},\n \"winpath\": {\"type\": \"string\", \"value\": \"C:\\\\Users\\\\nodejs\\\\templates\"},\n \"winpath2\": {\"type\": \"string\", \"value\": \"\\\\\\\\ServerX\\\\admin$\\\\system32\\\\\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_String6(t *testing.T) { - input := "regex2 = '''I [dw]on't need \\d{2} apples'''\nlines = '''\nThe first newline is\ntrimmed in raw strings.\n All other whitespace\n is preserved.\n'''\n" - jsonRef := "{\n \"lines\": {\"type\": \"string\", \"value\": \"The first newline is\\ntrimmed in raw strings.\\n All other whitespace\\n is preserved.\\n\"},\n \"regex2\": {\"type\": \"string\", \"value\": \"I [dw]on't need \\\\d{2} apples\"}\n}\n" +func TestTOMLTest_Valid_Spec1_1_0_Common18(t *testing.T) { + input := "regex2 = '''I [dw]on't need \\d{2} apples'''\nlines = '''\nThe first newline is\ntrimmed in literal strings.\n All other whitespace\n is preserved.\n'''\n" + jsonRef := "{\n \"lines\": {\"type\": \"string\", \"value\": \"The first newline is\\ntrimmed in literal strings.\\n All other whitespace\\n is preserved.\\n\"},\n \"regex2\": {\"type\": \"string\", \"value\": \"I [dw]on't need \\\\d{2} apples\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_String7(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common19(t *testing.T) { input := "quot15 = '''Here are fifteen quotation marks: \"\"\"\"\"\"\"\"\"\"\"\"\"\"\"'''\n\n# apos15 = '''Here are fifteen apostrophes: '''''''''''''''''' # INVALID\napos15 = \"Here are fifteen apostrophes: '''''''''''''''\"\n\n# 'That,' she said, 'is still pointless.'\nstr = ''''That,' she said, 'is still pointless.''''\n" jsonRef := "{\n \"apos15\": {\"type\": \"string\", \"value\": \"Here are fifteen apostrophes: '''''''''''''''\"},\n \"quot15\": {\"type\": \"string\", \"value\": \"Here are fifteen quotation marks: \\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\\\"\"},\n \"str\": {\"type\": \"string\", \"value\": \"'That,' she said, 'is still pointless.'\"}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table0(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common20(t *testing.T) { + input := "int1 = +99\nint2 = 42\nint3 = 0\nint4 = -17\n" + jsonRef := "{\n \"int1\": {\"type\": \"integer\", \"value\": \"99\"},\n \"int2\": {\"type\": \"integer\", \"value\": \"42\"},\n \"int3\": {\"type\": \"integer\", \"value\": \"0\"},\n \"int4\": {\"type\": \"integer\", \"value\": \"-17\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common21(t *testing.T) { + input := "int5 = 1_000\nint6 = 5_349_221\nint7 = 53_49_221 # Indian number system grouping\nint8 = 1_2_3_4_5 # VALID but discouraged\n" + jsonRef := "{\n \"int5\": {\"type\": \"integer\", \"value\": \"1000\"},\n \"int6\": {\"type\": \"integer\", \"value\": \"5349221\"},\n \"int7\": {\"type\": \"integer\", \"value\": \"5349221\"},\n \"int8\": {\"type\": \"integer\", \"value\": \"12345\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common22(t *testing.T) { + input := "# hexadecimal with prefix `0x`\nhex1 = 0xDEADBEEF\nhex2 = 0xdeadbeef\nhex3 = 0xdead_beef\n\n# octal with prefix `0o`\noct1 = 0o01234567\noct2 = 0o755 # useful for Unix file permissions\n\n# binary with prefix `0b`\nbin1 = 0b11010110\n" + jsonRef := "{\n \"bin1\": {\"type\": \"integer\", \"value\": \"214\"},\n \"hex1\": {\"type\": \"integer\", \"value\": \"3735928559\"},\n \"hex2\": {\"type\": \"integer\", \"value\": \"3735928559\"},\n \"hex3\": {\"type\": \"integer\", \"value\": \"3735928559\"},\n \"oct1\": {\"type\": \"integer\", \"value\": \"342391\"},\n \"oct2\": {\"type\": \"integer\", \"value\": \"493\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common23(t *testing.T) { + input := "# fractional\nflt1 = +1.0\nflt2 = 3.1415\nflt3 = -0.01\n\n# exponent\nflt4 = 5e+22\nflt5 = 1e06\nflt6 = -2E-2\n\n# both\nflt7 = 6.626e-34\n" + jsonRef := "{\n \"flt1\": {\"type\": \"float\", \"value\": \"1\"},\n \"flt2\": {\"type\": \"float\", \"value\": \"3.1415\"},\n \"flt3\": {\"type\": \"float\", \"value\": \"-0.01\"},\n \"flt4\": {\"type\": \"float\", \"value\": \"5e+22\"},\n \"flt5\": {\"type\": \"float\", \"value\": \"1e+06\"},\n \"flt6\": {\"type\": \"float\", \"value\": \"-0.02\"},\n \"flt7\": {\"type\": \"float\", \"value\": \"6.626e-34\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common24(t *testing.T) { + input := "flt8 = 224_617.445_991_228\n" + jsonRef := "{\n \"flt8\": {\"type\": \"float\", \"value\": \"224617.445991228\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common25(t *testing.T) { + input := "# infinity\nsf1 = inf # positive infinity\nsf2 = +inf # positive infinity\nsf3 = -inf # negative infinity\n\n# not a number\nsf4 = nan # actual sNaN/qNaN encoding is implementation-specific\nsf5 = +nan # same as `nan`\nsf6 = -nan # valid, actual encoding is implementation-specific\n" + jsonRef := "{\n \"sf1\": {\"type\": \"float\", \"value\": \"inf\"},\n \"sf2\": {\"type\": \"float\", \"value\": \"inf\"},\n \"sf3\": {\"type\": \"float\", \"value\": \"-inf\"},\n \"sf4\": {\"type\": \"float\", \"value\": \"nan\"},\n \"sf5\": {\"type\": \"float\", \"value\": \"nan\"},\n \"sf6\": {\"type\": \"float\", \"value\": \"nan\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common26(t *testing.T) { + input := "bool1 = true\nbool2 = false\n" + jsonRef := "{\n \"bool1\": {\"type\": \"bool\", \"value\": \"true\"},\n \"bool2\": {\"type\": \"bool\", \"value\": \"false\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common27(t *testing.T) { + input := "odt1 = 1979-05-27T07:32:00Z\nodt2 = 1979-05-27T00:32:00-07:00\nodt3 = 1979-05-27T00:32:00.5-07:00\nodt4 = 1979-05-27T00:32:00.999-07:00\n" + jsonRef := "{\n \"odt1\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00Z\"},\n \"odt2\": {\"type\": \"datetime\", \"value\": \"1979-05-27T00:32:00-07:00\"},\n \"odt3\": {\"type\": \"datetime\", \"value\": \"1979-05-27T00:32:00.5-07:00\"},\n \"odt4\": {\"type\": \"datetime\", \"value\": \"1979-05-27T00:32:00.999-07:00\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common28(t *testing.T) { + input := "odt4 = 1979-05-27 07:32:00Z\n" + jsonRef := "{\n \"odt4\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00Z\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common29(t *testing.T) { + input := "odt5 = 1979-05-27 07:32Z\nodt6 = 1979-05-27 07:32-07:00\n" + jsonRef := "{\n \"odt5\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00Z\"},\n \"odt6\": {\"type\": \"datetime\", \"value\": \"1979-05-27T07:32:00-07:00\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common3(t *testing.T) { + input := "key = \"value\"\nbare_key = \"value\"\nbare-key = \"value\"\n1234 = \"value\"\n" + jsonRef := "{\n \"1234\": {\"type\": \"string\", \"value\": \"value\"},\n \"bare-key\": {\"type\": \"string\", \"value\": \"value\"},\n \"bare_key\": {\"type\": \"string\", \"value\": \"value\"},\n \"key\": {\"type\": \"string\", \"value\": \"value\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common30(t *testing.T) { + input := "ldt1 = 1979-05-27T07:32:00\nldt2 = 1979-05-27T07:32:00.5\nldt3 = 1979-05-27T00:32:00.999\n" + jsonRef := "{\n \"ldt1\": {\"type\": \"datetime-local\", \"value\": \"1979-05-27T07:32:00\"},\n \"ldt2\": {\"type\": \"datetime-local\", \"value\": \"1979-05-27T07:32:00.5\"},\n \"ldt3\": {\"type\": \"datetime-local\", \"value\": \"1979-05-27T00:32:00.999\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common31(t *testing.T) { + input := "ldt3 = 1979-05-27T07:32\n" + jsonRef := "{\n \"ldt3\": {\"type\": \"datetime-local\", \"value\": \"1979-05-27T07:32:00\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common32(t *testing.T) { + input := "ld1 = 1979-05-27\n" + jsonRef := "{\n \"ld1\": {\"type\": \"date-local\", \"value\": \"1979-05-27\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common33(t *testing.T) { + input := "lt1 = 07:32:00\nlt2 = 00:32:00.5\nlt3 = 00:32:00.999\n" + jsonRef := "{\n \"lt1\": {\"type\": \"time-local\", \"value\": \"07:32:00\"},\n \"lt2\": {\"type\": \"time-local\", \"value\": \"00:32:00.5\"},\n \"lt3\": {\"type\": \"time-local\", \"value\": \"00:32:00.999\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common34(t *testing.T) { + input := "lt3 = 07:32\n" + jsonRef := "{\n \"lt3\": {\"type\": \"time-local\", \"value\": \"07:32:00\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common35(t *testing.T) { + input := "integers = [ 1, 2, 3 ]\ncolors = [ \"red\", \"yellow\", \"green\" ]\nnested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ]\nnested_mixed_array = [ [ 1, 2 ], [\"a\", \"b\", \"c\"] ]\nstring_array = [ \"all\", 'strings', \"\"\"are the same\"\"\", '''type''' ]\n\n# Mixed-type arrays are allowed\nnumbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ]\ncontributors = [\n \"Foo Bar \",\n { name = \"Baz Qux\", email = \"bazqux@example.com\", url = \"https://example.com/bazqux\" }\n]\n" + jsonRef := "{\n \"colors\": [\n {\"type\": \"string\", \"value\": \"red\"},\n {\"type\": \"string\", \"value\": \"yellow\"},\n {\"type\": \"string\", \"value\": \"green\"}\n ],\n \"contributors\": [\n {\"type\": \"string\", \"value\": \"Foo Bar \\u003cfoo@example.com\\u003e\"},\n {\n \"email\": {\"type\": \"string\", \"value\": \"bazqux@example.com\"},\n \"name\": {\"type\": \"string\", \"value\": \"Baz Qux\"},\n \"url\": {\"type\": \"string\", \"value\": \"https://example.com/bazqux\"}\n }\n ],\n \"integers\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"nested_arrays_of_ints\": [\n [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n [\n {\"type\": \"integer\", \"value\": \"3\"},\n {\"type\": \"integer\", \"value\": \"4\"},\n {\"type\": \"integer\", \"value\": \"5\"}\n ]\n ],\n \"nested_mixed_array\": [\n [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ],\n [\n {\"type\": \"string\", \"value\": \"a\"},\n {\"type\": \"string\", \"value\": \"b\"},\n {\"type\": \"string\", \"value\": \"c\"}\n ]\n ],\n \"numbers\": [\n {\"type\": \"float\", \"value\": \"0.1\"},\n {\"type\": \"float\", \"value\": \"0.2\"},\n {\"type\": \"float\", \"value\": \"0.5\"},\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"5\"}\n ],\n \"string_array\": [\n {\"type\": \"string\", \"value\": \"all\"},\n {\"type\": \"string\", \"value\": \"strings\"},\n {\"type\": \"string\", \"value\": \"are the same\"},\n {\"type\": \"string\", \"value\": \"type\"}\n ]\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common36(t *testing.T) { + input := "integers2 = [\n 1, 2, 3\n]\n\nintegers3 = [\n 1,\n 2, # this is ok\n]\n" + jsonRef := "{\n \"integers2\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"},\n {\"type\": \"integer\", \"value\": \"3\"}\n ],\n \"integers3\": [\n {\"type\": \"integer\", \"value\": \"1\"},\n {\"type\": \"integer\", \"value\": \"2\"}\n ]\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common37(t *testing.T) { input := "[table]\n" jsonRef := "{\n \"table\": {}\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table1(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common38(t *testing.T) { input := "[table-1]\nkey1 = \"some string\"\nkey2 = 123\n\n[table-2]\nkey1 = \"another string\"\nkey2 = 456\n" jsonRef := "{\n \"table-1\": {\n \"key1\": {\"type\": \"string\", \"value\": \"some string\"},\n \"key2\": {\"type\": \"integer\", \"value\": \"123\"}\n },\n \"table-2\": {\n \"key1\": {\"type\": \"string\", \"value\": \"another string\"},\n \"key2\": {\"type\": \"integer\", \"value\": \"456\"}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table2(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common39(t *testing.T) { input := "[dog.\"tater.man\"]\ntype.name = \"pug\"\n" jsonRef := "{\n \"dog\": {\n \"tater.man\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"pug\"}\n }\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table3(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common4(t *testing.T) { + input := "\"127.0.0.1\" = \"value\"\n\"character encoding\" = \"value\"\n\"ʎǝʞ\" = \"value\"\n'key2' = \"value\"\n'quoted \"value\"' = \"value\"\n" + jsonRef := "{\n \"127.0.0.1\": {\"type\": \"string\", \"value\": \"value\"},\n \"character encoding\": {\"type\": \"string\", \"value\": \"value\"},\n \"key2\": {\"type\": \"string\", \"value\": \"value\"},\n \"quoted \\\"value\\\"\": {\"type\": \"string\", \"value\": \"value\"},\n \"ʎǝʞ\": {\"type\": \"string\", \"value\": \"value\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common40(t *testing.T) { input := "[a.b.c] # this is best practice\n[ d.e.f ] # same as [d.e.f]\n[ g . h . i ] # same as [g.h.i]\n[ j . \"ʞ\" . 'l' ] # same as [j.\"ʞ\".'l']\n" jsonRef := "{\n \"a\": {\n \"b\": {\n \"c\": {}\n }\n },\n \"d\": {\n \"e\": {\n \"f\": {}\n }\n },\n \"g\": {\n \"h\": {\n \"i\": {}\n }\n },\n \"j\": {\n \"ʞ\": {\n \"l\": {}\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table4(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common41(t *testing.T) { input := "# [x] you\n# [x.y] don't\n# [x.y.z] need these\n[x.y.z.w] # for this to work\n\n[x] # defining a super-table afterward is ok\n" jsonRef := "{\n \"x\": {\n \"y\": {\n \"z\": {\n \"w\": {}\n }\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table5(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common42(t *testing.T) { input := "# VALID BUT DISCOURAGED\n[fruit.apple]\n[animal]\n[fruit.orange]\n" jsonRef := "{\n \"animal\": {},\n \"fruit\": {\n \"apple\": {},\n \"orange\": {}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table6(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common43(t *testing.T) { input := "# RECOMMENDED\n[fruit.apple]\n[fruit.orange]\n[animal]\n" jsonRef := "{\n \"animal\": {},\n \"fruit\": {\n \"apple\": {},\n \"orange\": {}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table7(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common44(t *testing.T) { input := "# Top-level table begins.\nname = \"Fido\"\nbreed = \"pug\"\n\n# Top-level table ends.\n[owner]\nname = \"Regina Dogman\"\nmember_since = 1999-08-04\n" jsonRef := "{\n \"breed\": {\"type\": \"string\", \"value\": \"pug\"},\n \"name\": {\"type\": \"string\", \"value\": \"Fido\"},\n \"owner\": {\n \"member_since\": {\"type\": \"date-local\", \"value\": \"1999-08-04\"},\n \"name\": {\"type\": \"string\", \"value\": \"Regina Dogman\"}\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table8(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common45(t *testing.T) { input := "fruit.apple.color = \"red\"\n# Defines a table named fruit\n# Defines a table named fruit.apple\n\nfruit.apple.taste.sweet = true\n# Defines a table named fruit.apple.taste\n# fruit and fruit.apple were already created\n" jsonRef := "{\n \"fruit\": {\n \"apple\": {\n \"color\": {\"type\": \"string\", \"value\": \"red\"},\n \"taste\": {\n \"sweet\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_Spec_Table9(t *testing.T) { +func TestTOMLTest_Valid_Spec1_1_0_Common46(t *testing.T) { input := "[fruit]\napple.color = \"red\"\napple.taste.sweet = true\n\n# [fruit.apple] # INVALID\n# [fruit.apple.taste] # INVALID\n\n[fruit.apple.texture] # you can add sub-tables\nsmooth = true\n" jsonRef := "{\n \"fruit\": {\n \"apple\": {\n \"color\": {\"type\": \"string\", \"value\": \"red\"},\n \"taste\": {\n \"sweet\": {\"type\": \"bool\", \"value\": \"true\"}\n },\n \"texture\": {\n \"smooth\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n }\n }\n}\n" testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_String_DoubleQuoteEscape(t *testing.T) { - input := "test = \"\\\"one\\\"\"\n" +func TestTOMLTest_Valid_Spec1_1_0_Common47(t *testing.T) { + input := "name = { first = \"Tom\", last = \"Preston-Werner\" }\npoint = {x=1, y=2}\nanimal = { type.name = \"pug\" }\ncontact = {\n personal = {\n name = \"Donald Duck\",\n email = \"donald@duckburg.com\",\n },\n work = {\n name = \"Coin cleaner\",\n email = \"donald@ScroogeCorp.com\",\n },\n}\n" + jsonRef := "{\n \"animal\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"pug\"}\n }\n },\n \"contact\": {\n \"personal\": {\n \"email\": {\"type\": \"string\", \"value\": \"donald@duckburg.com\"},\n \"name\": {\"type\": \"string\", \"value\": \"Donald Duck\"}\n },\n \"work\": {\n \"email\": {\"type\": \"string\", \"value\": \"donald@ScroogeCorp.com\"},\n \"name\": {\"type\": \"string\", \"value\": \"Coin cleaner\"}\n }\n },\n \"name\": {\n \"first\": {\"type\": \"string\", \"value\": \"Tom\"},\n \"last\": {\"type\": \"string\", \"value\": \"Preston-Werner\"}\n },\n \"point\": {\n \"x\": {\"type\": \"integer\", \"value\": \"1\"},\n \"y\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common48(t *testing.T) { + input := "[name]\nfirst = \"Tom\"\nlast = \"Preston-Werner\"\n\n[point]\nx = 1\ny = 2\n\n[animal]\ntype.name = \"pug\"\n\n[contact.personal]\nname = \"Donald Duck\"\nemail = \"donald@duckburg.com\"\n\n[contact.work]\nname = \"Coin cleaner\"\nemail = \"donald@ScroogeCorp.com\"\n" + jsonRef := "{\n \"animal\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"pug\"}\n }\n },\n \"contact\": {\n \"personal\": {\n \"email\": {\"type\": \"string\", \"value\": \"donald@duckburg.com\"},\n \"name\": {\"type\": \"string\", \"value\": \"Donald Duck\"}\n },\n \"work\": {\n \"email\": {\"type\": \"string\", \"value\": \"donald@ScroogeCorp.com\"},\n \"name\": {\"type\": \"string\", \"value\": \"Coin cleaner\"}\n }\n },\n \"name\": {\n \"first\": {\"type\": \"string\", \"value\": \"Tom\"},\n \"last\": {\"type\": \"string\", \"value\": \"Preston-Werner\"}\n },\n \"point\": {\n \"x\": {\"type\": \"integer\", \"value\": \"1\"},\n \"y\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common49(t *testing.T) { + input := "[product]\ntype = { name = \"Nail\" }\n# type.edible = false # INVALID\n" + jsonRef := "{\n \"product\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"Nail\"}\n }\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common50(t *testing.T) { + input := "[product]\ntype.name = \"Nail\"\n# type = { edible = false } # INVALID\n" + jsonRef := "{\n \"product\": {\n \"type\": {\n \"name\": {\"type\": \"string\", \"value\": \"Nail\"}\n }\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common51(t *testing.T) { + input := "[[product]]\nname = \"Hammer\"\nsku = 738594937\n\n[[product]] # empty table within the array\n\n[[product]]\nname = \"Nail\"\nsku = 284758393\n\ncolor = \"gray\"\n" + jsonRef := "{\n \"product\": [\n {\n \"name\": {\"type\": \"string\", \"value\": \"Hammer\"},\n \"sku\": {\"type\": \"integer\", \"value\": \"738594937\"}\n },\n {},\n {\n \"color\": {\"type\": \"string\", \"value\": \"gray\"},\n \"name\": {\"type\": \"string\", \"value\": \"Nail\"},\n \"sku\": {\"type\": \"integer\", \"value\": \"284758393\"}\n }\n ]\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common52(t *testing.T) { + input := "[[fruits]]\nname = \"apple\"\n\n[fruits.physical] # subtable\ncolor = \"red\"\nshape = \"round\"\n\n[[fruits.varieties]] # nested array of tables\nname = \"red delicious\"\n\n[[fruits.varieties]]\nname = \"granny smith\"\n\n\n[[fruits]]\nname = \"banana\"\n\n[[fruits.varieties]]\nname = \"plantain\"\n" + jsonRef := "{\n \"fruits\": [\n {\n \"name\": {\"type\": \"string\", \"value\": \"apple\"},\n \"physical\": {\n \"color\": {\"type\": \"string\", \"value\": \"red\"},\n \"shape\": {\"type\": \"string\", \"value\": \"round\"}\n },\n \"varieties\": [\n {\n \"name\": {\"type\": \"string\", \"value\": \"red delicious\"}\n },\n {\n \"name\": {\"type\": \"string\", \"value\": \"granny smith\"}\n }\n ]\n },\n {\n \"name\": {\"type\": \"string\", \"value\": \"banana\"},\n \"varieties\": [{\n \"name\": {\"type\": \"string\", \"value\": \"plantain\"}\n }]\n }\n ]\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common53(t *testing.T) { + input := "points = [ { x = 1, y = 2, z = 3 },\n { x = 7, y = 8, z = 9 },\n { x = 2, y = 4, z = 8 } ]\n" + jsonRef := "{\n \"points\": [\n {\n \"x\": {\"type\": \"integer\", \"value\": \"1\"},\n \"y\": {\"type\": \"integer\", \"value\": \"2\"},\n \"z\": {\"type\": \"integer\", \"value\": \"3\"}\n },\n {\n \"x\": {\"type\": \"integer\", \"value\": \"7\"},\n \"y\": {\"type\": \"integer\", \"value\": \"8\"},\n \"z\": {\"type\": \"integer\", \"value\": \"9\"}\n },\n {\n \"x\": {\"type\": \"integer\", \"value\": \"2\"},\n \"y\": {\"type\": \"integer\", \"value\": \"4\"},\n \"z\": {\"type\": \"integer\", \"value\": \"8\"}\n }\n ]\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common6(t *testing.T) { + input := "name = \"Orange\"\nphysical.color = \"orange\"\nphysical.shape = \"round\"\nsite.\"google.com\" = true\n" + jsonRef := "{\n \"name\": {\"type\": \"string\", \"value\": \"Orange\"},\n \"physical\": {\n \"color\": {\"type\": \"string\", \"value\": \"orange\"},\n \"shape\": {\"type\": \"string\", \"value\": \"round\"}\n },\n \"site\": {\n \"google.com\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common7(t *testing.T) { + input := "fruit.name = \"banana\" # this is best practice\nfruit. color = \"yellow\" # same as fruit.color\nfruit . flavor = \"banana\" # same as fruit.flavor\n" + jsonRef := "{\n \"fruit\": {\n \"color\": {\"type\": \"string\", \"value\": \"yellow\"},\n \"flavor\": {\"type\": \"string\", \"value\": \"banana\"},\n \"name\": {\"type\": \"string\", \"value\": \"banana\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common8(t *testing.T) { + input := "# This makes the key \"fruit\" into a table.\nfruit.apple.smooth = true\n\n# So then you can add to the table \"fruit\" like so:\nfruit.orange = 2\n" + jsonRef := "{\n \"fruit\": {\n \"orange\": {\"type\": \"integer\", \"value\": \"2\"},\n \"apple\": {\n \"smooth\": {\"type\": \"bool\", \"value\": \"true\"}\n }\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Spec1_1_0_Common9(t *testing.T) { + input := "# VALID BUT DISCOURAGED\n\napple.type = \"fruit\"\norange.type = \"fruit\"\n\napple.skin = \"thin\"\norange.skin = \"thick\"\n\napple.color = \"red\"\norange.color = \"orange\"\n" + jsonRef := "{\n \"apple\": {\n \"color\": {\"type\": \"string\", \"value\": \"red\"},\n \"skin\": {\"type\": \"string\", \"value\": \"thin\"},\n \"type\": {\"type\": \"string\", \"value\": \"fruit\"}\n },\n \"orange\": {\n \"color\": {\"type\": \"string\", \"value\": \"orange\"},\n \"skin\": {\"type\": \"string\", \"value\": \"thick\"},\n \"type\": {\"type\": \"string\", \"value\": \"fruit\"}\n }\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_String_BasicEscape01(t *testing.T) { + input := "# Escape \"\ntest = \"\\\"one\\\"\"\n" jsonRef := "{\n \"test\": {\"type\": \"string\", \"value\": \"\\\"one\\\"\"}\n}\n" testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_String_BasicEscape02(t *testing.T) { + input := "# Escape \\ and then \"\ntest = \"\\\\\\\"one\"\n" + jsonRef := "{\n \"test\": {\"type\": \"string\", \"value\": \"\\\\\\\"one\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_String_BasicEscape03(t *testing.T) { + input := "# Escape \\ four times and then \"\ntest = \"\\\\\\\\\\\\\\\\\\\"one\"\n" + jsonRef := "{\n \"test\": {\"type\": \"string\", \"value\": \"\\\\\\\\\\\\\\\\\\\"one\"}\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_String_Empty(t *testing.T) { input := "answer = \"\"\n" jsonRef := "{\n \"answer\": {\"type\": \"string\", \"value\": \"\"}\n}\n" @@ -2661,6 +3271,12 @@ func TestTOMLTest_Valid_String_EndsInWhitespaceEscape(t *testing.T) { testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_String_EscapeEsc(t *testing.T) { + input := "esc = \"\\e There is no escape! \\e\"\n" + jsonRef := "{\n \"esc\": {\"type\": \"string\", \"value\": \"\\u001b There is no escape! \\u001b\"}\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_String_EscapeTricky(t *testing.T) { input := "end_esc = \"String does not end here\\\" but ends here\\\\\"\nlit_end_esc = 'String ends here\\'\n\nmultiline_unicode = \"\"\"\n\\u00a0\"\"\"\n\nmultiline_not_unicode = \"\"\"\n\\\\u0041\"\"\"\n\nmultiline_end_esc = \"\"\"When will it end? \\\"\"\"...\"\"\\\" should be here\\\"\"\"\"\n\nlit_multiline_not_unicode = '''\n\\u007f'''\n\nlit_multiline_end = '''There is no escape\\'''\n" jsonRef := "{\n \"end_esc\": {\"type\": \"string\", \"value\": \"String does not end here\\\" but ends here\\\\\"},\n \"lit_end_esc\": {\"type\": \"string\", \"value\": \"String ends here\\\\\"},\n \"lit_multiline_end\": {\"type\": \"string\", \"value\": \"There is no escape\\\\\"},\n \"lit_multiline_not_unicode\": {\"type\": \"string\", \"value\": \"\\\\u007f\"},\n \"multiline_end_esc\": {\"type\": \"string\", \"value\": \"When will it end? \\\"\\\"\\\"...\\\"\\\"\\\" should be here\\\"\"},\n \"multiline_not_unicode\": {\"type\": \"string\", \"value\": \"\\\\u0041\"},\n \"multiline_unicode\": {\"type\": \"string\", \"value\": \"\u00a0\"}\n}\n" @@ -2679,6 +3295,24 @@ func TestTOMLTest_Valid_String_Escapes(t *testing.T) { testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_String_HexEscape(t *testing.T) { + input := "# \\x for the first 255 codepoints\n\nwhitespace = \"\\x20 \\x09 \\x1b \\x0d\\x0a\"\nbs = \"\\x7f\"\nnul = \"\\x00\"\nhello = \"\\x68\\x65\\x6c\\x6c\\x6f\\x0a\"\nhigher-than-127 = \"S\\xf8rmirb\\xe6ren\"\n\nmultiline = \"\"\"\n\\x20 \\x09 \\x1b \\x0d\\x0a\n\\x7f\n\\x00\n\\x68\\x65\\x6c\\x6c\\x6f\\x0a\n\\x53\\xF8\\x72\\x6D\\x69\\x72\\x62\\xE6\\x72\\x65\\x6E\n\"\"\"\n\n# Not inside literals.\nliteral = '\\x20 \\x09 \\x0d\\x0a'\nmultiline-literal = '''\n\\x20 \\x09 \\x0d\\x0a\n'''\n" + jsonRef := "{\n \"bs\": {\"type\": \"string\", \"value\": \"\x7f\"},\n \"hello\": {\"type\": \"string\", \"value\": \"hello\\n\"},\n \"higher-than-127\": {\"type\": \"string\", \"value\": \"Sørmirbæren\"},\n \"literal\": {\"type\": \"string\", \"value\": \"\\\\x20 \\\\x09 \\\\x0d\\\\x0a\"},\n \"multiline\": {\"type\": \"string\", \"value\": \" \\t \\u001b \\r\\n\\n\x7f\\n\\u0000\\nhello\\n\\nSørmirbæren\\n\"},\n \"multiline-literal\": {\"type\": \"string\", \"value\": \"\\\\x20 \\\\x09 \\\\x0d\\\\x0a\\n\"},\n \"nul\": {\"type\": \"string\", \"value\": \"\\u0000\"},\n \"whitespace\": {\"type\": \"string\", \"value\": \" \\t \\u001b \\r\\n\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_String_MultibyteEscape(t *testing.T) { + input := "# Test each multibyte length: 2, 3, and 4 bytes:\n# ɑ € 𐫱\n\nbasic-1 = \"\\u0251 \\u20ac \\U00010AF1 \\u0251\\u20ac\\U00010AF1\"\nml-basic-1 = \"\"\"\\u0251 \\u20ac \\U00010AF1 \\u0251\\u20ac\\U00010AF1\"\"\"\n\n# Again, but only using \\U\nbasic-2 = \"\\U00000251 \\U000020ac \\U00010AF1 \\U00000251\\U000020ac\\U00010AF1\"\nml-basic-2 = \"\"\"\\U00000251 \\U000020ac \\U00010AF1 \\U00000251\\U000020ac\\U00010AF1\"\"\"\n" + jsonRef := "{\n \"basic-1\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"},\n \"ml-basic-1\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"},\n \"basic-2\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"},\n \"ml-basic-2\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"}\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_String_Multibyte(t *testing.T) { + input := "# Test each multibyte length: 2, 3, and 4 bytes:\n# ɑ € 𐫱\n\nbasic = \"ɑ € 𐫱 ɑ€𐫱\"\nraw = 'ɑ € 𐫱 ɑ€𐫱'\nml-basic = \"\"\"ɑ € 𐫱 ɑ€𐫱\"\"\"\nml-raw = '''ɑ € 𐫱 ɑ€𐫱'''\n" + jsonRef := "{\n \"basic\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"},\n \"ml-basic\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"},\n \"ml-raw\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"},\n \"raw\": {\"type\": \"string\", \"value\": \"ɑ € 𐫱 ɑ€𐫱\"}\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_String_MultilineEmpty(t *testing.T) { input := "empty-1 = \"\"\"\"\"\"\n\n# A newline immediately following the opening delimiter will be trimmed.\nempty-2 = \"\"\"\n\"\"\"\n\n# \\ at the end of line trims newlines as well; note that last \\ is followed by\n# two spaces, which are ignored.\nempty-3 = \"\"\"\\\n \"\"\"\nempty-4 = \"\"\"\\\n \\\n \\ \n \"\"\"\n\n" jsonRef := "{\n \"empty-1\": {\"type\": \"string\", \"value\": \"\"},\n \"empty-2\": {\"type\": \"string\", \"value\": \"\"},\n \"empty-3\": {\"type\": \"string\", \"value\": \"\"},\n \"empty-4\": {\"type\": \"string\", \"value\": \"\"}\n}\n" @@ -2715,6 +3349,12 @@ func TestTOMLTest_Valid_String_QuotedUnicode(t *testing.T) { testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_String_RawEmpty(t *testing.T) { + input := "empty = ''\n" + jsonRef := "{\n \"empty\": {\"type\": \"string\", \"value\": \"\"}\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_String_RawMultiline(t *testing.T) { input := "# Single ' should be allowed.\noneline = '''This string has a ' quote character.'''\n\n# A newline immediately following the opening delimiter will be trimmed.\nfirstnl = '''\nThis string has a ' quote character.'''\n\n# All other whitespace and newline characters remain intact.\nmultiline = '''\nThis string\nhas ' a quote character\nand more than\none newline\nin it.'''\n\n# Tab character in literal string does not need to be escaped\nmultiline_with_tab = '''First line\n\t Followed by a tab'''\n\nthis-str-has-apostrophes='''' there's one already\n'' two more\n'''''\n" jsonRef := "{\n \"firstnl\": {\"type\": \"string\", \"value\": \"This string has a ' quote character.\"},\n \"multiline\": {\"type\": \"string\", \"value\": \"This string\\nhas ' a quote character\\nand more than\\none newline\\nin it.\"},\n \"multiline_with_tab\": {\"type\": \"string\", \"value\": \"First line\\n\\t Followed by a tab\"},\n \"oneline\": {\"type\": \"string\", \"value\": \"This string has a ' quote character.\"},\n \"this-str-has-apostrophes\": {\"type\": \"string\", \"value\": \"' there's one already\\n'' two more\\n''\"}\n}\n" @@ -2745,18 +3385,24 @@ func TestTOMLTest_Valid_String_UnicodeEscape(t *testing.T) { testgenValid(t, input, jsonRef) } -func TestTOMLTest_Valid_String_UnicodeLiteral(t *testing.T) { - input := "answer = \"δ\"\n" - jsonRef := "{\n \"answer\": {\"type\": \"string\", \"value\": \"δ\"}\n}\n" - testgenValid(t, input, jsonRef) -} - func TestTOMLTest_Valid_String_WithPound(t *testing.T) { input := "pound = \"We see no # comments here.\"\npoundcomment = \"But there are # some comments here.\" # Did I # mess you up?\n" jsonRef := "{\n \"pound\": {\"type\": \"string\", \"value\": \"We see no # comments here.\"},\n \"poundcomment\": {\"type\": \"string\", \"value\": \"But there are # some comments here.\"}\n}\n" testgenValid(t, input, jsonRef) } +func TestTOMLTest_Valid_Table_ArrayEmptyName(t *testing.T) { + input := "# Silly thing to do, but valid.\n\n[['']]\na = 1\n[['']]\na = 2\n" + jsonRef := "{\n \"\": [\n {\"a\": {\"type\": \"integer\", \"value\": \"1\"}},\n {\"a\": {\"type\": \"integer\", \"value\": \"2\"}}\n ]\n}\n" + testgenValid(t, input, jsonRef) +} + +func TestTOMLTest_Valid_Table_ArrayEmpty(t *testing.T) { + input := "[[a]]\n" + jsonRef := "{\n \"a\": [{}]\n}\n" + testgenValid(t, input, jsonRef) +} + func TestTOMLTest_Valid_Table_ArrayImplicitAndExplicitAfter(t *testing.T) { input := "[[a.b]]\nx = 1\n\n[a]\ny = 2\n" jsonRef := "{\n \"a\": {\n \"b\": [{\n \"x\": {\"type\": \"integer\", \"value\": \"1\"}\n }],\n \"y\": {\"type\": \"integer\", \"value\": \"2\"}\n }\n}\n"