155 lines
2.8 KiB
Go
155 lines
2.8 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/exit-code-13", nil,
|
|
"", "",
|
|
13,
|
|
)}
|
|
|
|
func TestSystemInclude (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/system-include", nil,
|
|
"", "Hello, /usr/include!\n",
|
|
0,
|
|
)}
|
|
|
|
func TestSystemSrc (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/system-src", 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/simple-interface", 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/match-exit-code", nil,
|
|
"", "",
|
|
7,
|
|
)}
|
|
|
|
func TestMatchPrint (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/match-print", dependencies,
|
|
"", "F64\n",
|
|
0,
|
|
)}
|
|
|
|
func TestMatchDefaultPrint (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/match-default-print", dependencies,
|
|
"", "something else\n",
|
|
0,
|
|
)}
|
|
|
|
func TestReturnAssign (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/return-assign", 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 TestForSimple (test *testing.T) {
|
|
testUnit (test,
|
|
"/test-data/data/for-simple", nil,
|
|
"", "",
|
|
0,
|
|
)}
|
|
|
|
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,
|
|
)}
|
|
|
|
func TestForStringArrayOnce (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/for-string-array-once", dependencies,
|
|
"", "abc\n",
|
|
0,
|
|
)}
|
|
|
|
func TestForBreakBranch (test *testing.T) {
|
|
dependencies := []string {
|
|
compileDependency(test, "io"),
|
|
}
|
|
testUnit (test,
|
|
"/test-data/data/for-break-branch", dependencies,
|
|
"", "iter\niter\n",
|
|
0,
|
|
)}
|