TestParseContext_BackwardCompatibility verifies non-context method still works
(t *testing.T)
| 314 | |
| 315 | // TestParseContext_BackwardCompatibility verifies non-context method still works |
| 316 | func TestParseContext_BackwardCompatibility(t *testing.T) { |
| 317 | sql := "SELECT * FROM users" |
| 318 | tokens := tokenizeSQL(t, sql) |
| 319 | |
| 320 | p := NewParser() |
| 321 | defer p.Release() |
| 322 | |
| 323 | // Test old non-context method |
| 324 | ast1, err1 := p.Parse(tokens) |
| 325 | if err1 != nil { |
| 326 | t.Fatalf("Parse() error = %v", err1) |
| 327 | } |
| 328 | |
| 329 | // Test new context method with background context |
| 330 | ast2, err2 := p.ParseContext(context.Background(), tokens) |
| 331 | if err2 != nil { |
| 332 | t.Fatalf("ParseContext() error = %v", err2) |
| 333 | } |
| 334 | |
| 335 | // Both should produce ASTs |
| 336 | if ast1 == nil || ast2 == nil { |
| 337 | t.Error("Expected ASTs from both methods") |
| 338 | return |
| 339 | } |
| 340 | |
| 341 | // Both should have same number of statements |
| 342 | if len(ast1.Statements) != len(ast2.Statements) { |
| 343 | t.Errorf("Statement count mismatch: Parse()=%d, ParseContext()=%d", |
| 344 | len(ast1.Statements), len(ast2.Statements)) |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | // TestParseContext_ErrorHandling verifies proper error handling |
| 349 | func TestParseContext_ErrorHandling(t *testing.T) { |
nothing calls this directly
no test coverage detected