split tests into separate files

This commit is contained in:
2025-08-22 00:59:14 -06:00
parent da43647b54
commit 1ee8de23da
7 changed files with 1061 additions and 930 deletions

View File

@ -0,0 +1,47 @@
package lang
import (
"testing"
)
func TestParseServerDefinitions(t *testing.T) {
tests := []struct {
name string
input string
want AST
wantErr bool
}{
{
name: "simple server definition",
input: `server MyApp host "localhost" port 8080`,
want: AST{
Definitions: []Definition{
{
Server: &Server{
Name: "MyApp",
Settings: []ServerSetting{
{Host: stringPtr("localhost")},
{Port: intPtr(8080)},
},
},
},
},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := ParseInput(tt.input)
if (err != nil) != tt.wantErr {
t.Errorf("ParseInput() error = %v, wantErr %v", err, tt.wantErr)
return
}
if !tt.wantErr && !astEqual(got, tt.want) {
t.Errorf("ParseInput() mismatch.\nGot: %+v\nWant: %+v", got, tt.want)
}
})
}
}