feat: parse into a Document that keeps order and comments
Test / test (push) Successful in 1m34s

Assisted-by: DeepSeek V4.1 Flash
This commit is contained in:
2026-09-20 10:40:57 +02:00
parent a6e3e3fe31
commit 72f8b21ac4
16 changed files with 939 additions and 119 deletions
+4 -4
View File
@@ -24,7 +24,7 @@ func TestSyntaxErrorMessage(t *testing.T) {
}
func TestParseRejectsInvalidUTF8(t *testing.T) {
_, err := Parse([]byte("v = \"\xff\"\n"))
_, err := ParseMap([]byte("v = \"\xff\"\n"))
if err == nil {
t.Fatal("expected a UTF-8 validation error")
}
@@ -130,7 +130,7 @@ func TestUnmarshalIntoNilAny(t *testing.T) {
func TestParseContextHonoursCancellation(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
cancel()
if _, err := ParseContext(ctx, []byte("a = 1\n")); !errors.Is(err, context.Canceled) {
if _, err := ParseMapContext(ctx, []byte("a = 1\n")); !errors.Is(err, context.Canceled) {
t.Fatalf("ParseContext returned %v, want context.Canceled", err)
}
}
@@ -160,7 +160,7 @@ func TestContextRoundTrip(t *testing.T) {
in := []byte(`title = "x"
count = 3
`)
if _, err := ParseContext(context.Background(), in); err != nil {
if _, err := ParseMapContext(context.Background(), in); err != nil {
t.Fatalf("ParseContext: %v", err)
}
var out struct {
@@ -987,7 +987,7 @@ func TestDecoderMaxInputSize(t *testing.T) {
t.Errorf("err = %v, want it to name the limit", err)
}
// Parse carries the nesting default and no size limit.
if _, err := Parse(doc); err != nil {
if _, err := ParseMap(doc); err != nil {
t.Fatalf("parse: %v", err)
}
}