test:refression test for https://github.com/goplus/llgo/issues/1370
Co-authored-by: xgopilot <noreply@goplus.org> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
25
cl/_testdata/geometry1370/geometry.go
Normal file
25
cl/_testdata/geometry1370/geometry.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package geometry1370
|
||||
|
||||
type Shape interface {
|
||||
Area() float64
|
||||
validate() bool
|
||||
setID(int)
|
||||
}
|
||||
|
||||
type Rectangle struct {
|
||||
Width, Height float64
|
||||
id int
|
||||
}
|
||||
|
||||
func (r *Rectangle) Area() float64 { return r.Width * r.Height }
|
||||
func (r *Rectangle) validate() bool { return r.Width > 0 && r.Height > 0 }
|
||||
func (r *Rectangle) setID(id int) { r.id = id }
|
||||
func (r *Rectangle) GetID() int { return r.id }
|
||||
|
||||
func NewRectangle(width, height float64) *Rectangle {
|
||||
return &Rectangle{Width: width, Height: height}
|
||||
}
|
||||
|
||||
func RegisterShape(s Shape, id int) {
|
||||
s.setID(id)
|
||||
}
|
||||
Reference in New Issue
Block a user