(t *testing.T)
| 532 | } |
| 533 | |
| 534 | func TestCheckTypeExpressionStructured(t *testing.T) { |
| 535 | tests := []struct { |
| 536 | tpe ast.BaseTerm |
| 537 | good []ast.Constant |
| 538 | bad []ast.Constant |
| 539 | }{ |
| 540 | { |
| 541 | tpe: symbols.NewMapType( |
| 542 | ast.NumberBound, |
| 543 | ast.StringBound, |
| 544 | ), |
| 545 | good: []ast.Constant{ |
| 546 | evalExpr(ast.ApplyFn{symbols.Map, []ast.BaseTerm{ |
| 547 | ast.Number(3), ast.String("three"), |
| 548 | ast.Number(4), ast.String("four"), |
| 549 | }}), |
| 550 | }, |
| 551 | bad: []ast.Constant{ |
| 552 | evalExpr(ast.ApplyFn{symbols.Map, []ast.BaseTerm{ |
| 553 | ast.String("three"), ast.Number(3), |
| 554 | ast.String("four"), ast.Number(4), |
| 555 | }}), |
| 556 | }, |
| 557 | }, |
| 558 | { |
| 559 | tpe: symbols.NewStructType( |
| 560 | name("/foo"), |
| 561 | ast.NumberBound, |
| 562 | name("/bar"), |
| 563 | ast.StringBound, |
| 564 | name("/baz"), |
| 565 | symbols.NewListType(ast.NumberBound), |
| 566 | ), |
| 567 | good: []ast.Constant{ |
| 568 | evalExpr(ast.ApplyFn{symbols.Struct, []ast.BaseTerm{ |
| 569 | name("/foo"), ast.Number(3), |
| 570 | name("/bar"), ast.String("three"), |
| 571 | name("/baz"), ast.ApplyFn{symbols.List, []ast.BaseTerm{ |
| 572 | ast.Number(23), |
| 573 | }}}}), |
| 574 | }, |
| 575 | bad: []ast.Constant{ |
| 576 | evalExpr(ast.ApplyFn{symbols.Struct, []ast.BaseTerm{ |
| 577 | name("/foo"), ast.Number(3), |
| 578 | }}), |
| 579 | }, |
| 580 | }, |
| 581 | } |
| 582 | for _, test := range tests { |
| 583 | h, err := symbols.NewBoundHandle(test.tpe) |
| 584 | if err != nil { |
| 585 | t.Errorf("NewMonoTypeHandle(%v) failed %v", test.tpe, err) |
| 586 | } |
| 587 | for _, c := range test.good { |
| 588 | if !h.HasType(c) { |
| 589 | t.Errorf("NewMonoTypeHandle(%v).HasType(%v)=false want true", test.tpe, c) |
| 590 | } |
| 591 | } |
nothing calls this directly
no test coverage detected