(t *testing.T)
| 368 | } |
| 369 | |
| 370 | func TestMatchParser_MultipleArms(t *testing.T) { |
| 371 | input := `match result { |
| 372 | Ok(x) => x, |
| 373 | Err(e) => 0, |
| 374 | _ => -1 |
| 375 | }` |
| 376 | |
| 377 | tok := tokenizer.New([]byte(input)) |
| 378 | _, err := tok.Tokenize() |
| 379 | if err != nil { |
| 380 | t.Fatalf("tokenize error: %v", err) |
| 381 | } |
| 382 | |
| 383 | parser := NewMatchParser(tok) |
| 384 | expr, err := parser.ParseMatchExpr() |
| 385 | if err != nil { |
| 386 | t.Fatalf("parse error: %v", err) |
| 387 | } |
| 388 | |
| 389 | if len(expr.Arms) != 3 { |
| 390 | t.Errorf("got %d arms, want 3", len(expr.Arms)) |
| 391 | } |
| 392 | |
| 393 | // Verify pattern types |
| 394 | if _, ok := expr.Arms[0].Pattern.(*ast.ConstructorPattern); !ok { |
| 395 | t.Errorf("arm 0 pattern should be ConstructorPattern, got %T", expr.Arms[0].Pattern) |
| 396 | } |
| 397 | |
| 398 | if _, ok := expr.Arms[1].Pattern.(*ast.ConstructorPattern); !ok { |
| 399 | t.Errorf("arm 1 pattern should be ConstructorPattern, got %T", expr.Arms[1].Pattern) |
| 400 | } |
| 401 | |
| 402 | if _, ok := expr.Arms[2].Pattern.(*ast.WildcardPattern); !ok { |
| 403 | t.Errorf("arm 2 pattern should be WildcardPattern, got %T", expr.Arms[2].Pattern) |
| 404 | } |
| 405 | } |
| 406 | |
| 407 | func TestMatchParser_ComplexScrutinee(t *testing.T) { |
| 408 | tests := []struct { |
nothing calls this directly
no test coverage detected