From 9a5ca20d2537179f3a8e01762c8db6b52a4db2d9 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sat, 3 Oct 2026 14:03:48 -0700 Subject: Chapter 17a: Mutability and Read-Only Views --- .../java/com/seaofnodes/simple/BrainFuckTest.java | 80 ---------------------- 1 file changed, 80 deletions(-) delete mode 100644 src/test/java/com/seaofnodes/simple/BrainFuckTest.java (limited to 'src/test/java/com/seaofnodes/simple/BrainFuckTest.java') diff --git a/src/test/java/com/seaofnodes/simple/BrainFuckTest.java b/src/test/java/com/seaofnodes/simple/BrainFuckTest.java deleted file mode 100644 index 29ef8732..00000000 --- a/src/test/java/com/seaofnodes/simple/BrainFuckTest.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.seaofnodes.simple; - -import com.seaofnodes.simple.evaluator.Evaluator; -import com.seaofnodes.simple.node.StopNode; -import org.junit.Test; -import org.junit.Ignore; - -import java.nio.charset.StandardCharsets; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -public class BrainFuckTest { - - @Test - public void testBrainfuck() { - var program = "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.".getBytes(StandardCharsets.UTF_8); - var encoded = new StringBuilder("u8[] program = new u8[").append(program.length).append("];"); - for (int i = 0; i < program.length; i++) { - int value = program[i] & 0xFF; - encoded.append("program[").append(i).append("] = ").append(value).append(";"); - } - - Parser parser = new Parser( - encoded + """ -int pc = 0; -int d = 0; -u8[] data = new u8[100]; -u8[] output = new u8[0]; - -while (pc < program#) { - int command = program[pc]; - if (command == 62) { - d = d + 1; - } else if (command == 60) { - d = d - 1; - } else if (command == 43) { - data[d] = data[d] + 1; - } else if (command == 45) { - data[d] = data[d] - 1; - } else if (command == 46) { - u8[] old = output; - output = new u8[output# + 1]; - int i = 0; - while (i < old#) { - output[i] = old[i]; - i = i + 1; - } - output[i] = data[d]; - } else if (command == 44) { - data[d] = 42; - } else if (command == 91) { - if (data[d] == 0) { - int d = 1; - while (d > 0) { - pc = pc + 1; - command = program[pc]; - if (command == 91) d = d + 1; - if (command == 93) d = d - 1; - } - } - } else if (command == 93) { - if (data[d] != 0) { - int d = 1; - while (d > 0) { - pc = pc - 1; - command = program[pc]; - if (command == 93) d = d + 1; - if (command == 91) d = d - 1; - } - } - } - pc = pc + 1; -} -return output; - """); - StopNode stop = parser.parse().iterate(); - assertEquals("Hello World!\n", Evaluator.evaluate(stop, 0, 10000).toString()); - } -} -- cgit v1.2.3