functions with bindings
This commit is contained in:
@@ -10,6 +10,7 @@ func TestMake(t *testing.T) {
|
||||
}{
|
||||
{OpConstant, []int{65534}, []byte{byte(OpConstant), 255, 254}},
|
||||
{OpAdd, []int{}, []byte{byte(OpAdd)}},
|
||||
{OpGetLocal, []int{255}, []byte{byte(OpGetLocal), 255}},
|
||||
}
|
||||
|
||||
for _, tt := range test {
|
||||
@@ -30,13 +31,15 @@ func TestMake(t *testing.T) {
|
||||
func TestInstructions(t *testing.T) {
|
||||
instructions := []Instructions{
|
||||
Make(OpAdd),
|
||||
Make(OpGetLocal, 1),
|
||||
Make(OpConstant, 2),
|
||||
Make(OpConstant, 65535),
|
||||
}
|
||||
|
||||
expected := `0000 OpAdd
|
||||
0001 OpConstant 2
|
||||
0004 OpConstant 65535
|
||||
0001 OpGetLocal 1
|
||||
0003 OpConstant 2
|
||||
0006 OpConstant 65535
|
||||
`
|
||||
|
||||
concatted := Instructions{}
|
||||
@@ -49,13 +52,14 @@ func TestInstructions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperands(t *testing.T) {
|
||||
func TestReadOperands(t *testing.T) {
|
||||
tests := []struct {
|
||||
op Opcode
|
||||
operands []int
|
||||
bytesRead int
|
||||
}{
|
||||
{OpConstant, []int{65535}, 2},
|
||||
{OpGetLocal, []int{255}, 1},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user