Property-based tests generate invalid TOML keys occasionally
roberth opened this issue · 3 comments
roberth commented
I've found this test failure in CI. Perhaps it hasn't been seen before, because of the random nature of property tests.
Log excerpt
Failures:
test/Test/Toml/Codec/Combinator/Common.hs:39:5:
1) Codec: unit and property tests for bidirectional codecs, Combinator spec, Combinator.Map: Roundtrip tests, Map Text Int (tableMap): decode . encode ≡ id
✗ <interactive> failed at test/Test/Toml/Codec/Combinator/Common.hs:39:5
after 38 tests and 10 shrinks.
┏━━ test/Test/Toml/Codec/Combinator/Common.hs ━━━
28 ┃ codecRoundtripWith
29 ┃ :: forall a
30 ┃ . (Eq a, Show a)
31 ┃ => (TomlCodec a -> Text -> Either [TomlDecodeError] a)
32 ┃ -> String
33 ┃ -> (Key -> TomlCodec a)
34 ┃ -> Gen a
35 ┃ -> SpecWith (Arg Expectation)
36 ┃ codecRoundtripWith dcode typeName mkCodec genA = it label $ hedgehog $ do
37 ┃ a <- forAll genA
┃ │ fromList [ ( "\"\\\"" , 0 ) ]
38 ┃ let codec = mkCodec "a"
39 ┃ tripping a (encode codec) (dcode codec)
┃ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
┃ │ ━━━ Intermediate ━━━
┃ │ "\n[a]\n"
┃ │ ━━━ - Original) (+ Roundtrip ━━━
┃ │ - Right (fromList [ ( "\"\\\"" , 0 ) ])
┃ │ + Right (fromList [])
40 ┃ where
41 ┃ label :: String
42 ┃ label = typeName ++ ": decode . encode ≡ id"
This failure can be reproduced by running:
> recheck (Size 37) (Seed 10155217494328621451 7554747479521254871) <property>
roberth commented
The second attempt did not find the failure. The first attempt is on the same page.
It was built on an aarch64-linux machine, but I don't think that should matter.
chshersh commented
TotallyNotChase commented
Is there a reason the bare
generator makes sure the first character in the key is an alphabetical character? Doesn't the toml spec allow alphanumeric + dash in any position?
https://toml.io/en/v0.5.0#keys