RegisterChanges.java

1
package com.rox.debug.cpu;
2
3
import com.rox.cpu.mos6502.MOS6502Snapshot;
4
5
import java.util.LinkedHashSet;
6
import java.util.Set;
7
8
/**
9
 * Which registers and flags changed at the most recent change - kept until the next one, so while paused
10
 * a step's changes stay visible across refreshes instead of clearing on the next identical read.
11
 * Names: {@code PC}, {@code A}, {@code X}, {@code Y}, {@code SP}, and flag letters {@code N V B D I Z C}.
12
 */
13
public final class RegisterChanges {
14
    private MOS6502Snapshot previous;
15
    private Set<String> lastChanged = Set.of();
16
17
    /** @return what differs from the last different state seen (nothing on the first call) */
18
    public Set<String> update(final MOS6502Snapshot current){
19 1 1. update : negated conditional → KILLED
        if (previous != null){
20
            final Set<String> changed = diff(previous, current);
21
            //an untracked change (IRQ line, NMI latch) alone keeps the last highlights rather than clearing them
22 1 1. update : negated conditional → KILLED
            if (!changed.isEmpty()){
23
                lastChanged = Set.copyOf(changed);
24
            }
25
        }
26
        previous = current;
27 1 1. update : replaced return value with Collections.emptySet for com/rox/debug/cpu/RegisterChanges::update → KILLED
        return lastChanged;
28
    }
29
30
    private static Set<String> diff(final MOS6502Snapshot before, final MOS6502Snapshot after){
31
        final Set<String> changed = new LinkedHashSet<>();
32 2 1. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
2. diff : negated conditional → KILLED
        addIf(changed, before.pc() != after.pc(), "PC");
33 2 1. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
2. diff : negated conditional → KILLED
        addIf(changed, before.a() != after.a(), "A");
34 2 1. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
2. diff : negated conditional → KILLED
        addIf(changed, before.x() != after.x(), "X");
35 2 1. diff : negated conditional → KILLED
2. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
        addIf(changed, before.y() != after.y(), "Y");
36 2 1. diff : negated conditional → KILLED
2. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
        addIf(changed, before.stackPointer() != after.stackPointer(), "SP");
37 2 1. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
2. diff : negated conditional → KILLED
        addIf(changed, before.negative() != after.negative(), "N");
38 2 1. diff : negated conditional → KILLED
2. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
        addIf(changed, before.signedOverflow() != after.signedOverflow(), "V");
39 2 1. diff : negated conditional → KILLED
2. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
        addIf(changed, before.breakFlag() != after.breakFlag(), "B");
40 2 1. diff : negated conditional → KILLED
2. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
        addIf(changed, before.decimal() != after.decimal(), "D");
41 2 1. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
2. diff : negated conditional → KILLED
        addIf(changed, before.interruptDisable() != after.interruptDisable(), "I");
42 2 1. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
2. diff : negated conditional → KILLED
        addIf(changed, before.zero() != after.zero(), "Z");
43 2 1. diff : negated conditional → KILLED
2. diff : removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED
        addIf(changed, before.carry() != after.carry(), "C");
44 1 1. diff : replaced return value with Collections.emptySet for com/rox/debug/cpu/RegisterChanges::diff → KILLED
        return changed;
45
    }
46
47
    private static void addIf(final Set<String> changed, final boolean differs, final String name){
48 1 1. addIf : negated conditional → KILLED
        if (differs){
49
            changed.add(name);
50
        }
51
    }
52
}

Mutations

19

1.1
Location : update
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:nothingHasChangedOnTheFirstLook()]
negated conditional → KILLED

22

1.1
Location : update
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

27

1.1
Location : update
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
replaced return value with Collections.emptySet for com/rox/debug/cpu/RegisterChanges::update → KILLED

32

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

33

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

34

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedRegister()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

35

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedRegister()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

36

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedRegister()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

37

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedFlag()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

38

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedFlag()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

39

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedFlag()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

40

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedFlag()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

41

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedFlag()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

42

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedFlag()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

43

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

2.2
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:reportsEachChangedFlag()]
removed call to com/rox/debug/cpu/RegisterChanges::addIf → KILLED

44

1.1
Location : diff
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
replaced return value with Collections.emptySet for com/rox/debug/cpu/RegisterChanges::diff → KILLED

48

1.1
Location : addIf
Killed by : com.rox.debug.cpu.RegisterChangesTest.[engine:junit-jupiter]/[class:com.rox.debug.cpu.RegisterChangesTest]/[method:anUntrackedChangeAloneKeepsTheLastHighlights()]
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.1