Skip to content

Commit b2e48aa

Browse files
xokdviumemilazy
authored andcommitted
tests/functional/lang: Add more tests for TOML timestamps
Current test suite doesn't cover the subsecond formatting at all and toml11 is quite finicky with that. We should at the very least test its behavior to avoid silent breakages on updates. (cherry picked from commit 7ed0229d1abd4414144c7af396842462ce6fc1eb) Upstream-PR: NixOS/nix#13741 Change-Id: I6a6a696433b168072d6ad2585dce8a3c10ccbc39
1 parent c586596 commit b2e48aa

3 files changed

Lines changed: 89 additions & 5 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; ld1 = { _type = "timestamp"; value = "1979-05-27"; }; ldt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00"; }; ldt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999"; }; lt1 = { _type = "timestamp"; value = "07:32:00"; }; lt2 = { _type = "timestamp"; value = "00:32:00.999999"; }; name = "Orange"; oct1 = 342391; oct2 = 493; odt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; odt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00-07:00"; }; odt3 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999-07:00"; }; odt4 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; }
1+
{ "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; ld1 = { _type = "timestamp"; value = "1979-05-27"; }; ldt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00"; }; ldt10 = { _type = "timestamp"; value = "1979-05-27T00:32:00.123456789"; }; ldt11 = { _type = "timestamp"; value = "1979-05-27T00:32:00.123456789"; }; ldt2 = { _type = "timestamp"; value = "1979-05-27T07:32:00.100"; }; ldt3 = { _type = "timestamp"; value = "1979-05-27T07:32:00.120"; }; ldt4 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123"; }; ldt5 = { _type = "timestamp"; value = "1979-05-27T00:32:00.123400"; }; ldt6 = { _type = "timestamp"; value = "1979-05-27T00:32:00.123450"; }; ldt7 = { _type = "timestamp"; value = "1979-05-27T00:32:00.123456"; }; ldt8 = { _type = "timestamp"; value = "1979-05-27T00:32:00.123456700"; }; ldt9 = { _type = "timestamp"; value = "1979-05-27T00:32:00.123456780"; }; lt1 = { _type = "timestamp"; value = "07:32:00"; }; lt10 = { _type = "timestamp"; value = "00:32:00.123456789"; }; lt11 = { _type = "timestamp"; value = "00:32:00.123456789"; }; lt2 = { _type = "timestamp"; value = "00:32:00.100"; }; lt3 = { _type = "timestamp"; value = "00:32:00.120"; }; lt4 = { _type = "timestamp"; value = "00:32:00.123"; }; lt5 = { _type = "timestamp"; value = "00:32:00.123400"; }; lt6 = { _type = "timestamp"; value = "00:32:00.123450"; }; lt7 = { _type = "timestamp"; value = "00:32:00.123456"; }; lt8 = { _type = "timestamp"; value = "00:32:00.123456700"; }; lt9 = { _type = "timestamp"; value = "00:32:00.123456780"; }; name = "Orange"; oct1 = 342391; oct2 = 493; odt1 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; odt10 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123456Z"; }; odt11 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123456700Z"; }; odt12 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123456780Z"; }; odt13 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123456789Z"; }; odt14 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123456789Z"; }; odt2 = { _type = "timestamp"; value = "1979-05-27T00:32:00-07:00"; }; odt3 = { _type = "timestamp"; value = "1979-05-27T00:32:00.999999-07:00"; }; odt4 = { _type = "timestamp"; value = "1979-05-27T07:32:00Z"; }; odt5 = { _type = "timestamp"; value = "1979-05-27T07:32:00.100Z"; }; odt6 = { _type = "timestamp"; value = "1979-05-27T07:32:00.120Z"; }; odt7 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123Z"; }; odt8 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123400Z"; }; odt9 = { _type = "timestamp"; value = "1979-05-27T07:32:00.123450Z"; }; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; }

