Skip to content

Conversation

fxnn
Copy link
Owner

@fxnn fxnn commented Jul 3, 2022

This allows to write Brainfuck using TDD! 🤓

Idea:

  1. Divide your Brainfuck code into blocks using the # instruction.
  2. Test all the code since the last # instruction by adding one or more blocks enclosed in {...}.
  3. Inside the test block, place the given tape contents, optionally followed by an ampersand & and the given input characters, followed by a tilde ~, followed by the expected tape contents after running the code, finally optionally followed by an ampersand & and the expected output characters.

When giving tape contents, input or output characters, the format is zero or multiple integers, separated by an arbitrary amount of whitespace. The rest of the tape/input/output is filled with zeroes. Denote the tape cursor position by suffixing the integer with an exclamation mark. When asserting, denote arbitrary places with an underscore _.

Example:

# duplicate the number
[->+>+<<]>>[-<<+>>]<<
{3! 0 ~ _ 3 }
{3! 0 0 ~ 3! 3 0}

@fxnn fxnn self-assigned this Jul 3, 2022
@fxnn fxnn changed the title add TddBrainfuckInstructionSet TDD Brainfuck Jul 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant