Implemented constant folding

This commit is contained in:
2024-07-29 14:44:16 +02:00
parent 8d4eb9935d
commit 5b1d456720
8 changed files with 118 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import (
"testing"
"git.akyoto.dev/cli/q/src/build"
"git.akyoto.dev/cli/q/src/build/config"
"git.akyoto.dev/go/assert"
)
@ -52,11 +53,21 @@ var programs = []struct {
}
func TestPrograms(t *testing.T) {
config.ConstantFold = false
for _, test := range programs {
t.Run(test.Name, func(t *testing.T) {
run(t, filepath.Join("programs", test.Name+".q"), test.Input, test.Output, test.ExitCode)
})
}
config.ConstantFold = true
for _, test := range programs {
t.Run(test.Name+" (optimized)", func(t *testing.T) {
run(t, filepath.Join("programs", test.Name+".q"), test.Input, test.Output, test.ExitCode)
})
}
}
func BenchmarkPrograms(b *testing.B) {