Skip to content

Commit fe6162e

Browse files
authored
toml, tests: support v2.0.0 of the test-suite at toml-lang/toml-test@229ce2e (#26101)
1 parent 4c9564e commit fe6162e

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

.github/workflows/download_full_toml_test_suites.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rm -rf vlib/toml/tests/testdata/iarna vlib/toml/tests/testdata/toml_rs vlib/toml
1010
git -C vlib/toml/tests/testdata/iarna checkout 1880b1a
1111

1212
./v retry -- git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/toml_lang
13-
git -C vlib/toml/tests/testdata/toml_lang checkout 8bb8d9c
13+
git -C vlib/toml/tests/testdata/toml_lang checkout 229ce2e
1414

1515
# A few history notes of toml-rs (previously alexcrichton):
1616
# commit 7f5472c the test-suite dir moves to the crates/ sub-directory

vlib/toml/parser/parser.v

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ pub fn (mut p Parser) time() !ast.Time {
15411541
lit += p.tok.lit
15421542
p.check(.number)!
15431543
lit += p.tok.lit
1544-
// TODO: does TOML even have optional seconds?
1544+
// NOTE: TOML v1.1.0 have optional seconds
15451545
// if p.peek_tok.kind == .colon {
15461546
p.check(.colon)!
15471547
lit += p.tok.lit
@@ -1557,6 +1557,11 @@ pub fn (mut p Parser) time() !ast.Time {
15571557
p.expect(.number)!
15581558
}
15591559

1560+
if !lit[lit.len - 1].is_digit() {
1561+
return error(@MOD + '.' + @STRUCT + '.' + @FN +
1562+
' expected a number as last occurrence in "${lit}" got "${lit[lit.len - 1].ascii_str()}"')
1563+
}
1564+
15601565
// Parse offset
15611566
if p.peek_tok.kind == .minus || p.peek_tok.kind == .plus {
15621567
p.next()!

vlib/toml/tests/toml_lang_test.v

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Instructions for developers:
22
// The actual tests and data can be obtained by doing:
33
// `git clone -n https://github.com/toml-lang/toml-test.git vlib/toml/tests/testdata/toml_lang`
4-
// `git -C vlib/toml/tests/testdata/toml_lang reset --hard 8bb8d9c
4+
// `git -C vlib/toml/tests/testdata/toml_lang reset --hard 229ce2e
55
// See also the CI toml tests
66
import os
77
import toml
@@ -14,7 +14,8 @@ const test_files_file = os.join_path(test_root, 'files-toml-1.0.0')
1414
const hide_oks = os.getenv('VTEST_HIDE_OK') == '1'
1515
const no_jq = os.getenv('VNO_JQ') == '1'
1616

17-
// Kept for easier handling of future updates to the tests
17+
// Kept for easier lookup and handling of future updates to the tests.
18+
// NOTE: entries in this list are valid TOML that the parser should work with, but currently does not.
1819
const valid_exceptions = [
1920
'do_not_remove',
2021
'array/open-parent-table.toml',
@@ -26,19 +27,25 @@ const valid_exceptions = [
2627
'table/array-implicit-and-explicit-after.toml',
2728
'table/array-within-dotted.toml',
2829
]
29-
const jq_not_equal = [
30-
'do_not_remove',
31-
]
30+
// NOTE: entries in this list are tests of invalid TOML that should have the parser fail, but currently does not.
3231
const invalid_exceptions = [
3332
'do_not_remove',
34-
'inline-table/duplicate-key-2.toml',
35-
'string/multiline-escape-space-2.toml',
33+
'key/duplicate-keys-06.toml',
34+
'inline-table/duplicate-key-02.toml',
35+
'string/multiline-escape-space-02.toml',
36+
'string/missing-quotes-array.toml',
3637
'table/duplicate-key-dotted-array.toml',
37-
'table/redefine-2.toml',
38+
'table/append-with-dotted-keys-05.toml',
39+
'table/duplicate-key-03.toml',
40+
'table/duplicate-key-10.toml',
41+
'table/redefine-02.toml',
3842
]
3943
const valid_value_exceptions = [
4044
'do_not_remove',
4145
]
46+
const jq_not_equal = [
47+
'do_not_remove',
48+
]
4249

4350
const jq = os.find_abs_path_of_executable('jq') or { '' }
4451
const compare_work_dir_root = os.join_path(os.vtmp_dir(), 'toml_toml_lang')

0 commit comments

Comments
 (0)