Skip to content

Commit 2024b48

Browse files
authored
toml: add compliance to official toml-lang/toml-test@8bb8d9c (#26070)
1 parent 3a4c664 commit 2024b48

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
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 c6a78f1
13+
git -C vlib/toml/tests/testdata/toml_lang checkout 8bb8d9c
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/checker/checker.v

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,32 @@ fn (c &Checker) check_time(t ast.Time) ! {
405405
' "${lit}" is not a valid RFC 3339 Time format string in ...${c.excerpt(t.pos)}...')
406406
}
407407

408+
if parts.len > 1 {
409+
// Offset
410+
offset_parts := parts[1].split(':')
411+
if offset_parts.len != 2 {
412+
return error(@MOD + '.' + @STRUCT + '.' + @FN +
413+
' "${parts[1]}" is not a valid RFC 3339 time offset specifier in ...${c.excerpt(t.pos)}...')
414+
}
415+
hh := offset_parts[0].int()
416+
if hh < 0 || hh > 24 {
417+
pos := token.Pos{
418+
...t.pos
419+
pos: t.pos.pos + check_length
420+
}
421+
return error(@MOD + '.' + @STRUCT + '.' + @FN +
422+
' "${hh}" hour specifier in "${parts[1]}" should be between 00 and 24 in ...${c.excerpt(pos)}...')
423+
}
424+
mm := offset_parts[1].int()
425+
if mm < 0 || mm > 59 {
426+
pos := token.Pos{
427+
...t.pos
428+
pos: t.pos.pos + check_length
429+
}
430+
return error(@MOD + '.' + @STRUCT + '.' + @FN +
431+
' "${mm}" second specifier in "${parts[1]}" should be between 00 and 59 in ...${c.excerpt(pos)}...')
432+
}
433+
}
408434
// Simulate a time offset if it's missing then it can be checked. Already toml supports local time and rfc3339 don't.
409435
mut has_time_offset := false
410436
for ch in parts[0]#[8..] {

vlib/toml/tests/toml_lang_test.v

Lines changed: 1 addition & 1 deletion
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 c6a78f1
4+
// `git -C vlib/toml/tests/testdata/toml_lang reset --hard 8bb8d9c
55
// See also the CI toml tests
66
import os
77
import toml

0 commit comments

Comments
 (0)