118 lines
2.1 KiB
Go
118 lines
2.1 KiB
Go
package compiler
|
|
|
|
import "testing"
|
|
|
|
func TestHelloWorld (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/hello", nil,
|
|
"", "Hello, world!\n",
|
|
0,
|
|
)}
|
|
|
|
func TestExitCode13 (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/exitcode13", nil,
|
|
"", "",
|
|
13,
|
|
)}
|
|
|
|
func TestSystemInclude (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/systeminclude", nil,
|
|
"", "Hello, /usr/include!\n",
|
|
0,
|
|
)}
|
|
|
|
func TestSystemSrc (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/systemsrc", dependencies,
|
|
"", "Hello, /usr/src!\n",
|
|
0,
|
|
)}
|
|
|
|
func TestArgC (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/argc", nil,
|
|
"", "",
|
|
2, "arg1", "arg2",
|
|
)}
|
|
|
|
// TODO: uncomment once #47 has been dealt with
|
|
// func TestArgV (test *testing.T) {
|
|
// testUnit (test,
|
|
// "/test-data/data/argv", nil,
|
|
// "", "This is an argument\n",
|
|
// 0, "This is an argument",
|
|
// )}
|
|
|
|
func TestSimpleInterface (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/simpleinterface", nil,
|
|
"", "",
|
|
9,
|
|
)}
|
|
|
|
func TestWriterInterface (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/writer", dependencies,
|
|
"", "well hello their\n",
|
|
0,
|
|
)}
|
|
|
|
func TestMatchExitCode (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/matchexitcode", nil,
|
|
"", "",
|
|
7,
|
|
)}
|
|
|
|
func TestMatchPrint (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/matchprint", dependencies,
|
|
"", "F64\n",
|
|
0,
|
|
)}
|
|
|
|
func TestReturnAssign (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/returnassign", dependencies,
|
|
"", "false\n",
|
|
0,
|
|
)}
|
|
|
|
func TestLoopBreakExitCode (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/loop-break-exit-code", nil,
|
|
"", "",
|
|
5,
|
|
)}
|
|
|
|
func TestLoopBreakBranchExitCode (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/loop-break-branch-exit-code", nil,
|
|
"", "",
|
|
2,
|
|
)}
|
|
|
|
func TestForStringArray (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/for-string-array", dependencies,
|
|
"", "a\nb\nc\na\nb\nc\n",
|
|
0,
|
|
)}
|