Improved tests

This commit is contained in:
2024-07-29 18:03:15 +02:00
parent ce74685231
commit ae8e46de4d
4 changed files with 52 additions and 29 deletions

View File

@ -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)
})
}
}