Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -567,3 +567,50 @@ type Item struct {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunPlainJSONShapes(t *testing.T) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
in := strings.NewReader("when = 1979-05-27T07:32:00-07:00\nd = 1979-05-27\nt = 07:32:00\nwall = 1979-05-27T07:32:00\n" +
|
||||
"items = [1, \"two\"]\n\n[[tables]]\nx = true\n")
|
||||
code := Run([]string{"-json"}, in, &stdout, &stderr)
|
||||
if code != 0 {
|
||||
t.Fatalf("Run returned %d, want 0; stderr = %q", code, stderr.String())
|
||||
}
|
||||
out := stdout.String()
|
||||
for _, want := range []string{
|
||||
"\"when\": \"1979-05-27T07:32-07:00\"",
|
||||
"\"d\": \"1979-05-27\"",
|
||||
"\"t\": \"07:32\"",
|
||||
"\"wall\": \"1979-05-27T07:32\"",
|
||||
"\"items\": [",
|
||||
"\"x\": true",
|
||||
} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Errorf("output missing %q:\n%s", want, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestInferStructScalarShapes(t *testing.T) {
|
||||
var stdout, stderr bytes.Buffer
|
||||
in := strings.NewReader("f = 1.5\nb = true\nd = 1979-05-27\nldt = 1979-05-27T07:32:00\nlt = 07:32:00\nnums = [1, 2, 3]\nmixed = [1, \"a\"]\nempty = []\n")
|
||||
code := Run([]string{"-struct"}, in, &stdout, &stderr)
|
||||
if code != 0 {
|
||||
t.Fatalf("Run returned %d, want 0; stderr = %q", code, stderr.String())
|
||||
}
|
||||
out := stdout.String()
|
||||
for _, want := range []string{
|
||||
"F float64",
|
||||
"B bool",
|
||||
"D interpres.LocalDate",
|
||||
"Ldt interpres.LocalDateTime",
|
||||
"Lt interpres.LocalTime",
|
||||
"Nums []int64",
|
||||
"Mixed []any",
|
||||
"Empty []any",
|
||||
} {
|
||||
if !strings.Contains(out, want) {
|
||||
t.Errorf("output missing %q:\n%s", want, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user