blacklist certain tests
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -87,4 +87,5 @@ fabric.properties
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
/dist
|
/dist
|
||||||
|
/.vscode
|
||||||
/monkey-lang
|
/monkey-lang
|
||||||
@@ -8,10 +8,16 @@ import (
|
|||||||
"monkey/parser"
|
"monkey/parser"
|
||||||
"monkey/utils"
|
"monkey/utils"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var BlacklistedExamples = map[string]bool{
|
||||||
|
"echoserver": true,
|
||||||
|
}
|
||||||
|
|
||||||
func assertEvaluated(t *testing.T, expected interface{}, actual object.Object) {
|
func assertEvaluated(t *testing.T, expected interface{}, actual object.Object) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
@@ -884,17 +890,26 @@ func TestImportSearchPaths(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestExamples(t *testing.T) {
|
func TestExamples(t *testing.T) {
|
||||||
matches, err := filepath.Glob("../examples/*.monkey")
|
matches, err := filepath.Glob("./examples/*.monkey")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
|
basename := path.Base(match)
|
||||||
|
name := strings.TrimSuffix(basename, filepath.Ext(basename))
|
||||||
|
|
||||||
|
if BlacklistedExamples[name] {
|
||||||
|
t.Skipf("not testing blacklisted example %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
b, err := os.ReadFile(match)
|
b, err := os.ReadFile(match)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
testEval(string(b))
|
testEval(string(b))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var BlacklistedExamples = map[string]bool{
|
||||||
|
"echoserver": true,
|
||||||
|
}
|
||||||
|
|
||||||
type vmTestCase struct {
|
type vmTestCase struct {
|
||||||
input string
|
input string
|
||||||
expected interface{}
|
expected interface{}
|
||||||
@@ -1051,6 +1055,55 @@ func TestIntegration(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestExamples(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.Skip("skipping test in short mode.")
|
||||||
|
}
|
||||||
|
|
||||||
|
matches, err := filepath.Glob("../examples/*.monkey")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, match := range matches {
|
||||||
|
basename := path.Base(match)
|
||||||
|
name := strings.TrimSuffix(basename, filepath.Ext(basename))
|
||||||
|
|
||||||
|
if BlacklistedExamples[name] {
|
||||||
|
t.Skipf("not testing blacklisted example %s", name)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Run(name, func(t *testing.T) {
|
||||||
|
b, err := os.ReadFile(match)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
input := string(b)
|
||||||
|
program := parse(input)
|
||||||
|
|
||||||
|
c := compiler.New()
|
||||||
|
err = c.Compile(program)
|
||||||
|
if err != nil {
|
||||||
|
t.Log(input)
|
||||||
|
t.Fatalf("compiler error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
vm := New(c.Bytecode())
|
||||||
|
|
||||||
|
err = vm.Run()
|
||||||
|
if err != nil {
|
||||||
|
t.Log(input)
|
||||||
|
t.Fatalf("vm error: %s", err)
|
||||||
|
}
|
||||||
|
if vm.sp != 0 {
|
||||||
|
t.Log(input)
|
||||||
|
t.Fatal("vm stack pointer non-zero")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkFibonacci(b *testing.B) {
|
func BenchmarkFibonacci(b *testing.B) {
|
||||||
tests := map[string]string{
|
tests := map[string]string{
|
||||||
"iterative": `
|
"iterative": `
|
||||||
|
|||||||
Reference in New Issue
Block a user