compiler/test: use public functions in tests

`CompileWithOptions` does exactly the thing we need.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgeniy Stratonikov 2021-07-26 14:36:31 +03:00
parent 42769d11ff
commit 46f623a48f

View file

@ -67,17 +67,8 @@ func (ms *MyStruct) MethodOnPointerToStruct() { }
func _deploy(data interface{}, isUpdate bool) { x := 1; _ = x } func _deploy(data interface{}, isUpdate bool) { x := 1; _ = x }
` `
info, err := getBuildInfo("foo.go", src) buf, d, err := CompileWithOptions("foo.go", strings.NewReader(src), nil)
require.NoError(t, err) require.NoError(t, err)
pkg := info.program.Package(info.initialPackage)
c := newCodegen(info, pkg)
require.NoError(t, c.compile(info, pkg))
buf, err := c.writeJumps(c.prog.Bytes())
require.NoError(t, err)
d := c.emitDebugInfo(buf)
require.NotNil(t, d) require.NotNil(t, d)
t.Run("return types", func(t *testing.T) { t.Run("return types", func(t *testing.T) {
@ -308,15 +299,8 @@ func TestSequencePoints(t *testing.T) {
return false return false
}` }`
info, err := getBuildInfo("foo.go", src) _, d, err := CompileWithOptions("foo.go", strings.NewReader(src), nil)
require.NoError(t, err) require.NoError(t, err)
pkg := info.program.Package(info.initialPackage)
c := newCodegen(info, pkg)
require.NoError(t, c.compile(info, pkg))
buf := c.prog.Bytes()
d := c.emitDebugInfo(buf)
require.NotNil(t, d) require.NotNil(t, d)
require.Equal(t, d.Documents, []string{"foo.go"}) require.Equal(t, d.Documents, []string{"foo.go"})