(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestCompile(t *testing.T) { |
| 52 | var tests = []struct { |
| 53 | code string |
| 54 | want vm.Program |
| 55 | }{ |
| 56 | { |
| 57 | `65535`, |
| 58 | vm.Program{ |
| 59 | Constants: []any{ |
| 60 | math.MaxUint16, |
| 61 | }, |
| 62 | Bytecode: []vm.Opcode{ |
| 63 | vm.OpPush, |
| 64 | }, |
| 65 | Arguments: []int{0}, |
| 66 | }, |
| 67 | }, |
| 68 | { |
| 69 | `.5`, |
| 70 | vm.Program{ |
| 71 | Constants: []any{ |
| 72 | .5, |
| 73 | }, |
| 74 | Bytecode: []vm.Opcode{ |
| 75 | vm.OpPush, |
| 76 | }, |
| 77 | Arguments: []int{0}, |
| 78 | }, |
| 79 | }, |
| 80 | { |
| 81 | `true`, |
| 82 | vm.Program{ |
| 83 | Bytecode: []vm.Opcode{ |
| 84 | vm.OpTrue, |
| 85 | }, |
| 86 | Arguments: []int{0}, |
| 87 | }, |
| 88 | }, |
| 89 | { |
| 90 | `"string"`, |
| 91 | vm.Program{ |
| 92 | Constants: []any{ |
| 93 | "string", |
| 94 | }, |
| 95 | Bytecode: []vm.Opcode{ |
| 96 | vm.OpPush, |
| 97 | }, |
| 98 | Arguments: []int{0}, |
| 99 | }, |
| 100 | }, |
| 101 | { |
| 102 | `"string" == "string"`, |
| 103 | vm.Program{ |
| 104 | Constants: []any{ |
| 105 | "string", |
| 106 | }, |
| 107 | Bytecode: []vm.Opcode{ |
| 108 | vm.OpPush, |
nothing calls this directly
no test coverage detected
searching dependent graphs…