-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/toml: validate the resulting value against toml.Unmarshal
Given some input TOML, we can use our new encoding/toml.Decoder to obtain an ast.Node and then compile that to a cue.Value. Similarly, we can use go-toml's Unmarshal API on the same input TOML to obtain a Go value directly. Those two values should be equivalent, which we check via qt.JSONEquals. Two test cases fail this new check: the one involving duplicate keys, which is a known bug in our decoder, and the pair of tests involving empty TOML input, which we decoded as a CUE null. It seems like all TOML decoders decode empty input as an empty struct, and the TOML spec also hints that way as it allows empty tables which "simply have no key/value pairs within them". Moreover, since we create an ast.File, it seems best to leave it empty, which equals an empty struct, rather than add a "null" embedding. While here, add a TODO to remind myself to revisit literal decoding. Updates #68. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I83e34b939f1c2dd3b7928e14076f69c39e5054e0 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194706 Unity-Result: CUE porcuepine <[email protected]> TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]>
- Loading branch information
Showing
2 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters