toml-lang / toml-test

A language agnostic test suite for TOML parsers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent test result of '+inf'

Bowen7 opened this issue · comments

The +inf returns

{
    "type": "float",
    "value": "inf"
}

in the valid/spec/float-2.json file

sf2 = +inf # positive infinity

"sf2": {
"type": "float",
"value": "inf"
},

However, it returns

{
    "type": "float",
-    "value": "inf"
+    "value": "+inf"
}

in the valid/float/inf-and-nan.json file

infinity_plus = +inf

"infinity_plus": {
"type": "float",
"value": "+inf"
},

Is this causing practical issues for you?

I just wrote a parser for TOML for fun and found that it cannot pass these test suites.

I had to add custom processing to my test program to account for the inconsistent way the test suite encodes infinities

https://github.com/glguy/toml-parser/blob/main/test-drivers/encoder/Main.hs#L59-L60

That's actually a different issue @glguy, with the "I" in "Inf" being capitalized sometimes. That was fixed last year. I'm not 100% sure if that's in the latest tagged release (need to look that up), but it's definitely in the latest master.

Verified with:

% git log -n1 
commit 4bcf07d (HEAD -> main, tag: toml-parser-2.0.0.0, origin/main, origin/HEAD)
Author: Eric Mertens <emertens@gmail.com>
Date:   Sat Feb 24 08:27:42 2024 -0800

    Use NonEmpty in lexer context stack

% git diff
diff --git i/test-drivers/encoder/Main.hs w/test-drivers/encoder/Main.hs
index 73998b2..e322d23 100644
--- i/test-drivers/encoder/Main.hs
+++ w/test-drivers/encoder/Main.hs
@@ -56,6 +56,6 @@ decodeValue "date-local"     (lexValue -> Right (TokLocalDate      x)) = pure (T
 decodeValue "float"          (lexValue -> Right (TokFloat          x)) = pure (Toml.Double    x)
 decodeValue "float"          (lexValue -> Right (TokInteger        x)) = pure (Toml.Double    (fromInteger x))
 -- extra infinities as toml-tests are inconsistent
-decodeValue "float"          "+Inf"                                    = pure (Toml.Double    (1/0))
-decodeValue "float"          "-Inf"                                    = pure (Toml.Double    (-1/0))
+-- decodeValue "float"          "+Inf"                                    = pure (Toml.Double    (1/0))
+-- decodeValue "float"          "-Inf"                                    = pure (Toml.Double    (-1/0))
 decodeValue _                _                                         = empty

% toml-test ./TomlDecoder
toml-test v2023-12-07 [./TomlDecoder]: using embedded tests
  valid tests: 179 passed,  0 failed
invalid tests: 368 passed,  0 failed

% toml-test -encoder ./TomlEncoder
toml-test v2023-12-07 [./TomlEncoder]: using embedded tests
encoder tests: 179 passed,  0 failed

(I made sure to rebuild the TomlDecoder/TomlEncoder with the changes).