module support
Some checks failed
Build / build (push) Successful in 10m22s
Test / build (push) Failing after 15m54s

This commit is contained in:
Chuck Smith
2024-03-26 16:49:38 -04:00
parent 6d234099d1
commit 110152a139
21 changed files with 541 additions and 100 deletions

View File

@@ -7,6 +7,7 @@ import (
"monkey/lexer"
"monkey/object"
"monkey/parser"
"monkey/utils"
"os"
"path"
"path/filepath"
@@ -1127,3 +1128,35 @@ func BenchmarkFibonacci(b *testing.B) {
})
}
}
func TestImportExpressions(t *testing.T) {
tests := []vmTestCase{
{
input: `mod := import("../testdata/mod"); mod.A`,
expected: 5,
},
{
input: `mod := import("../testdata/mod"); mod.Sum(2, 3)`,
expected: 5,
},
{
input: `mod := import("../testdata/mod"); mod.a`,
expected: nil,
},
}
runVmTests(t, tests)
}
func TestImportSearchPaths(t *testing.T) {
utils.AddPath("../testdata")
tests := []vmTestCase{
{
input: `mod := import("../testdata/mod"); mod.A`,
expected: 5,
},
}
runVmTests(t, tests)
}