From fe6162e94dcb8669f7512edd5d39da10a3cc6c5b Mon Sep 17 00:00:00 2001 From: larpon <768942+larpon@users.noreply.github.com> Date: Wed, 24 Dec 2025 10:33:17 +0100 Subject: [PATCH] toml, tests: support v2.0.0 of the test-suite at toml-lang/toml-test@229ce2e (#26101) --- .../download_full_toml_test_suites.sh | 2 +- vlib/toml/parser/parser.v | 7 +++++- vlib/toml/tests/toml_lang_test.v | 23 ++++++++++++------- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/download_full_toml_test_suites.sh b/.github/workflows/download_full_toml_test_suites.sh index ed89a4527..764c5bd35 100755 --- a/.github/workflows/download_full_toml_test_suites.sh +++ b/.github/workflows/download_full_toml_test_suites.sh @@ -10,7 +10,7 @@ rm -rf vlib/toml/tests/testdata/iarna vlib/toml/tests/testdata/toml_rs vlib/toml git -C vlib/toml/tests/testdata/iarna checkout 1880b1a ./v retry -- git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/toml_lang -git -C vlib/toml/tests/testdata/toml_lang checkout 8bb8d9c +git -C vlib/toml/tests/testdata/toml_lang checkout 229ce2e # A few history notes of toml-rs (previously alexcrichton): # commit 7f5472c the test-suite dir moves to the crates/ sub-directory diff --git a/vlib/toml/parser/parser.v b/vlib/toml/parser/parser.v index 542407617..f698eb441 100644 --- a/vlib/toml/parser/parser.v +++ b/vlib/toml/parser/parser.v @@ -1541,7 +1541,7 @@ pub fn (mut p Parser) time() !ast.Time { lit += p.tok.lit p.check(.number)! lit += p.tok.lit - // TODO: does TOML even have optional seconds? + // NOTE: TOML v1.1.0 have optional seconds // if p.peek_tok.kind == .colon { p.check(.colon)! lit += p.tok.lit @@ -1557,6 +1557,11 @@ pub fn (mut p Parser) time() !ast.Time { p.expect(.number)! } + if !lit[lit.len - 1].is_digit() { + return error(@MOD + '.' + @STRUCT + '.' + @FN + + ' expected a number as last occurrence in "${lit}" got "${lit[lit.len - 1].ascii_str()}"') + } + // Parse offset if p.peek_tok.kind == .minus || p.peek_tok.kind == .plus { p.next()! diff --git a/vlib/toml/tests/toml_lang_test.v b/vlib/toml/tests/toml_lang_test.v index 1bf0e3421..c87e8e7e2 100644 --- a/vlib/toml/tests/toml_lang_test.v +++ b/vlib/toml/tests/toml_lang_test.v @@ -1,7 +1,7 @@ // Instructions for developers: // The actual tests and data can be obtained by doing: // `git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/toml_lang` -// `git -C vlib/toml/tests/testdata/toml_lang reset --hard 8bb8d9c +// `git -C vlib/toml/tests/testdata/toml_lang reset --hard 229ce2e // See also the CI toml tests import os import toml @@ -14,7 +14,8 @@ const test_files_file = os.join_path(test_root, 'files-toml-1.0.0') const hide_oks = os.getenv('VTEST_HIDE_OK') == '1' const no_jq = os.getenv('VNO_JQ') == '1' -// Kept for easier handling of future updates to the tests +// Kept for easier lookup and handling of future updates to the tests. +// NOTE: entries in this list are valid TOML that the parser should work with, but currently does not. const valid_exceptions = [ 'do_not_remove', 'array/open-parent-table.toml', @@ -26,19 +27,25 @@ const valid_exceptions = [ 'table/array-implicit-and-explicit-after.toml', 'table/array-within-dotted.toml', ] -const jq_not_equal = [ - 'do_not_remove', -] +// NOTE: entries in this list are tests of invalid TOML that should have the parser fail, but currently does not. const invalid_exceptions = [ 'do_not_remove', - 'inline-table/duplicate-key-2.toml', - 'string/multiline-escape-space-2.toml', + 'key/duplicate-keys-06.toml', + 'inline-table/duplicate-key-02.toml', + 'string/multiline-escape-space-02.toml', + 'string/missing-quotes-array.toml', 'table/duplicate-key-dotted-array.toml', - 'table/redefine-2.toml', + 'table/append-with-dotted-keys-05.toml', + 'table/duplicate-key-03.toml', + 'table/duplicate-key-10.toml', + 'table/redefine-02.toml', ] const valid_value_exceptions = [ 'do_not_remove', ] +const jq_not_equal = [ + 'do_not_remove', +] const jq = os.find_abs_path_of_executable('jq') or { '' } const compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml_toml_lang') -- 2.39.5