Skip to content

Commit

Permalink
finished writing the test routine and got the first test to pass. rea…
Browse files Browse the repository at this point in the history
…lized i still need to complete compileExpressionList
  • Loading branch information
Isaiah Becker-Mayer committed Mar 8, 2021
1 parent 3483e91 commit 16d0444
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Compiler/test/ExpressionLessSquare/Main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@
</subroutineBody>
</subroutineDec>
<symbol> } </symbol>
</class>
</class>
27 changes: 27 additions & 0 deletions Compiler/test/compilationengine_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package test

import (
"bytes"
"io/ioutil"
"strings"
"testing"

"github.com/ibeckermayer/Nand2TetrisFPGA/Compiler/pkg/compiler"
Expand All @@ -13,8 +16,32 @@ func runCeTest(jackFilePath string, t *testing.T) {
if err != nil {
t.Fatal(err)
}

correctFilePath := strings.Replace(jackFilePath, ".jack", ".xml", -1)
outFilePath := strings.Replace(jackFilePath, ".jack", "_out.xml", -1)

b1, err := ioutil.ReadFile(correctFilePath)
if err != nil {
t.Fatal(err)
}
b2, err := ioutil.ReadFile(outFilePath)
if err != nil {
t.Fatal(err)
}

if !(bytes.Equal(b1, b2)) {
t.Fatal("Files weren't equal!")
}
}

func TestCeExpressionLessSquareMain(t *testing.T) {
runCeTest("./ExpressionLessSquare/Main.jack", t)
}

func TestCeExpressionLessSquareSquare(t *testing.T) {
runCeTest("./ExpressionLessSquare/Square.jack", t)
}

func TestCeExpressionLessSquareSquareGame(t *testing.T) {
runCeTest("./ExpressionLessSquare/SquareGame.jack", t)
}

0 comments on commit 16d0444

Please sign in to comment.