add bracket syntax replace tests
This commit is contained in:
59
lang/test_ast_comparisons.go
Normal file
59
lang/test_ast_comparisons.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user