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
|
// last word on the stack
|
||||||
left := machine.Pop()
|
left := machine.Pop()
|
||||||
right := machine.Pop()
|
right := machine.Pop()
|
||||||
if left == 0 && right == 0 {
|
if right == 0 {
|
||||||
err = ErrorDivideByZero
|
err = ErrorDivideByZero
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -34,23 +34,23 @@ func TestArithmetic(test *testing.T) {
|
|||||||
PUSH, 3,
|
PUSH, 3,
|
||||||
ADD,
|
ADD,
|
||||||
|
|
||||||
PUSH, 10,
|
|
||||||
PUSH, 4,
|
PUSH, 4,
|
||||||
|
PUSH, 10,
|
||||||
SUB,
|
SUB,
|
||||||
|
|
||||||
PUSH, 7,
|
PUSH, 7,
|
||||||
PUSH, 2,
|
PUSH, 2,
|
||||||
MUL,
|
MUL,
|
||||||
|
|
||||||
PUSH, 12,
|
|
||||||
PUSH, 3,
|
PUSH, 3,
|
||||||
|
PUSH, 12,
|
||||||
DIV,
|
DIV,
|
||||||
}, test)
|
}, test)
|
||||||
|
|
||||||
addResult := machine.Pop()
|
|
||||||
subResult := machine.Pop()
|
|
||||||
mulResult := machine.Pop()
|
|
||||||
divResult := machine.Pop()
|
divResult := machine.Pop()
|
||||||
|
mulResult := machine.Pop()
|
||||||
|
subResult := machine.Pop()
|
||||||
|
addResult := machine.Pop()
|
||||||
|
|
||||||
test.Log("add:", addResult)
|
test.Log("add:", addResult)
|
||||||
test.Log("sub:", subResult)
|
test.Log("sub:", subResult)
|
||||||
|
Loading…
Reference in New Issue
Block a user