(t *testing.T)
| 597 | } |
| 598 | |
| 599 | func TestEquivMapAndStructExpr(t *testing.T) { |
| 600 | fac := ast.NewExprFactory() |
| 601 | map1 := fac.NewMap(1, []ast.EntryExpr{ |
| 602 | fac.NewMapEntry(2, fac.NewIdent(3, "k"), fac.NewLiteral(4, types.Int(1)), false), |
| 603 | }) |
| 604 | map2 := fac.NewMap(10, []ast.EntryExpr{ |
| 605 | fac.NewMapEntry(20, fac.NewIdent(30, "k"), fac.NewLiteral(40, types.Int(1)), false), |
| 606 | }) |
| 607 | mapOpt := fac.NewMap(10, []ast.EntryExpr{ |
| 608 | fac.NewMapEntry(20, fac.NewIdent(30, "k"), fac.NewLiteral(40, types.Int(1)), true), |
| 609 | }) |
| 610 | |
| 611 | struct1 := fac.NewStruct(1, "MyStruct", []ast.EntryExpr{ |
| 612 | fac.NewStructField(2, "field", fac.NewLiteral(3, types.Int(1)), false), |
| 613 | }) |
| 614 | struct2 := fac.NewStruct(10, "MyStruct", []ast.EntryExpr{ |
| 615 | fac.NewStructField(20, "field", fac.NewLiteral(30, types.Int(1)), false), |
| 616 | }) |
| 617 | structOpt := fac.NewStruct(10, "MyStruct", []ast.EntryExpr{ |
| 618 | fac.NewStructField(20, "field", fac.NewLiteral(30, types.Int(1)), true), |
| 619 | }) |
| 620 | structDiffField := fac.NewStruct(10, "MyStruct", []ast.EntryExpr{ |
| 621 | fac.NewStructField(20, "other", fac.NewLiteral(30, types.Int(1)), false), |
| 622 | }) |
| 623 | |
| 624 | if !ast.EquivExpr(map1, map2) { |
| 625 | t.Errorf("ast.EquivExpr(map1, map2) = false, want true") |
| 626 | } |
| 627 | if ast.EquivExpr(map1, mapOpt) { |
| 628 | t.Errorf("ast.EquivExpr(map1, mapOpt) = true, want false") |
| 629 | } |
| 630 | if !ast.EquivExpr(struct1, struct2) { |
| 631 | t.Errorf("ast.EquivExpr(struct1, struct2) = false, want true") |
| 632 | } |
| 633 | if ast.EquivExpr(struct1, structOpt) { |
| 634 | t.Errorf("ast.EquivExpr(struct1, structOpt) = true, want false") |
| 635 | } |
| 636 | if ast.EquivExpr(struct1, structDiffField) { |
| 637 | t.Errorf("ast.EquivExpr(struct1, structDiffField) = true, want false") |
| 638 | } |
| 639 | if ast.EquivExpr(map1, struct1) { |
| 640 | t.Errorf("ast.EquivExpr(map1, struct1) = true, want false") |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | type customExpr struct { |
| 645 | ast.Expr |
nothing calls this directly
no test coverage detected