module support
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user