package tests_test import ( "path/filepath" "testing" "git.akyoto.dev/cli/q/src/build" "git.akyoto.dev/go/assert" ) var examples = []struct { Name string Input string Output string ExitCode int }{ {"hello", "", "Hello", 0}, {"factorial", "", "", 120}, {"fibonacci", "", "", 55}, {"array", "", "ABCD", 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) }) } } func BenchmarkExamples(b *testing.B) { for _, test := range examples { b.Run(test.Name, func(b *testing.B) { compiler := build.New(filepath.Join("..", "examples", test.Name)) for i := 0; i < b.N; i++ { _, err := compiler.Run() assert.Nil(b, err) } }) } }