refactor: move issue #1370 regression tests from _cmptest to _demo
Move the three regression test cases for issue #1370 from _cmptest/ to _demo/: - issue1370_gotypes (go/types.Object test) - issue1370_goast (go/ast.Expr test) - issue1370_geometry (custom interface test) Updated import path in geometry.go to reflect new location. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
This commit is contained in:
32
_demo/issue1370_geometry/geometry.go
Normal file
32
_demo/issue1370_geometry/geometry.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/goplus/llgo/_demo/issue1370_geometry/geometry"
|
||||
)
|
||||
|
||||
func main() {
|
||||
rect := geometry.NewRectangle(5.0, 3.0)
|
||||
|
||||
err := geometry.RegisterShape(rect, 42)
|
||||
if err != nil {
|
||||
println("FAIL: RegisterShape returned error")
|
||||
return
|
||||
}
|
||||
|
||||
if rect.GetID() != 42 {
|
||||
println("FAIL: ID not set correctly")
|
||||
return
|
||||
}
|
||||
|
||||
area := rect.Area()
|
||||
fmt.Printf("Area: %.1f\n", area)
|
||||
|
||||
if area != 15.0 {
|
||||
println("FAIL: Area calculation incorrect")
|
||||
return
|
||||
}
|
||||
|
||||
println("SUCCESS: Custom interface with private methods works correctly")
|
||||
}
|
||||
Reference in New Issue
Block a user