-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TomlVisitorTest after seeing ClassCastException in arrays (#4892)
* Add TomlVisitorTest after seeing ClassCastException in arrays * Have Toml.Literal implement TomlValue * Drop unnecessary cast instead
- Loading branch information
Showing
4 changed files
with
199 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
root = true | ||
|
||
[*.java] | ||
indent_size = 4 | ||
ij_continuation_indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,8 @@ void keyValueString() { | |
rewriteRun( | ||
toml( | ||
""" | ||
str = "I'm a string. \\"You can quote me\\". Name\\tJos\\u00E9\\nLocation\\tSF." | ||
""" | ||
str = "I'm a string. \\"You can quote me\\". Name\\tJos\\u00E9\\nLocation\\tSF." | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -37,23 +37,23 @@ void keyValueInteger() { | |
rewriteRun( | ||
toml( | ||
""" | ||
int1 = +99 | ||
int2 = 42 | ||
int3 = 0 | ||
int4 = -17 | ||
int5 = 1_000 | ||
# hexadecimal with prefix `0x` | ||
hex1 = 0xDEADBEEF | ||
hex2 = 0xdeadbeef | ||
hex3 = 0xdead_beef | ||
# octal with prefix `0o` | ||
oct1 = 0o01234567 | ||
oct2 = 0o755 # useful for Unix file permissions | ||
# binary with prefix `0b` | ||
bin1 = 0b11010110 | ||
""" | ||
int1 = +99 | ||
int2 = 42 | ||
int3 = 0 | ||
int4 = -17 | ||
int5 = 1_000 | ||
# hexadecimal with prefix `0x` | ||
hex1 = 0xDEADBEEF | ||
hex2 = 0xdeadbeef | ||
hex3 = 0xdead_beef | ||
# octal with prefix `0o` | ||
oct1 = 0o01234567 | ||
oct2 = 0o755 # useful for Unix file permissions | ||
# binary with prefix `0b` | ||
bin1 = 0b11010110 | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -63,31 +63,31 @@ void keyValueFloat() { | |
rewriteRun( | ||
toml( | ||
""" | ||
# fractional | ||
flt1 = +1.0 | ||
flt2 = 3.1415 | ||
flt3 = -0.01 | ||
# exponent | ||
flt4 = 5e+22 | ||
flt5 = 1e06 | ||
flt6 = -2E-2 | ||
# both | ||
flt7 = 6.626e-34 | ||
flt8 = 224_617.445_991_228 | ||
# infinity | ||
sf1 = inf # positive infinity | ||
sf2 = +inf # positive infinity | ||
sf3 = -inf # negative infinity | ||
# not a number | ||
sf4 = nan # actual sNaN/qNaN encoding is implementation-specific | ||
sf5 = +nan # same as `nan` | ||
sf6 = -nan # valid, actual encoding is implementation-specific | ||
""" | ||
# fractional | ||
flt1 = +1.0 | ||
flt2 = 3.1415 | ||
flt3 = -0.01 | ||
# exponent | ||
flt4 = 5e+22 | ||
flt5 = 1e06 | ||
flt6 = -2E-2 | ||
# both | ||
flt7 = 6.626e-34 | ||
flt8 = 224_617.445_991_228 | ||
# infinity | ||
sf1 = inf # positive infinity | ||
sf2 = +inf # positive infinity | ||
sf3 = -inf # negative infinity | ||
# not a number | ||
sf4 = nan # actual sNaN/qNaN encoding is implementation-specific | ||
sf5 = +nan # same as `nan` | ||
sf6 = -nan # valid, actual encoding is implementation-specific | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -97,9 +97,9 @@ void keyValueBool() { | |
rewriteRun( | ||
toml( | ||
""" | ||
bool1 = true | ||
bool2 = false | ||
""" | ||
bool1 = true | ||
bool2 = false | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -109,11 +109,11 @@ void keyValueOffsetDateTime() { | |
rewriteRun( | ||
toml( | ||
""" | ||
odt1 = 1979-05-27T07:32:00Z | ||
odt2 = 1979-05-27T00:32:00-07:00 | ||
odt3 = 1979-05-27T00:32:00.999999-07:00 | ||
odt4 = 1979-05-27 07:32:00Z | ||
""" | ||
odt1 = 1979-05-27T07:32:00Z | ||
odt2 = 1979-05-27T00:32:00-07:00 | ||
odt3 = 1979-05-27T00:32:00.999999-07:00 | ||
odt4 = 1979-05-27 07:32:00Z | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -123,9 +123,9 @@ void keyValueLocalDateTime() { | |
rewriteRun( | ||
toml( | ||
""" | ||
ldt1 = 1979-05-27T07:32:00 | ||
ldt2 = 1979-05-27T00:32:00.999999 | ||
""" | ||
ldt1 = 1979-05-27T07:32:00 | ||
ldt2 = 1979-05-27T00:32:00.999999 | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -135,8 +135,8 @@ void keyValueLocalDate() { | |
rewriteRun( | ||
toml( | ||
""" | ||
ld1 = 1979-05-27 | ||
""" | ||
ld1 = 1979-05-27 | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -146,9 +146,9 @@ void keyValueLocalTime() { | |
rewriteRun( | ||
toml( | ||
""" | ||
lt1 = 07:32:00 | ||
lt2 = 00:32:00.999999 | ||
""" | ||
lt1 = 07:32:00 | ||
lt2 = 00:32:00.999999 | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -158,27 +158,27 @@ void keyValueArray() { | |
rewriteRun( | ||
toml( | ||
""" | ||
integers = [ 1, 2, 3 ] | ||
colors = [ "red", "yellow", "green" ] | ||
nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ] | ||
nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] | ||
string_array = [ "all", 'strings', ""\"are the same""\", '''type''' ] | ||
# Mixed-type arrays are allowed | ||
numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] | ||
contributors = [ | ||
"Foo Bar <[email protected]>", | ||
{ name = "Baz Qux", email = "[email protected]", url = "https://example.com/bazqux" } | ||
] | ||
integers2 = [ | ||
1, 2, 3 | ||
] | ||
integers3 = [ | ||
1, | ||
2, # this is ok | ||
] | ||
""" | ||
integers = [ 1, 2, 3 ] | ||
colors = [ "red", "yellow", "green" ] | ||
nested_arrays_of_ints = [ [ 1, 2 ], [3, 4, 5] ] | ||
nested_mixed_array = [ [ 1, 2 ], ["a", "b", "c"] ] | ||
string_array = [ "all", 'strings', ""\"are the same""\", '''type''' ] | ||
# Mixed-type arrays are allowed | ||
numbers = [ 0.1, 0.2, 0.5, 1, 2, 5 ] | ||
contributors = [ | ||
"Foo Bar <[email protected]>", | ||
{ name = "Baz Qux", email = "[email protected]", url = "https://example.com/bazqux" } | ||
] | ||
integers2 = [ | ||
1, 2, 3 | ||
] | ||
integers3 = [ | ||
1, | ||
2, # this is ok | ||
] | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -188,17 +188,17 @@ void table() { | |
rewriteRun( | ||
toml( | ||
""" | ||
[table-1] | ||
key1 = "some string" | ||
key2 = 123 | ||
[table-2] | ||
key1 = "another string" | ||
key2 = 456 | ||
[dog."tater.man"] | ||
type.name = "pug" | ||
""" | ||
[table-1] | ||
key1 = "some string" | ||
key2 = 123 | ||
[table-2] | ||
key1 = "another string" | ||
key2 = 456 | ||
[dog."tater.man"] | ||
type.name = "pug" | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -208,18 +208,18 @@ void arrayTable() { | |
rewriteRun( | ||
toml( | ||
""" | ||
[[products]] | ||
name = "Hammer" | ||
sku = 738594937 | ||
[[products]] # empty table within the array | ||
[[products]] | ||
name = "Nail" | ||
sku = 284758393 | ||
color = "gray" | ||
""" | ||
[[products]] | ||
name = "Hammer" | ||
sku = 738594937 | ||
[[products]] # empty table within the array | ||
[[products]] | ||
name = "Nail" | ||
sku = 284758393 | ||
color = "gray" | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -229,11 +229,11 @@ void bareKeys() { | |
rewriteRun( | ||
toml( | ||
""" | ||
key = "value" | ||
bare_key = "value" | ||
bare-key = "value" | ||
1234 = "value" | ||
""" | ||
key = "value" | ||
bare_key = "value" | ||
bare-key = "value" | ||
1234 = "value" | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -243,12 +243,12 @@ void quotedKeys() { | |
rewriteRun( | ||
toml( | ||
""" | ||
"127.0.0.1" = "value" | ||
"character encoding" = "value" | ||
"ʎǝʞ" = "value" | ||
'key2' = "value" | ||
'quoted "value"' = "value" | ||
""" | ||
"127.0.0.1" = "value" | ||
"character encoding" = "value" | ||
"ʎǝʞ" = "value" | ||
'key2' = "value" | ||
'quoted "value"' = "value" | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -258,10 +258,10 @@ void dottedKeys() { | |
rewriteRun( | ||
toml( | ||
""" | ||
physical.color = "orange" | ||
physical.shape = "round" | ||
site."google.com" = true | ||
""" | ||
physical.color = "orange" | ||
physical.shape = "round" | ||
site."google.com" = true | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -271,10 +271,10 @@ void extraWhitespaceDottedKeys() { | |
rewriteRun( | ||
toml( | ||
""" | ||
fruit.name = "banana" # this is best practice | ||
fruit. color = "yellow" # same as fruit.color | ||
fruit . flavor = "banana" # same as fruit.flavor | ||
""" | ||
fruit.name = "banana" # this is best practice | ||
fruit. color = "yellow" # same as fruit.color | ||
fruit . flavor = "banana" # same as fruit.flavor | ||
""" | ||
) | ||
); | ||
} | ||
|
@@ -321,9 +321,9 @@ void trailingComment() { | |
rewriteRun( | ||
toml( | ||
""" | ||
str = "I'm a string. \\"You can quote me\\". Name\\tJos\\u00E9\\nLocation\\tSF." | ||
# trailing comment | ||
""" | ||
str = "I'm a string. \\"You can quote me\\". Name\\tJos\\u00E9\\nLocation\\tSF." | ||
# trailing comment | ||
""" | ||
) | ||
); | ||
} | ||
|
Oops, something went wrong.