(t *testing.T)
| 689 | } |
| 690 | |
| 691 | func TestConvertVal(t *testing.T) { |
| 692 | tests := []ref.Val{ |
| 693 | types.True, |
| 694 | types.Bytes("bytes"), |
| 695 | types.Double(3.2), |
| 696 | types.Int(-1), |
| 697 | types.NullValue, |
| 698 | types.String("string"), |
| 699 | types.Uint(27), |
| 700 | } |
| 701 | for _, tst := range tests { |
| 702 | c, err := ast.ValToConstant(tst) |
| 703 | if err != nil { |
| 704 | t.Errorf("ValToConstant(%v) failed: %v", tst, err) |
| 705 | } |
| 706 | v, err := ast.ConstantToVal(c) |
| 707 | if err != nil { |
| 708 | t.Errorf("ValToConstant(%v) failed: %v", c, err) |
| 709 | } |
| 710 | if tst.Equal(v) != types.True { |
| 711 | t.Errorf("roundtrip from %v to %v and back did not produce equal results, got %v, wanted %v", tst, c, v, tst) |
| 712 | } |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | func TestValToConstantError(t *testing.T) { |
| 717 | out, err := ast.ValToConstant(types.Duration{Duration: time.Duration(10)}) |
nothing calls this directly
no test coverage detected