|
@@ -9,6 +9,7 @@ func TestMake(t *testing.T) {
|
|
|
expected []byte
|
|
expected []byte
|
|
|
}{
|
|
}{
|
|
|
{OpConstant, []int{65534}, []byte{byte(OpConstant), 0xFF, 0xFE}},
|
|
{OpConstant, []int{65534}, []byte{byte(OpConstant), 0xFF, 0xFE}},
|
|
|
|
|
+ {OpAdd, []int{}, []byte{byte(OpAdd)}},
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for _, tt := range tests {
|
|
for _, tt := range tests {
|
|
@@ -28,14 +29,14 @@ func TestMake(t *testing.T) {
|
|
|
|
|
|
|
|
func TestInstructionsString(t *testing.T) {
|
|
func TestInstructionsString(t *testing.T) {
|
|
|
instructions := []Instructions{
|
|
instructions := []Instructions{
|
|
|
- Make(OpConstant, 1),
|
|
|
|
|
|
|
+ Make(OpAdd),
|
|
|
Make(OpConstant, 2),
|
|
Make(OpConstant, 2),
|
|
|
Make(OpConstant, 65535),
|
|
Make(OpConstant, 65535),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- expected := `0000 OpConstant 1
|
|
|
|
|
-0003 OpConstant 2
|
|
|
|
|
-0006 OpConstant 65535
|
|
|
|
|
|
|
+ expected := `0000 OpAdd
|
|
|
|
|
+0001 OpConstant 2
|
|
|
|
|
+0004 OpConstant 65535
|
|
|
`
|
|
`
|
|
|
|
|
|
|
|
concatted := Instructions{}
|
|
concatted := Instructions{}
|