all repos

scratch @ 753ee96

⭐ me doing recreational ~~drugs~~ programming

scratch/brainfuck/test/gbf_parser_test.gleam (view raw)

1
import gbf/internal/lexer.{Position}
2
import gbf/internal/parser.{Block, Leaf, Node}
3
import gbf/internal/token.{DecrementByte, IncrementByte, IncrementPointer}
4
import gleeunit/should
5
6
pub fn should_parse_test() {
7
  "+[->+]>"
8
  |> lexer.new
9
  |> lexer.lex
10
  |> parser.parse
11
  |> should.equal(
12
    Ok(
13
      Node(
14
        Block(position: Position(0), children: [
15
          Leaf(#(IncrementByte, Position(0))),
16
          Node(
17
            Block(position: Position(1), children: [
18
              Leaf(#(DecrementByte, Position(2))),
19
              Leaf(#(IncrementPointer, Position(3))),
20
              Leaf(#(IncrementByte, Position(4))),
21
            ]),
22
          ),
23
          Leaf(#(IncrementPointer, Position(6))),
24
        ]),
25
      ),
26
    ),
27
  )
28
}