Skip to content

TOML decoder bugs #17

@epage

Description

@epage

Describe the bug
As this looks to be forked from basic-toml, there are 21 decoder failures from toml-test (#2)

Failure outputs
basic-toml version 0.1.10
FAIL valid/array/array
     Error: Error { message: "invalid number at line 5 column 2" }
 
     Exit 1

     input sent to parser-cmd (PID 15638):
       ints = [1, 2, 3, ]
       floats = [1.1, 2.1, 3.1]
       strings = ["a", "b", "c"]
       dates = [
       	1987-07-05T17:45:00Z,
       	1979-05-27T07:32:00,
       	2006-06-01,
       	11:00:00,
       ]
       comments = [
                1,
                2, #this is ok
       ]

     output from parser-cmd (PID 15638) (stderr):
       Error: Error { message: "invalid number at line 5 column 2" }

       Exit 1

     want:
          

FAIL valid/comment/everywhere
     Error: Error { message: "invalid number at line 27 column 6" }
 
     Exit 1

     input sent to parser-cmd (PID 15660):
       # Top comment.
         # Top comment.
       # Top comment.

       # [no-extraneous-groups-please]

       [group] # Comment
       answer = 42 # Comment
       # no-extraneous-keys-please = 999
       # Inbetween comment.
       more = [ # Comment
         # What about multiple # comments?
         # Can you handle it?
         #
                 # Evil.
       # Evil.
         42, 42, # Comments within arrays are fun.
         # What about multiple # comments?
         # Can you handle it?
         #
                 # Evil.
       # Evil.
       # ] Did I fool you?
       ] # Hopefully not.

       # Make sure the space between the datetime and "#" isn't lexed.
       dt = 1979-05-27T07:32:12-07:00  # c
       d = 1979-05-27 # Comment

       [[aot]] # Comment
       k = 98 # Comment
       [[aot]]# Comment
       k = 99# Comment

     output from parser-cmd (PID 15660) (stderr):
       Error: Error { message: "invalid number at line 27 column 6" }

       Exit 1

     want:
          

FAIL valid/datetime/datetime
     Error: Error { message: "invalid number at line 1 column 9" }
 
     Exit 1

     input sent to parser-cmd (PID 15676):
       space = 1987-07-05 17:45:00Z

       # ABNF is case-insensitive, both "Z" and "z" must be supported.
       lower = 1987-07-05t17:45:00z

     output from parser-cmd (PID 15676) (stderr):
       Error: Error { message: "invalid number at line 1 column 9" }

       Exit 1

     want:
          

FAIL valid/datetime/edge
     Error: Error { message: "invalid number at line 1 column 17" }
 
     Exit 1

     input sent to parser-cmd (PID 15677):
       first-offset = 0001-01-01 00:00:00Z
       first-local  = 0001-01-01 00:00:00
       first-date   = 0001-01-01

       last-offset = 9999-12-31 23:59:59Z
       last-local  = 9999-12-31 23:59:59
       last-date   = 9999-12-31

     output from parser-cmd (PID 15677) (stderr):
       Error: Error { message: "invalid number at line 1 column 17" }

       Exit 1

     want:
          

FAIL valid/datetime/leap-year
     Error: Error { message: "invalid number at line 1 column 23" }
 
     Exit 1

     input sent to parser-cmd (PID 15680):
       2000-datetime       = 2000-02-29 15:15:15Z
       2000-datetime-local = 2000-02-29 15:15:15
       2000-date           = 2000-02-29

       2024-datetime       = 2024-02-29 15:15:15Z
       2024-datetime-local = 2024-02-29 15:15:15
       2024-date           = 2024-02-29

     output from parser-cmd (PID 15680) (stderr):
       Error: Error { message: "invalid number at line 1 column 23" }

       Exit 1

     want:
          

FAIL valid/datetime/local
     Error: Error { message: "invalid number at line 1 column 9" }
 
     Exit 1

     input sent to parser-cmd (PID 15681):
       local = 1987-07-05T17:45:00
       milli = 1977-12-21T10:32:00.555
       space = 1987-07-05 17:45:00

     output from parser-cmd (PID 15681) (stderr):
       Error: Error { message: "invalid number at line 1 column 9" }

       Exit 1

     want:
          

FAIL valid/datetime/local-date
     Error: Error { message: "invalid number at line 1 column 15" }
 
     Exit 1

     input sent to parser-cmd (PID 15679):
       bestdayever = 1987-07-05

     output from parser-cmd (PID 15679) (stderr):
       Error: Error { message: "invalid number at line 1 column 15" }

       Exit 1

     want:
          

FAIL valid/datetime/local-time
     Error: Error { message: "expected newline, found a colon at line 1 column 18" }
 
     Exit 1

     input sent to parser-cmd (PID 15686):
       besttimeever = 17:45:00
       milliseconds = 10:32:00.555

     output from parser-cmd (PID 15686) (stderr):
       Error: Error { message: "expected newline, found a colon at line 1 column 18" }

       Exit 1

     want:
          

FAIL valid/datetime/milliseconds
     Error: Error { message: "invalid number at line 1 column 9" }
 
     Exit 1

     input sent to parser-cmd (PID 15684):
       utc1  = 1987-07-05T17:45:56.123Z
       utc2  = 1987-07-05T17:45:56.6Z
       wita1 = 1987-07-05T17:45:56.123+08:00
       wita2 = 1987-07-05T17:45:56.6+08:00

     output from parser-cmd (PID 15684) (stderr):
       Error: Error { message: "invalid number at line 1 column 9" }

       Exit 1

     want:
          

FAIL valid/datetime/timezone
     Error: Error { message: "invalid number at line 1 column 8" }
 
     Exit 1

     input sent to parser-cmd (PID 15682):
       utc  = 1987-07-05T17:45:56Z
       pdt  = 1987-07-05T17:45:56-05:00
       nzst = 1987-07-05T17:45:56+12:00
       nzdt = 1987-07-05T17:45:56+13:00  # DST

     output from parser-cmd (PID 15682) (stderr):
       Error: Error { message: "invalid number at line 1 column 8" }

       Exit 1

     want:
          

FAIL valid/example
     Error: Error { message: "invalid number at line 1 column 17" }
 
     Exit 1

     input sent to parser-cmd (PID 15693):
       best-day-ever = 1987-07-05T17:45:00Z

       [numtheory]
       boring = false
       perfection = [6, 28, 496]

     output from parser-cmd (PID 15693) (stderr):
       Error: Error { message: "invalid number at line 1 column 17" }

       Exit 1

     want:
          

FAIL valid/spec-1.0.0/local-date-0
     Error: Error { message: "invalid number at line 1 column 7" }
 
     Exit 1

     input sent to parser-cmd (PID 15784):
       ld1 = 1979-05-27

     output from parser-cmd (PID 15784) (stderr):
       Error: Error { message: "invalid number at line 1 column 7" }

       Exit 1

     want:
          

FAIL valid/spec-1.0.0/local-date-time-0
     Error: Error { message: "invalid number at line 1 column 8" }
 
     Exit 1

     input sent to parser-cmd (PID 15786):
       ldt1 = 1979-05-27T07:32:00
       ldt2 = 1979-05-27T00:32:00.999

     output from parser-cmd (PID 15786) (stderr):
       Error: Error { message: "invalid number at line 1 column 8" }

       Exit 1

     want:
          

FAIL valid/spec-1.0.0/local-time-0
     Error: Error { message: "invalid number at line 1 column 8" }
 
     Exit 1

     input sent to parser-cmd (PID 15787):
       lt1 = 07:32:00
       lt2 = 00:32:00.999

     output from parser-cmd (PID 15787) (stderr):
       Error: Error { message: "invalid number at line 1 column 8" }

       Exit 1

     want:
          

FAIL valid/spec-1.0.0/offset-date-time-0
     Error: Error { message: "invalid number at line 1 column 8" }
 
     Exit 1

     input sent to parser-cmd (PID 15789):
       odt1 = 1979-05-27T07:32:00Z
       odt2 = 1979-05-27T00:32:00-07:00
       odt3 = 1979-05-27T00:32:00.999-07:00

     output from parser-cmd (PID 15789) (stderr):
       Error: Error { message: "invalid number at line 1 column 8" }

       Exit 1

     want:
          

FAIL valid/spec-1.0.0/offset-date-time-1
     Error: Error { message: "invalid number at line 1 column 8" }
 
     Exit 1

     input sent to parser-cmd (PID 15788):
       odt4 = 1979-05-27 07:32:00Z

     output from parser-cmd (PID 15788) (stderr):
       Error: Error { message: "invalid number at line 1 column 8" }

       Exit 1

     want:
          

FAIL valid/spec-1.0.0/table-7
     Error: Error { message: "invalid number at line 8 column 16" }
 
     Exit 1

     input sent to parser-cmd (PID 15798):
       # Top-level table begins.
       name = "Fido"
       breed = "pug"

       # Top-level table ends.
       [owner]
       name = "Regina Dogman"
       member_since = 1999-08-04

     output from parser-cmd (PID 15798) (stderr):
       Error: Error { message: "invalid number at line 8 column 16" }

       Exit 1

     want:
          

FAIL valid/spec-1.0.0/table-9
     Error: Error { message: "duplicate key: `apple` for key `fruit` at line 8 column 8" }
 
     Exit 1

     input sent to parser-cmd (PID 15809):
       [fruit]
       apple.color = "red"
       apple.taste.sweet = true

       # [fruit.apple]  # INVALID
       # [fruit.apple.taste]  # INVALID

       [fruit.apple.texture]  # you can add sub-tables
       smooth = true

     output from parser-cmd (PID 15809) (stderr):
       Error: Error { message: "duplicate key: `apple` for key `fruit` at line 8 column 8" }

       Exit 1

     want:
          

FAIL valid/spec-example-1
     Error: Error { message: "invalid number at line 7 column 7" }
 
     Exit 1

     input sent to parser-cmd (PID 15812):
       # This is a TOML document. Boom.

       title = "TOML Example"

       [owner]
       name = "Lance Uppercut"
       dob = 1979-05-27T07:32:00-08:00 # First class dates? Why not?

       [database]
       server = "192.168.1.1"
       ports = [ 8001, 8001, 8002 ]
       connection_max = 5000
       enabled = true

       [servers]

         # You can indent as you please. Tabs or spaces. TOML don't care.
         [servers.alpha]
         ip = "10.0.0.1"
         dc = "eqdc10"

         [servers.beta]
         ip = "10.0.0.2"
         dc = "eqdc10"

       [clients]
       data = [ ["gamma", "delta"], [1, 2] ]

       # Line breaks are OK when inside arrays
       hosts = [
         "alpha",
         "omega"
       ]

     output from parser-cmd (PID 15812) (stderr):
       Error: Error { message: "invalid number at line 7 column 7" }

       Exit 1

     want:
          

FAIL valid/spec-example-1-compact
     Error: Error { message: "invalid number at line 5 column 5" }
 
     Exit 1

     input sent to parser-cmd (PID 15808):
       #Useless spaces eliminated.
       title="TOML Example"
       [owner]
       name="Lance Uppercut"
       dob=1979-05-27T07:32:00-08:00#First class dates
       [database]
       server="192.168.1.1"
       ports=[8001,8001,8002]
       connection_max=5000
       enabled=true
       [servers]
       [servers.alpha]
       ip="10.0.0.1"
       dc="eqdc10"
       [servers.beta]
       ip="10.0.0.2"
       dc="eqdc10"
       [clients]
       data=[["gamma","delta"],[1,2]]
       hosts=[
       "alpha",
       "omega"
       ]

     output from parser-cmd (PID 15808) (stderr):
       Error: Error { message: "invalid number at line 5 column 5" }

       Exit 1

     want:
          

FAIL valid/table/array-within-dotted
     Error: Error { message: "duplicate key: `apple` for key `fruit` at line 4 column 9" }
 
     Exit 1

     input sent to parser-cmd (PID 15841):
       [fruit]
       apple.color = "red"

       [[fruit.apple.seeds]]
       size = 2

     output from parser-cmd (PID 15841) (stderr):
       Error: Error { message: "duplicate key: `apple` for key `fruit` at line 4 column 9" }

       Exit 1

     want:
          

FAIL invalid/control/comment-del
     Expected an error, but no error was reported.

     input sent to parser-cmd (PID 15920):
       comment-del  = "0x7f"   # �

     output from parser-cmd (PID 15920) (stdout):
       {
         "comment-del": {"type": "string", "value": "0x7f"}
       }

     want:
       Exit code 1

FAIL invalid/integer/positive-bin
     Expected an error, but no error was reported.

     input sent to parser-cmd (PID 16126):
       positive-bin = +0b11010110

     output from parser-cmd (PID 16126) (stdout):
       {
         "positive-bin": {"type": "integer", "value": "214"}
       }

     want:
       Exit code 1

FAIL invalid/integer/positive-hex
     Expected an error, but no error was reported.

     input sent to parser-cmd (PID 16127):
       positive-hex = +0xff

     output from parser-cmd (PID 16127) (stdout):
       {
         "positive-hex": {"type": "integer", "value": "255"}
       }

     want:
       Exit code 1

FAIL invalid/integer/positive-oct
     Expected an error, but no error was reported.

     input sent to parser-cmd (PID 16128):
       positive-oct = +0o755

     output from parser-cmd (PID 16128) (stdout):
       {
         "positive-oct": {"type": "integer", "value": "493"}
       }

     want:
       Exit code 1

toml-test v2025-04-23 [./scripts/target/release/basic-toml-decoder]: using embedded tests
  valid tests: 184 passed, 21 failed
invalid tests: 525 passed,  4 failed

==> ENCODER TESTS
(not supported)
took 0.5 0.20


Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions