BookLogic.java

1
package io.github.some_example_name;
2
3
/**
4
 * <code>BookLogic</code> contains core logic for Book interaction.
5
 * <p>
6
 * Made for unit testing.
7
 */
8
public class BookLogic {
9
10
    private boolean searched = false;
11
    private boolean showQuiz = false;
12
13
    private float messageTimer = 0f;
14
    private final float messageDuration;
15
16
    /**
17
     * Constructs BookLogic with a given message duration.
18
     *
19
     * @param messageDuration how long the quiz message should be active
20
     */
21
    public BookLogic(float messageDuration) {
22
        this.messageDuration = messageDuration;
23
    }
24
25
    /**
26
     * Marks the book as searched and triggers quiz.
27
     */
28
    public void search() {
29 1 1. search : negated conditional → KILLED
        if (!searched) {
30
            searched = true;
31
            showQuiz = true;
32
            messageTimer = 0f;
33
        }
34
    }
35
36
    /**
37
     * Updates internal timers.
38
     *
39
     * @param delta time elapsed since last frame
40
     */
41
    public void update(float delta) {
42 1 1. update : negated conditional → KILLED
        if (showQuiz) {
43 1 1. update : Replaced float addition with subtraction → KILLED
            messageTimer += delta;
44 2 1. update : negated conditional → KILLED
2. update : changed conditional boundary → KILLED
            if (messageTimer >= messageDuration) {
45
                showQuiz = false;
46
            }
47
        }
48
    }
49
50
    public boolean isSearched() {
51 2 1. isSearched : replaced boolean return with false for io/github/some_example_name/BookLogic::isSearched → KILLED
2. isSearched : replaced boolean return with true for io/github/some_example_name/BookLogic::isSearched → KILLED
        return searched;
52
    }
53
54
    public boolean shouldShowQuiz() {
55 2 1. shouldShowQuiz : replaced boolean return with false for io/github/some_example_name/BookLogic::shouldShowQuiz → KILLED
2. shouldShowQuiz : replaced boolean return with true for io/github/some_example_name/BookLogic::shouldShowQuiz → KILLED
        return showQuiz;
56
    }
57
}
58

Mutations

29

1.1
Location : search
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:quizRemainsVisibleBeforeTimeout()]
negated conditional → KILLED

42

1.1
Location : update
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:quizHidesExactlyAtBoundary()]
negated conditional → KILLED

43

1.1
Location : update
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:quizHidesExactlyAtBoundary()]
Replaced float addition with subtraction → KILLED

44

1.1
Location : update
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:quizHidesExactlyAtBoundary()]
negated conditional → KILLED

2.2
Location : update
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:quizHidesExactlyAtBoundary()]
changed conditional boundary → KILLED

51

1.1
Location : isSearched
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:searchOnlyWorksOnce()]
replaced boolean return with false for io/github/some_example_name/BookLogic::isSearched → KILLED

2.2
Location : isSearched
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:bookIsNotSearchedInitially()]
replaced boolean return with true for io/github/some_example_name/BookLogic::isSearched → KILLED

55

1.1
Location : shouldShowQuiz
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:quizRemainsVisibleBeforeTimeout()]
replaced boolean return with false for io/github/some_example_name/BookLogic::shouldShowQuiz → KILLED

2.2
Location : shouldShowQuiz
Killed by : io.github.some_example_name.BookLogicTest.[engine:junit-jupiter]/[class:io.github.some_example_name.BookLogicTest]/[method:quizHidesExactlyAtBoundary()]
replaced boolean return with true for io/github/some_example_name/BookLogic::shouldShowQuiz → KILLED

Active mutators

Tests examined


Report generated by PIT 1.15.0