[Demonstration 1]

[Buggy Method]
public static void loadZone(Zone newZone, Zone oldZone) {
    switch(newZone) {
        case grassField:
            Entity grass = new Entity(Tilemap.resize(tilemap.getTile(25), 100), 0, 0, 0) {

                @Override
                public void update(ScreenEventsInfo info) {
                    // TODO Auto-generated method stub
                }

                @Override
                public BufferedImage getShadow() {
                    return tilemap.getTile(50);
                }
            };
            grass.setCulling(false);
            grass.setName("grass");
            window.addGuiAtIndex(grass, 0);
            Entity grass_monster = new GrassMonster(50, 50);
            //make trees on top
            //add seed so its the same
            Random rand = new Random(12321);
            for (int i1 = 0; i1 < 3; i1++) {
                for (int i = 0; i < 60; i++) {
                    Tree t = new Tree((i * 40) + (rand.nextInt(80) - rand.nextInt(80)), (rand.nextInt(80) - rand.nextInt(80)));
                    window.addGui(t);
                }
            }
            //make trees at left
            for (int i1 = 0; i1 < 3; i1++) {
                for (int i = 0; i < 60; i++) {
                    Tree t = new Tree(rand.nextInt(100) - rand.nextInt(100), (i * 40) + (rand.nextInt(100) - rand.nextInt(100)));
                    window.addGui(t);
                }
            }
            //make flowers
            for (int i = 0; i < 80; i++) {
                Flower f = new Flower(rand.nextInt(3000), rand.nextInt(3000));
                window.addGui(f);
            }
            //TODO: Temporary test.
            window.addGui(grass_monster);
            if (oldZone != null) {
                //player.setX(0);
                //player.setY(0);
                window.removeGui(player);
                // TODO: load old data
                Player p = new Player(player);
                window.setScroll_x((int) p.getX());
                window.setScroll_y((int) p.getY());
                if (oldZone == Zone.rogueDen) {
                    p.setCurrentSprite(1);
                }
            } else {
            }
            //RogueDenEntrance entrance = new RogueDenEntrance(500, 500);
            window.addGui(new RogueDenEntrance(500, 500));
            break;
    }
}

[Buggy Hunk]
new GrassMonster(50, 50);

[Patch]
new Rabbit(50, 50);

[Demonstration 2]

[Buggy Method]
@Test
public void ItCanStartASocketAtAPort() throws Exception {
    try (SocketWrapper socket = new SocketWrapper(5000)) {
        String data = "Test";
        StartSocket(socket);
        // Try to connect
        boolean connected = false;
        int retries = 0;
        while (!connected && retries < 5) {
            InetAddress host = InetAddress.getLocalHost();
            try (Socket client = new Socket(host.getHostName(), 5000)) {
                connected = true;
                String dataWritten = WriteToSocket(client, data + "\n");
                assertEquals("Test", dataWritten);
            } catch (ConnectException e) {
                Thread.sleep(100);
                retries++;
            }
        }
        // Throw exception if we couldn't retry
        if (retries >= 5) {
            throw new Exception();
        }
        assertEquals("data:" + data + " msg: " + processor.getMessage(), data, processor.getMessage());
    }
}

[Buggy Hunk]
assertEquals("data:" + data + " msg: " + processor.getMessage(), data, processor.getMessage());

[Patch]
assertEquals(data, processor.getMessage());

[Demonstration 3]

[Buggy Method]
@Override
private List<String> filterData(List<String> input, MetaSyntax m) {
    boolean skipLine = false;
    List<String> output = new ArrayList<>(input.size());
    for (String line : input) {
        if (line.matches(m.getSolutionFileRegex())) {
            return new ArrayList<>();
        }
        if (line.matches(m.getBeginSolutionRegex())) {
            skipLine = true;
        } else if (skipLine && line.matches(m.getEndSolutionRegex())) {
            skipLine = false;
        } else if (line.matches(m.getStubRegex())) {
            String stubContent = line.replaceFirst(m.getStubMarker(), "");
            stubContent = stubContent.replaceAll(m.getCommentEndRegex(), "");
            //NOTE: will remove all instances of commentEndRegex, for example --> --> -->
            output.add(stubContent);
        } else if (!skipLine) {
            output.add(line);
        }
    }
    return output;
}

[Buggy Hunk]
private List<String> filterData(List<String> input, MetaSyntax m) {

[Patch]
List<String> filterData(List<String> input, MetaSyntax m) {