Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amirrezaask committed Oct 19, 2019
1 parent 473c7c6 commit da6c0b5
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions interpreter/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ func Test_Integration(t *testing.T) {
},
}))

_, err = i.Eval(`:types`)
out, err := i.Eval(`:types`)
assert.NoError(t, err)
assert.Equal(t, i.typesForSource(), i.shellCmdOutput)
assert.Equal(t, i.typesForSource()+"\n", out)

_, err = i.Eval(":help")
out, err = i.Eval(":help")
assert.NoError(t, err)
assert.Equal(t, helpText, i.shellCmdOutput)
assert.Equal(t, helpText+"\n", out)

_, err = i.Eval(`:imports`)
out, err = i.Eval(`:imports`)
assert.NoError(t, err)
assert.Equal(t, i.imports.AsDump()+"\n", i.eval())
assert.Equal(t, i.imports.AsDump()+"\n", out)

_, err = i.Eval("var x int = 2")
assert.NoError(t, err)
Expand All @@ -204,7 +204,7 @@ func Test_Integration(t *testing.T) {
_, err = i.Eval("x+=2")
assert.NoError(t, err)

out := i.eval()
out = i.eval()
assert.Empty(t, out)
assert.Equal(t, []string{"x+=2"}, i.code)

Expand All @@ -215,23 +215,21 @@ func Test_Integration(t *testing.T) {
out = i.eval()
assert.Equal(t, "<int> 4\n", out)

_, err = i.Eval(":doc fmt.Println")
out, err = i.Eval(":doc fmt.Println")
assert.NoError(t, err)

doc, err := goDoc("fmt.Println")
assert.NoError(t, err)
assert.Equal(t, string(doc)+"\n", i.eval())
assert.Equal(t, string(doc)+"\n", out)

_, err = i.Eval("func Name() string{}")
assert.NoError(t, err)
assert.Equal(t, "func Name() string{}", i.funcs["Name"])

_, err = i.Eval(":funcs")
out, err = i.Eval(":funcs")
assert.NoError(t, err)
assert.Equal(t, "Name => func Name() string{}\n", i.eval())
assert.Equal(t, "Name => func Name() string{}\n", out)

_, err = i.Eval(":dump")
out, err = i.Eval(":dump")
assert.NoError(t, err)
exp := i.shellCmdOutput
assert.Equal(t, exp+"\n", i.eval())
}

0 comments on commit da6c0b5

Please sign in to comment.