Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent test result of '+inf' #150

Closed
Bowen7 opened this issue Jan 19, 2024 · 4 comments
Closed

Inconsistent test result of '+inf' #150

Bowen7 opened this issue Jan 19, 2024 · 4 comments

Comments

@Bowen7
Copy link

Bowen7 commented Jan 19, 2024

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"
},

@arp242
Copy link
Collaborator

arp242 commented Jan 19, 2024

Is this causing practical issues for you?

@Bowen7
Copy link
Author

Bowen7 commented Jan 20, 2024

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

@glguy
Copy link

glguy commented Feb 26, 2024

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

@arp242
Copy link
Collaborator

arp242 commented Feb 26, 2024

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).

@arp242 arp242 closed this as completed in eff8d3a May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants