package nl.dvberkel.brainfuck.language;

import nl.dvberkel.brainfuck.language.instruction.PlusInstruction;
import nl.dvberkel.brainfuck.machine.BrainfuckMachine;
import org.junit.Test;

import static nl.dvberkel.util.ByteArrayFactory.ofLength;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

public class ProgramTest {
    @Test
    public void shouldExecuteOnMachine() {
        Program program = new PlusInstruction();
        BrainfuckMachine machine = new BrainfuckMachine(3);

        program.executeOn(machine);

        assertThat(machine.getCells(), is(ofLength(3).withContent(1)));
    }
}

@@ -156,16 +156,41 @@
 achine;%0A
+import org.junit.Before;%0A
 import o
@@ -373,16 +373,160 @@
 mTest %7B%0A
+    private BrainfuckMachine machine;%0A%0A    @Before%0A    public void createBrainfuckMachine() %7B%0A        machine = new BrainfuckMachine(3);%0A    %7D%0A%0A
     @Tes
@@ -622,68 +622,8 @@
 n();
-%0A        BrainfuckMachine machine = new BrainfuckMachine(3);
 %0A%0A  

make machine for each program test