Skip to content

Commit c9e199c

Browse files
committed
integrate mycology test suite
1 parent 95acfaf commit c9e199c

File tree

2 files changed

+942
-0
lines changed

2 files changed

+942
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.falsepattern.jfunge.storage;
2+
3+
import com.falsepattern.jfunge.interpreter.Interpreter;
4+
import lombok.val;
5+
import lombok.var;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.Test;
8+
9+
import java.io.ByteArrayInputStream;
10+
import java.io.ByteArrayOutputStream;
11+
import java.util.Arrays;
12+
13+
public class TestMycology {
14+
@Test
15+
public void testMycology() {
16+
val input = new ByteArrayInputStream(new byte[0]);
17+
val output = new ByteArrayOutputStream();
18+
val program = new ByteArrayOutputStream();
19+
Assertions.assertDoesNotThrow(() -> {
20+
val reader = TestMycology.class.getResourceAsStream("/mycology.b98");
21+
Assertions.assertNotNull(reader);
22+
var read = 0;
23+
val b = new byte[4096];
24+
while ((read = reader.read(b)) > 0) {
25+
program.write(b, 0, read);
26+
}
27+
});
28+
val returnCode = Assertions.assertDoesNotThrow(() -> Interpreter.executeProgram(false, new String[]{"mycology.b98"}, program.toByteArray(), 100000, input, output));
29+
Assertions.assertTrue(Arrays.stream(output.toString().split("\n")).noneMatch((line) -> line.startsWith("BAD")));
30+
Assertions.assertEquals(15, returnCode);
31+
}
32+
}

0 commit comments

Comments
 (0)