MemoryLine.java

1
// Copyright © 2004-2006 University of Helsinki, Department of Computer Science
2
// Copyright © 2012 various contributors
3
// This software is released under GNU Lesser General Public License 2.1.
4
// The license text is at http://www.gnu.org/licenses/lgpl-2.1.html
5
6
package fi.helsinki.cs.titokone;
7
8
/**
9
 * This class represents one slot in the TTK-91 computer's memory. It
10
 * contains both the integer value stored in the memory as well as
11
 * its symbolic code representation. As such, the class is not
12
 * strictly to be used in a computer's memory, but can also bridge the
13
 * gap between applications' binary and symbolic form.
14
 */
15
public class MemoryLine {
16
    /**
17
     * This field contains the symbolic form of the command. It is
18
     * empty if there is no symbolic representation for the binary.
19
     */
20
    private String symbolic;
21
    /**
22
     * This field contains the binary form of the data stored in this
23
     * line. It may be a valid command, or just a random number.
24
     */
25
    private int binary;
26
27
    /**
28
     * Creates a memory line with symbolic information.
29
     *
30
     * @param binary          Value of this memory slot.
31
     * @param symbolicCommand String that contains the corresponding
32
     *                        symbolic command, or an empty string ("") if there is no
33
     *                        representation.
34
     */
35
    public MemoryLine(int binary, String symbolicCommand) {
36 1
        this.binary = binary;
37 1
        symbolic = symbolicCommand;
38 1
        if (symbolic == null) {
39 1
            symbolic = "";
40
        }
41
    }
42
43
    /**
44
     * Returns the symbolic representation of the command. If the command
45
     * has no symbolic representation, an empty string is returned.
46
     *
47
     * @return Symbolic presentation of command. If symbolic
48
     *         representation of the command is not defined, an empty string is
49
     *         returned.
50
     */
51
    public String getSymbolic() {
52 1
        return symbolic;
53
    }
54
55
    /**
56
     * Returns the value of this memory slot.
57
     *
58
     * @return Integer value of this memory slot.
59
     */
60
    public int getBinary() {
61 1
        return binary;
62
    }
63
}

Mutations

36

Removed assignment to member variable binary : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testToString(fi.helsinki.cs.titokone.BinaryTest)

37

Removed assignment to member variable symbolic : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest)

38

negated conditional : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest)

39

Removed assignment to member variable symbolic : NO_COVERAGE

52

mutated return of Object value for fi/helsinki/cs/titokone/MemoryLine::getSymbolic to ( if (x != null) null else throw new RuntimeException ) : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testBinaryToApplication(fi.helsinki.cs.titokone.BinaryTest)

61

replaced return of integer sized value with (x == 0 ? 1 : 0) : KILLED -> fi.helsinki.cs.titokone.BinaryTest.testToString(fi.helsinki.cs.titokone.BinaryTest)

Active mutators

Tests examined


Report generated by PIT 0.27