Improved tests
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"git.akyoto.dev/cli/q/src/build"
|
||||
"git.akyoto.dev/cli/q/src/build/config"
|
||||
"git.akyoto.dev/go/assert"
|
||||
)
|
||||
|
||||
@ -18,13 +19,22 @@ var examples = []struct {
|
||||
{"factorial", "", "", 120},
|
||||
{"fibonacci", "", "", 55},
|
||||
{"array", "", "Hello", 0},
|
||||
{"echo", "Echo", "Echo", 0},
|
||||
{"itoa", "", "9223372036854775807", 0},
|
||||
}
|
||||
|
||||
func TestExamples(t *testing.T) {
|
||||
for _, test := range examples {
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
run(t, filepath.Join("..", "examples", test.Name), test.Input, test.Output, test.ExitCode)
|
||||
directory := filepath.Join("..", "examples", test.Name)
|
||||
|
||||
t.Run(test.Name+"/debug", func(t *testing.T) {
|
||||
config.ConstantFold = false
|
||||
run(t, directory, "debug", test.Name, test.Input, test.Output, test.ExitCode)
|
||||
})
|
||||
|
||||
t.Run(test.Name+"/release", func(t *testing.T) {
|
||||
config.ConstantFold = true
|
||||
run(t, directory, "release", test.Name, test.Input, test.Output, test.ExitCode)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user