code.Instructions with datum store side effects.
(t *testing.T)
| 658 | |
| 659 | // code.Instructions with datum store side effects. |
| 660 | func TestDatumSetInstrs(t *testing.T) { |
| 661 | tests := []datumStoreTests{ |
| 662 | { |
| 663 | name: "simple inc", |
| 664 | i: code.Instr{code.Inc, nil, 0}, |
| 665 | d: 0, |
| 666 | setup: func(t *thread, d datum.Datum) { |
| 667 | t.Push(d) |
| 668 | }, |
| 669 | expected: "1", |
| 670 | }, |
| 671 | { |
| 672 | name: "inc by int", |
| 673 | i: code.Instr{code.Inc, 0, 0}, |
| 674 | d: 0, |
| 675 | setup: func(t *thread, d datum.Datum) { |
| 676 | t.Push(d) |
| 677 | t.Push(2) |
| 678 | }, |
| 679 | expected: "2", |
| 680 | }, |
| 681 | { |
| 682 | name: "inc by str", |
| 683 | i: code.Instr{code.Inc, 0, 0}, |
| 684 | d: 0, |
| 685 | setup: func(t *thread, d datum.Datum) { |
| 686 | t.Push(d) |
| 687 | t.Push("4") |
| 688 | }, |
| 689 | expected: "4", |
| 690 | }, |
| 691 | { |
| 692 | name: "iset", |
| 693 | i: code.Instr{code.Iset, nil, 0}, |
| 694 | d: 0, |
| 695 | setup: func(t *thread, d datum.Datum) { |
| 696 | t.Push(d) |
| 697 | t.Push(2) |
| 698 | }, |
| 699 | expected: "2", |
| 700 | }, |
| 701 | { |
| 702 | name: "iset str", |
| 703 | i: code.Instr{code.Iset, nil, 0}, |
| 704 | d: 0, |
| 705 | setup: func(t *thread, d datum.Datum) { |
| 706 | t.Push(d) |
| 707 | t.Push("3") |
| 708 | }, |
| 709 | expected: "3", |
| 710 | }, |
| 711 | { |
| 712 | name: "fset", |
| 713 | i: code.Instr{code.Fset, nil, 0}, |
| 714 | d: 1, |
| 715 | setup: func(t *thread, d datum.Datum) { |
| 716 | t.Push(d) |
| 717 | t.Push(3.1) |
nothing calls this directly
no test coverage detected