mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
v3 parser: add some more test cases (functions) (#2422)
* [v3] add test case for parser (create struct from func) * [v3] add another test case for parser (func in other pkg) + misc
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
"github.com/wailsapp/wails/v3/internal/parser/testdata/variable_single_from_other_function/services"
|
||||
"log"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
)
|
||||
|
||||
// GreetService is great
|
||||
type GreetService struct {
|
||||
SomeVariable int
|
||||
lowerCase string
|
||||
target *Person
|
||||
}
|
||||
|
||||
type Person struct {
|
||||
Name string
|
||||
Address *services.Address
|
||||
}
|
||||
|
||||
// Greet does XYZ
|
||||
func (*GreetService) Greet(name string) string {
|
||||
return "Hello " + name
|
||||
}
|
||||
|
||||
// NewPerson creates a new person
|
||||
func (*GreetService) NewPerson(name string) *Person {
|
||||
return &Person{Name: name}
|
||||
}
|
||||
|
||||
func main() {
|
||||
otherService := services.NewOtherService()
|
||||
app := application.New(application.Options{
|
||||
Bind: []interface{}{
|
||||
&GreetService{},
|
||||
otherService,
|
||||
},
|
||||
})
|
||||
|
||||
app.NewWebviewWindow()
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package services
|
||||
|
||||
// OtherService is a struct
|
||||
// that does things
|
||||
type OtherService struct {
|
||||
t int
|
||||
}
|
||||
|
||||
type Address struct {
|
||||
Street string
|
||||
State string
|
||||
Country string
|
||||
}
|
||||
|
||||
// Yay does this and that
|
||||
func (o *OtherService) Yay() *Address {
|
||||
return &Address{
|
||||
Street: "123 Pitt Street",
|
||||
State: "New South Wales",
|
||||
Country: "Australia",
|
||||
}
|
||||
}
|
||||
|
||||
func NewOtherService() *OtherService {
|
||||
return &OtherService{}
|
||||
}
|
||||
Reference in New Issue
Block a user