The division test was wrong
This commit is contained in:
parent
287d23fe36
commit
884f00d048
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user