add bracket syntax replace tests

This commit is contained in:
2025-08-24 23:25:43 -06:00
parent 4ac93ee924
commit e71b1c3a23
22 changed files with 3324 additions and 1673 deletions

View File

@ -0,0 +1,59 @@
package lang
// AST and definition comparison functions for parser tests
// Custom comparison functions (simplified for the new structure)
func astEqual(got, want AST) bool {
if len(got.Definitions) != len(want.Definitions) {
return false
}
for i := range got.Definitions {
if !definitionEqual(got.Definitions[i], want.Definitions[i]) {
return false
}
}
return true
}
func definitionEqual(got, want Definition) bool {
// Server comparison
if (got.Server == nil) != (want.Server == nil) {
return false
}
if got.Server != nil && want.Server != nil {
if !serverEqual(*got.Server, *want.Server) {
return false
}
}
// Entity comparison
if (got.Entity == nil) != (want.Entity == nil) {
return false
}
if got.Entity != nil && want.Entity != nil {
if !entityEqual(*got.Entity, *want.Entity) {
return false
}
}
// Endpoint comparison
if (got.Endpoint == nil) != (want.Endpoint == nil) {
return false
}
if got.Endpoint != nil && want.Endpoint != nil {
if !endpointEqual(*got.Endpoint, *want.Endpoint) {
return false
}
}
// Page comparison (enhanced)
if (got.Page == nil) != (want.Page == nil) {
return false
}
if got.Page != nil && want.Page != nil {
return pageEqual(*got.Page, *want.Page)
}
return true
}