Skip to content

Commit

Permalink
add test for double for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
bobertlo committed Nov 17, 2024
1 parent e3f406a commit 9de21db
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,30 @@ func TestCompileForLoop(t *testing.T) {
{Op: DAT, OpMode: F, AMode: DIRECT, A: 123, BMode: DIRECT, B: 123},
}, w.Code)
}

func TestCompileDoubleForLoop(t *testing.T) {
config := ConfigNOP94()

input := `
dat 123, 123
i for 3
j for 2
dat i, j
rof
rof
dat 123, 123
`

w, err := CompileWarrior(strings.NewReader(input), config)
require.NoError(t, err)
assert.Equal(t, []Instruction{
{Op: DAT, OpMode: F, AMode: DIRECT, A: 123, BMode: DIRECT, B: 123},
{Op: DAT, OpMode: F, AMode: DIRECT, A: 1, BMode: DIRECT, B: 1},
{Op: DAT, OpMode: F, AMode: DIRECT, A: 1, BMode: DIRECT, B: 2},
{Op: DAT, OpMode: F, AMode: DIRECT, A: 2, BMode: DIRECT, B: 1},
{Op: DAT, OpMode: F, AMode: DIRECT, A: 2, BMode: DIRECT, B: 2},
{Op: DAT, OpMode: F, AMode: DIRECT, A: 3, BMode: DIRECT, B: 1},
{Op: DAT, OpMode: F, AMode: DIRECT, A: 3, BMode: DIRECT, B: 2},
{Op: DAT, OpMode: F, AMode: DIRECT, A: 123, BMode: DIRECT, B: 123},
}, w.Code)
}

0 comments on commit 9de21db

Please sign in to comment.