refactor how repl works
This commit is contained in:
@@ -49,7 +49,7 @@ func runVmTests(t *testing.T, tests []vmTestCase) {
|
||||
// fmt.Printf("\n")
|
||||
//}
|
||||
|
||||
vm := New(comp.Bytecode())
|
||||
vm := New("<test>", comp.Bytecode())
|
||||
err = vm.Run()
|
||||
if err != nil {
|
||||
t.Fatalf("vm error: %s", err)
|
||||
@@ -148,7 +148,7 @@ func testExpectedObject(t *testing.T, expected interface{}, actual object.Object
|
||||
|
||||
func parse(input string) *ast.Program {
|
||||
l := lexer.New(input)
|
||||
p := parser.New(l)
|
||||
p := parser.New("<test>", l)
|
||||
return p.ParseProgram()
|
||||
}
|
||||
|
||||
@@ -694,7 +694,7 @@ func TestCallingFunctionsWithWrongArguments(t *testing.T) {
|
||||
t.Fatalf("compiler error: %s", err)
|
||||
}
|
||||
|
||||
vm := New(comp.Bytecode())
|
||||
vm := New("<test>", comp.Bytecode())
|
||||
err = vm.Run()
|
||||
if err == nil {
|
||||
t.Fatalf("expected VM error but resulted in none.")
|
||||
@@ -1040,7 +1040,7 @@ func TestIntegration(t *testing.T) {
|
||||
t.Fatalf("compiler error: %s", err)
|
||||
}
|
||||
|
||||
vm := New(c.Bytecode())
|
||||
vm := New("<test>", c.Bytecode())
|
||||
|
||||
err = vm.Run()
|
||||
if err != nil {
|
||||
@@ -1089,7 +1089,7 @@ func TestExamples(t *testing.T) {
|
||||
t.Fatalf("compiler error: %s", err)
|
||||
}
|
||||
|
||||
vm := New(c.Bytecode())
|
||||
vm := New("<test>", c.Bytecode())
|
||||
|
||||
err = vm.Run()
|
||||
if err != nil {
|
||||
@@ -1166,7 +1166,7 @@ func BenchmarkFibonacci(b *testing.B) {
|
||||
b.Fatalf("compiler error: %s", err)
|
||||
}
|
||||
|
||||
vm := New(c.Bytecode())
|
||||
vm := New("<test>", c.Bytecode())
|
||||
|
||||
err = vm.Run()
|
||||
if err != nil {
|
||||
@@ -1185,15 +1185,15 @@ func BenchmarkFibonacci(b *testing.B) {
|
||||
func TestImportExpressions(t *testing.T) {
|
||||
tests := []vmTestCase{
|
||||
{
|
||||
input: `mod := import("../../testdata/mod"); mod.A`,
|
||||
input: `mod := import("../testdata/mod"); mod.A`,
|
||||
expected: 5,
|
||||
},
|
||||
{
|
||||
input: `mod := import("../../testdata/mod"); mod.Sum(2, 3)`,
|
||||
input: `mod := import("../testdata/mod"); mod.Sum(2, 3)`,
|
||||
expected: 5,
|
||||
},
|
||||
{
|
||||
input: `mod := import("../../testdata/mod"); mod.a`,
|
||||
input: `mod := import("../testdata/mod"); mod.a`,
|
||||
expected: nil,
|
||||
},
|
||||
}
|
||||
@@ -1202,11 +1202,11 @@ func TestImportExpressions(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestImportSearchPaths(t *testing.T) {
|
||||
utils.AddPath("../../testdata")
|
||||
utils.AddPath("../testdata")
|
||||
|
||||
tests := []vmTestCase{
|
||||
{
|
||||
input: `mod := import("../../testdata/mod"); mod.A`,
|
||||
input: `mod := import("../testdata/mod"); mod.A`,
|
||||
expected: 5,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user