Skip to content

Commit 5baee33

Browse files
committed
Compile every example file in tests
1 parent 66bb729 commit 5baee33

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

examples/blocks/yield_patterns.vibe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ end
2222

2323
def benchmark
2424
start = Time.now
25-
result = yield
25+
result = yield()
2626
elapsed = Time.now - start
2727
{ result: result, elapsed: elapsed }
2828
end

vibes/examples_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package vibes
33
import (
44
"context"
55
"maps"
6+
"os"
67
"path/filepath"
78
"testing"
89
)
@@ -2108,6 +2109,34 @@ func TestExamples(t *testing.T) {
21082109
}
21092110
}
21102111

2112+
func TestAllExampleFilesCompile(t *testing.T) {
2113+
examplesDir := filepath.Join("..", "examples")
2114+
var files []string
2115+
err := filepath.Walk(examplesDir, func(path string, info os.FileInfo, err error) error {
2116+
if err != nil {
2117+
return err
2118+
}
2119+
if !info.IsDir() && filepath.Ext(path) == ".vibe" {
2120+
files = append(files, path)
2121+
}
2122+
return nil
2123+
})
2124+
if err != nil {
2125+
t.Fatalf("walk examples dir: %v", err)
2126+
}
2127+
if len(files) == 0 {
2128+
t.Fatal("no .vibe files found in examples/")
2129+
}
2130+
2131+
engine := MustNewEngine(Config{})
2132+
for _, path := range files {
2133+
rel, _ := filepath.Rel(examplesDir, path)
2134+
t.Run(rel, func(t *testing.T) {
2135+
_ = compileScriptFromFileWithEngine(t, engine, path)
2136+
})
2137+
}
2138+
}
2139+
21112140
func compileExample(t *testing.T, rel string) *Script {
21122141
return compileExampleWithConfig(t, rel, Config{})
21132142
}

0 commit comments

Comments
 (0)