Skip to content

Commit

Permalink
Test issue pkujhd#96
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonymous committed Apr 9, 2024
1 parent 90ff3cf commit d53913e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
23 changes: 23 additions & 0 deletions jit/jit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,29 @@ func TestTypeMismatch(t *testing.T) {

}

func TestIssue96(t *testing.T) {
conf := baseConfig

data := testData{
files: []string{"./testdata/test_issue96/test.go"},
pkg: "./testdata/test_issue96",
}
testNames := []string{"BuildGoFiles", "BuildGoPackage", "BuildGoText"}
for _, testName := range testNames {
t.Run(testName, func(t *testing.T) {
module, symbols := buildLoadable(t, conf, testName, data)

testFunc := symbols["NewStructX"]
results := reflect.ValueOf(testFunc).Call(nil)
fmt.Println(results[0].Interface().(interface{ Do() error }).Do())
err := module.Unload()
if err != nil {
t.Fatal(err)
}
})
}
}

func TestRemotePkgs(t *testing.T) {
// This test tries to build some massive real world packages as a smoke test.
// Ideally in future we'd also build and run the tests for those packages as JIT modules to prove everything works
Expand Down
19 changes: 19 additions & 0 deletions jit/testdata/test_issue96/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package test_issue96

import "fmt"

type (
IDo interface {
Do() error
}
Struct1 struct{}
)

func (Struct1) Do() error {
fmt.Print("DO SOMETHING\n")
return nil
}

func NewStructX() IDo {
return Struct1{}
}

0 comments on commit d53913e

Please sign in to comment.