From 1e3b90c865726d191859866f7b10ac5d14b936d9 Mon Sep 17 00:00:00 2001 From: Emily Marshall <e.marshall3@student.unimelb.edu.au> Date: Tue, 11 Sep 2018 03:49:18 +1000 Subject: [PATCH] Update Machine.java --- mutants/mutant-4/swen90006/machine/Machine.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mutants/mutant-4/swen90006/machine/Machine.java b/mutants/mutant-4/swen90006/machine/Machine.java index 9bf5731..f5e5c1e 100644 --- a/mutants/mutant-4/swen90006/machine/Machine.java +++ b/mutants/mutant-4/swen90006/machine/Machine.java @@ -1,3 +1,6 @@ +//abs value of register value in ADD: +//may not be caught if test cases don't include +//negative values for ADD insturction. package swen90006.machine; import java.util.Arrays; @@ -58,7 +61,11 @@ public class Machine private void do_add(int dest, int src1, int src2) { - regs[dest] = regs[src1] + regs[src2]; + regs[dest] = regs[src1] + abs(regs[src2]); +//abs value of register value in ADD: +//may not be caught if test cases don't include +//negative values for ADD insturction. + } private void do_sub(int dest, int src1, int src2) @@ -77,6 +84,7 @@ public class Machine /* no op */ }else{ regs[dest] = regs[src1] / regs[src2]; + } } @@ -168,9 +176,10 @@ public class Machine int instructionsExecuted = 0; int pc = 0; - final int progLength = instructions.size(); + final int progLength = instructions.size()-1; while(true){ if (pc < 0 || pc >= progLength){ + /* will cause NoReturnValueException to be thrown * but that is not a bug and and indeed is what the * VM is supposed to do if the pc becomes negative, -- GitLab