(t *testing.T)
| 678 | } |
| 679 | |
| 680 | func TestCompile_Expect(t *testing.T) { |
| 681 | tests := []struct { |
| 682 | input string |
| 683 | option expr.Option |
| 684 | op vm.Opcode |
| 685 | arg int |
| 686 | }{ |
| 687 | { |
| 688 | input: "1", |
| 689 | option: expr.AsKind(reflect.Int), |
| 690 | op: vm.OpCast, |
| 691 | arg: 0, |
| 692 | }, |
| 693 | { |
| 694 | input: "1", |
| 695 | option: expr.AsInt64(), |
| 696 | op: vm.OpCast, |
| 697 | arg: 1, |
| 698 | }, |
| 699 | { |
| 700 | input: "1", |
| 701 | option: expr.AsFloat64(), |
| 702 | op: vm.OpCast, |
| 703 | arg: 2, |
| 704 | }, |
| 705 | { |
| 706 | input: "true", |
| 707 | option: expr.AsBool(), |
| 708 | op: vm.OpCast, |
| 709 | arg: 3, |
| 710 | }, |
| 711 | } |
| 712 | |
| 713 | for _, tt := range tests { |
| 714 | t.Run(tt.input, func(t *testing.T) { |
| 715 | program, err := expr.Compile(tt.input, tt.option) |
| 716 | require.NoError(t, err) |
| 717 | |
| 718 | lastOp := program.Bytecode[len(program.Bytecode)-1] |
| 719 | lastArg := program.Arguments[len(program.Arguments)-1] |
| 720 | |
| 721 | assert.Equal(t, tt.op, lastOp) |
| 722 | assert.Equal(t, tt.arg, lastArg) |
| 723 | }) |
| 724 | } |
| 725 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…