The division test was wrong

This commit is contained in:
Sasha Koshka 2022-08-28 19:59:00 -04:00
parent 287d23fe36
commit 884f00d048
2 changed files with 6 additions and 6 deletions

View File

@ -117,7 +117,7 @@ func (machine *Machine) Execute(offset int) (err error) {
// last word on the stack
left := machine.Pop()
right := machine.Pop()
if left == 0 && right == 0 {
if right == 0 {
err = ErrorDivideByZero
return
}

View File

@ -34,23 +34,23 @@ func TestArithmetic(test *testing.T) {
PUSH, 3,
ADD,
PUSH, 10,
PUSH, 4,
PUSH, 10,
SUB,
PUSH, 7,
PUSH, 2,
MUL,
PUSH, 12,
PUSH, 3,
PUSH, 12,
DIV,
}, test)
addResult := machine.Pop()
subResult := machine.Pop()
mulResult := machine.Pop()
divResult := machine.Pop()
mulResult := machine.Pop()
subResult := machine.Pop()
addResult := machine.Pop()
test.Log("add:", addResult)
test.Log("sub:", subResult)