Skip to content

Commit

Permalink
TestGopxNoFunc
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Jan 30, 2024
1 parent 1e4077b commit bd1a2d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cl/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,10 @@ func preloadGopFile(p *gox.Package, ctx *blockCtx, file string, f *ast.File, con
}
parent.tylds = append(parent.tylds, ld)
}

// bugfix: see TestGopxNoFunc
parent.inits = append(parent.inits, ld.load)

ctx.classRecv = &ast.FieldList{List: []*ast.Field{{
Names: []*ast.Ident{
{Name: "this"},
Expand Down
23 changes: 23 additions & 0 deletions cl/compile_spx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,11 @@ func (this *index) onInit() {
this.bar()
fmt.Println("Hi")
}
type bar struct {
spx.Sprite
*index
}
`)
}

Expand Down Expand Up @@ -537,6 +542,11 @@ func (this *Game) MainEntry() {
func main() {
new(Game).Main()
}
type Kai struct {
spx2.Sprite
*Game
}
`, "Game.t2gmx", "Kai.t2spx", "")
gopSpxTestExConf(t, "OnlyGmx", &conf, `
var (
Expand Down Expand Up @@ -1016,6 +1026,19 @@ func Test_foo(t *testing.T) {
`, "main.gox", "foo_xtest.gox", "_test")
}

func TestGopxNoFunc(t *testing.T) {
gopClTestFile(t, `
var (
a int
)
`, `package main
type foo struct {
a int
}
`, "foo.gox")
}

func TestClassFileGopx(t *testing.T) {
gopClTestFile(t, `
var (
Expand Down

0 comments on commit bd1a2d1

Please sign in to comment.