tests/functional/lang/eval-okay-fromTOML-timestamps.nix

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,53 @@ builtins.fromTOML ''
5555
odt2 = 1979-05-27T00:32:00-07:00
5656
odt3 = 1979-05-27T00:32:00.999999-07:00
5757
odt4 = 1979-05-27 07:32:00Z
58+
# milliseconds
59+
odt5 = 1979-05-27 07:32:00.1Z
60+
odt6 = 1979-05-27 07:32:00.12Z
61+
odt7 = 1979-05-27 07:32:00.123Z
62+
# microseconds
63+
odt8 = 1979-05-27t07:32:00.1234Z
64+
odt9 = 1979-05-27t07:32:00.12345Z
65+
odt10 = 1979-05-27t07:32:00.123456Z
66+
# nanoseconds
67+
odt11 = 1979-05-27 07:32:00.1234567Z
68+
odt12 = 1979-05-27 07:32:00.12345678Z
69+
odt13 = 1979-05-27 07:32:00.123456789Z
70+
# no more precision after nanoseconds
71+
odt14 = 1979-05-27t07:32:00.1234567891Z
72+
5873
ldt1 = 1979-05-27T07:32:00
59-
ldt2 = 1979-05-27T00:32:00.999999
74+
# milliseconds
75+
ldt2 = 1979-05-27T07:32:00.1
76+
ldt3 = 1979-05-27T07:32:00.12
77+
ldt4 = 1979-05-27T07:32:00.123
78+
# microseconds
79+
ldt5 = 1979-05-27t00:32:00.1234
80+
ldt6 = 1979-05-27t00:32:00.12345
81+
ldt7 = 1979-05-27t00:32:00.123456
82+
# nanoseconds
83+
ldt8 = 1979-05-27 00:32:00.1234567
84+
ldt9 = 1979-05-27 00:32:00.12345678
85+
ldt10 = 1979-05-27 00:32:00.123456789
86+
# no more precision after nanoseconds
87+
ldt11 = 1979-05-27t00:32:00.1234567891
88+
6089
ld1 = 1979-05-27
6190
lt1 = 07:32:00
62-
lt2 = 00:32:00.999999
91+
# milliseconds
92+
lt2 = 00:32:00.1
93+
lt3 = 00:32:00.12
94+
lt4 = 00:32:00.123
95+
# microseconds
96+
lt5 = 00:32:00.1234
97+
lt6 = 00:32:00.12345
98+
lt7 = 00:32:00.123456
99+
# nanoseconds
100+
lt8 = 00:32:00.1234567
101+
lt9 = 00:32:00.12345678
102+
lt10 = 00:32:00.123456789
103+
# no more precision after nanoseconds
104+
lt11 = 00:32:00.1234567891
63105
64106
arr1 = [ 1, 2, 3 ]
65107
arr2 = [ "red", "yellow", "green" ]

tests/functional2/lang/fromTOML-timestamps/in.nix

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,53 @@ builtins.fromTOML ''
5555
odt2 = 1979-05-27T00:32:00-07:00
5656
odt3 = 1979-05-27T00:32:00.999999-07:00
5757
odt4 = 1979-05-27 07:32:00Z
58+
# milliseconds
59+
odt5 = 1979-05-27 07:32:00.1Z
60+
odt6 = 1979-05-27 07:32:00.12Z
61+
odt7 = 1979-05-27 07:32:00.123Z
62+
# microseconds
63+
odt8 = 1979-05-27t07:32:00.1234Z
64+
odt9 = 1979-05-27t07:32:00.12345Z
65+
odt10 = 1979-05-27t07:32:00.123456Z
66+
# nanoseconds
67+
odt11 = 1979-05-27 07:32:00.1234567Z
68+
odt12 = 1979-05-27 07:32:00.12345678Z
69+
odt13 = 1979-05-27 07:32:00.123456789Z
70+
# no more precision after nanoseconds
71+
odt14 = 1979-05-27t07:32:00.1234567891Z
72+
5873
ldt1 = 1979-05-27T07:32:00
59-
ldt2 = 1979-05-27T00:32:00.999999
74+
# milliseconds
75+
ldt2 = 1979-05-27T07:32:00.1
76+
ldt3 = 1979-05-27T07:32:00.12
77+
ldt4 = 1979-05-27T07:32:00.123
78+
# microseconds
79+
ldt5 = 1979-05-27t00:32:00.1234
80+
ldt6 = 1979-05-27t00:32:00.12345
81+
ldt7 = 1979-05-27t00:32:00.123456
82+
# nanoseconds
83+
ldt8 = 1979-05-27 00:32:00.1234567
84+
ldt9 = 1979-05-27 00:32:00.12345678
85+
ldt10 = 1979-05-27 00:32:00.123456789
86+
# no more precision after nanoseconds
87+
ldt11 = 1979-05-27t00:32:00.1234567891
88+
6089
ld1 = 1979-05-27
6190
lt1 = 07:32:00
62-
lt2 = 00:32:00.999999
91+
# milliseconds
92+
lt2 = 00:32:00.1
93+
lt3 = 00:32:00.12
94+
lt4 = 00:32:00.123
95+
# microseconds
96+
lt5 = 00:32:00.1234
97+
lt6 = 00:32:00.12345
98+
lt7 = 00:32:00.123456
99+
# nanoseconds
100+
lt8 = 00:32:00.1234567
101+
lt9 = 00:32:00.12345678
102+
lt10 = 00:32:00.123456789
103+
# no more precision after nanoseconds
104+
lt11 = 00:32:00.1234567891
63105
64106
arr1 = [ 1, 2, 3 ]
65107
arr2 = [ "red", "yellow", "green" ]

0 commit comments

Comments
 (0)