arp242 / toml-c

TOML C library
Other
31 stars 5 forks source link

'make check' fails NaN tests #1

Open Kamicosi opened 8 months ago

Kamicosi commented 8 months ago

It looks like '+nan' and '-nan' should be parsed as just 'nan', but instead they're being parsed as '+nan' and '-nan', respectively.

make check
LICENSE  Makefile  README.md  header  libtoml.a  libtoml.pc  libtoml.so.1.0  test.bash  toml.c  toml.h  toml.o  toml2json  toml2json.c
FAIL valid/float/inf-and-nan
     Values for key 'nan_neg' don't match:
       Expected:     nan
       Your encoder: -nan

     input sent to parser-cmd:
       # We don't encode +nan and -nan back with the signs; many languages don't
       # support a sign on NaN (it doesn't really make much sense).
       nan = nan
       nan_neg = -nan
       nan_plus = +nan
       infinity = inf
       infinity_neg = -inf
       infinity_plus = +inf

     output from parser-cmd (stdout):
       {
         "infinity": {
           "type": "float",
           "value": "inf"
         },
         "infinity_neg": {
           "type": "float",
           "value": "-inf"
         },
         "infinity_plus": {
           "type": "float",
           "value": "+inf"
         },
         "nan": {
           "type": "float",
           "value": "nan"
         },
         "nan_neg": {
           "type": "float",
           "value": "-nan"
         },
         "nan_plus": {
           "type": "float",
           "value": "+nan"
         }
       }

     want:
       {
         "infinity": {
           "type": "float",
           "value": "inf"
         },
         "infinity_neg": {
           "type": "float",
           "value": "-inf"
         },
         "infinity_plus": {
           "type": "float",
           "value": "+inf"
         },
         "nan": {
           "type": "float",
           "value": "nan"
         },
         "nan_neg": {
           "type": "float",
           "value": "nan"
         },
         "nan_plus": {
           "type": "float",
           "value": "nan"
         }
       }

FAIL valid/spec/float-2
     Values for key 'sf5' don't match:
       Expected:     nan
       Your encoder: +nan

     input sent to parser-cmd:
       # 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

     output from parser-cmd (stdout):
       {
         "sf1": {
           "type": "float",
           "value": "inf"
         },
         "sf2": {
           "type": "float",
           "value": "+inf"
         },
         "sf3": {
           "type": "float",
           "value": "-inf"
         },
         "sf4": {
           "type": "float",
           "value": "nan"
         },
         "sf5": {
           "type": "float",
           "value": "+nan"
         },
         "sf6": {
           "type": "float",
           "value": "-nan"
         }
       }

     want:
       {
         "sf1": {
           "type": "float",
           "value": "+Inf"
         },
         "sf2": {
           "type": "float",
           "value": "+Inf"
         },
         "sf3": {
           "type": "float",
           "value": "-Inf"
         },
         "sf4": {
           "type": "float",
           "value": "nan"
         },
         "sf5": {
           "type": "float",
           "value": "nan"
         },
         "sf6": {
           "type": "float",
           "value": "nan"
         }
       }

toml-test [./toml2json]: using embedded tests: 398 passed,  2 failed, 15 skipped
make: *** [Makefile:42: check] Error 1

Version info:

toml-test -version -version
/home/cendo/go/bin/toml-test dev

go      go1.18.1
path    github.com/toml-lang/toml-test/cmd/toml-test
mod     github.com/toml-lang/toml-test  v1.4.0  h1:uZzMCvz5rebZbXuBoYDG5q7UqMyH29A5RnaZ8D1rSYA=
dep     github.com/BurntSushi/toml      v1.2.2-0.20230116181612-fcbab7400715    h1:wpQ/gpMTRuiaIOlcOImLxe7XF7FQ/Q5vmrQDEAHpGmI=
dep     zgo.at/zli      v0.0.0-20220603144954-fdab8cc4d9d8      h1:Cvmn2mATNsxwIVjKv91UHWdInUqjA/oWMH9kAUuzojQ=
build   -compiler=gc
build   CGO_ENABLED=1
build   CGO_CFLAGS=
build   CGO_CPPFLAGS=
build   CGO_CXXFLAGS=
build   CGO_LDFLAGS=
build   GOARCH=amd64
build   GOOS=linux
build   GOAMD64=v1
arp242 commented 8 months ago

This is a bug in toml-test: https://github.com/toml-lang/toml-test/commit/fe8e1e2

You'll need to get the latest master branch.