Added more tests
This commit is contained in:
parent
feebfe65bb
commit
795935ddfb
@ -1,26 +0,0 @@
|
|||||||
package tests_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"git.akyoto.dev/cli/q/src/build"
|
|
||||||
"git.akyoto.dev/go/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func BenchmarkEmpty(b *testing.B) {
|
|
||||||
compiler := build.New("benchmarks/empty.q")
|
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
_, err := compiler.Run()
|
|
||||||
assert.Nil(b, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkExpressions(b *testing.B) {
|
|
||||||
compiler := build.New("benchmarks/expressions.q")
|
|
||||||
|
|
||||||
for i := 0; i < b.N; i++ {
|
|
||||||
_, err := compiler.Run()
|
|
||||||
assert.Nil(b, err)
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,8 +10,7 @@ import (
|
|||||||
"git.akyoto.dev/go/assert"
|
"git.akyoto.dev/go/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestErrors(t *testing.T) {
|
var errs = []struct {
|
||||||
tests := []struct {
|
|
||||||
File string
|
File string
|
||||||
ExpectedError error
|
ExpectedError error
|
||||||
}{
|
}{
|
||||||
@ -37,7 +36,8 @@ func TestErrors(t *testing.T) {
|
|||||||
{"UnusedVariable.q", &errors.UnusedVariable{Name: "x"}},
|
{"UnusedVariable.q", &errors.UnusedVariable{Name: "x"}},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
func TestErrors(t *testing.T) {
|
||||||
|
for _, test := range errs {
|
||||||
name := strings.TrimSuffix(test.File, ".q")
|
name := strings.TrimSuffix(test.File, ".q")
|
||||||
|
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
|
@ -5,8 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestExamples(t *testing.T) {
|
var examples = []struct {
|
||||||
var tests = []struct {
|
|
||||||
Name string
|
Name string
|
||||||
ExpectedOutput string
|
ExpectedOutput string
|
||||||
ExpectedExitCode int
|
ExpectedExitCode int
|
||||||
@ -15,7 +14,8 @@ func TestExamples(t *testing.T) {
|
|||||||
{"write", "ELF", 0},
|
{"write", "ELF", 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
func TestExamples(t *testing.T) {
|
||||||
|
for _, test := range examples {
|
||||||
t.Run(test.Name, func(t *testing.T) {
|
t.Run(test.Name, func(t *testing.T) {
|
||||||
run(t, filepath.Join("..", "examples", test.Name), test.ExpectedOutput, test.ExpectedExitCode)
|
run(t, filepath.Join("..", "examples", test.Name), test.ExpectedOutput, test.ExpectedExitCode)
|
||||||
})
|
})
|
||||||
|
@ -10,16 +10,31 @@ import (
|
|||||||
"git.akyoto.dev/go/assert"
|
"git.akyoto.dev/go/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPrograms(t *testing.T) {
|
var programs = []struct {
|
||||||
var tests = []struct {
|
|
||||||
Name string
|
Name string
|
||||||
ExpectedOutput string
|
ExpectedOutput string
|
||||||
ExpectedExitCode int
|
ExpectedExitCode int
|
||||||
}{
|
}{
|
||||||
{"successive-calls.q", "", 9},
|
{"empty.q", "", 0},
|
||||||
|
{"square-sum.q", "", 25},
|
||||||
|
{"multi-calls.q", "", 9},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
func BenchmarkPrograms(b *testing.B) {
|
||||||
|
for _, test := range programs {
|
||||||
|
b.Run(test.Name, func(b *testing.B) {
|
||||||
|
compiler := build.New(filepath.Join("programs", test.Name))
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
_, err := compiler.Run()
|
||||||
|
assert.Nil(b, err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPrograms(t *testing.T) {
|
||||||
|
for _, test := range programs {
|
||||||
t.Run(test.Name, func(t *testing.T) {
|
t.Run(test.Name, func(t *testing.T) {
|
||||||
run(t, filepath.Join("programs", test.Name), test.ExpectedOutput, test.ExpectedExitCode)
|
run(t, filepath.Join("programs", test.Name), test.ExpectedOutput, test.ExpectedExitCode)
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user