test(demo): restructure issue #1370 regression tests to match maphash style
- Remove temporary .tmp-comment/ and .tmp-images/ directories - Remove llgo binary from repository - Refactor _demo/go/issue1370_case1 to include multiple test functions with proper validation - Refactor _demo/go/issue1370_case2 to include multiple test functions with proper validation - Tests now panic on failure with descriptive error messages - Follow the same test structure as _demo/go/maphash 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,18 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/types"
|
||||
)
|
||||
|
||||
func main() {
|
||||
testScopeInsertLookup()
|
||||
testScopeLookupNonExistent()
|
||||
testScopeMultipleObjects()
|
||||
}
|
||||
|
||||
func testScopeInsertLookup() {
|
||||
fmt.Println("=== Test Scope Insert and Lookup ===")
|
||||
scope := types.NewScope(nil, 0, 0, "test")
|
||||
obj := types.NewVar(0, nil, "x", types.Typ[types.Int])
|
||||
|
||||
scope.Insert(obj)
|
||||
|
||||
if scope.Lookup("x") == obj {
|
||||
println("SUCCESS: Scope.Insert and Lookup work correctly")
|
||||
} else {
|
||||
println("FAIL: Lookup returned wrong object")
|
||||
result := scope.Lookup("x")
|
||||
if result != obj {
|
||||
panic(fmt.Sprintf("Lookup returned wrong object: expected %v, got %v", obj, result))
|
||||
}
|
||||
fmt.Println("SUCCESS: Scope.Insert and Lookup work correctly")
|
||||
}
|
||||
|
||||
func testScopeLookupNonExistent() {
|
||||
fmt.Println("\n=== Test Scope Lookup Non-Existent ===")
|
||||
scope := types.NewScope(nil, 0, 0, "test")
|
||||
|
||||
result := scope.Lookup("nonexistent")
|
||||
if result != nil {
|
||||
panic(fmt.Sprintf("Lookup should return nil for non-existent name, got %v", result))
|
||||
}
|
||||
fmt.Println("SUCCESS: Lookup returns nil for non-existent name")
|
||||
}
|
||||
|
||||
func testScopeMultipleObjects() {
|
||||
fmt.Println("\n=== Test Scope Multiple Objects ===")
|
||||
scope := types.NewScope(nil, 0, 0, "test")
|
||||
obj1 := types.NewVar(0, nil, "x", types.Typ[types.Int])
|
||||
obj2 := types.NewVar(0, nil, "y", types.Typ[types.String])
|
||||
|
||||
scope.Insert(obj1)
|
||||
scope.Insert(obj2)
|
||||
|
||||
result1 := scope.Lookup("x")
|
||||
if result1 != obj1 {
|
||||
panic(fmt.Sprintf("Lookup('x') returned wrong object: expected %v, got %v", obj1, result1))
|
||||
}
|
||||
|
||||
result2 := scope.Lookup("y")
|
||||
if result2 != obj2 {
|
||||
panic(fmt.Sprintf("Lookup('y') returned wrong object: expected %v, got %v", obj2, result2))
|
||||
}
|
||||
fmt.Println("SUCCESS: Multiple objects handled correctly")
|
||||
}
|
||||
|
||||
@@ -7,14 +7,57 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
testIdentToExpr()
|
||||
testExprPos()
|
||||
testExprEnd()
|
||||
}
|
||||
|
||||
func testIdentToExpr() {
|
||||
fmt.Println("=== Test Ident to Expr Conversion ===")
|
||||
ident := &ast.Ident{
|
||||
NamePos: token.Pos(1),
|
||||
Name: "foo",
|
||||
}
|
||||
|
||||
|
||||
var expr ast.Expr = ident
|
||||
if expr == nil {
|
||||
panic("Interface conversion failed: expr is nil")
|
||||
}
|
||||
fmt.Printf("Identifier: %s\n", ident.Name)
|
||||
fmt.Printf("Position: %d\n", expr.Pos())
|
||||
|
||||
println("SUCCESS: ast.Expr interface conversion works correctly")
|
||||
fmt.Println("SUCCESS: ast.Expr interface conversion works correctly")
|
||||
}
|
||||
|
||||
func testExprPos() {
|
||||
fmt.Println("\n=== Test Expr.Pos() Method ===")
|
||||
expectedPos := token.Pos(42)
|
||||
ident := &ast.Ident{
|
||||
NamePos: expectedPos,
|
||||
Name: "bar",
|
||||
}
|
||||
|
||||
var expr ast.Expr = ident
|
||||
actualPos := expr.Pos()
|
||||
if actualPos != expectedPos {
|
||||
panic(fmt.Sprintf("Pos() returned wrong position: expected %d, got %d", expectedPos, actualPos))
|
||||
}
|
||||
fmt.Printf("Position: %d\n", actualPos)
|
||||
fmt.Println("SUCCESS: Expr.Pos() returns correct position")
|
||||
}
|
||||
|
||||
func testExprEnd() {
|
||||
fmt.Println("\n=== Test Expr.End() Method ===")
|
||||
name := "testvar"
|
||||
ident := &ast.Ident{
|
||||
NamePos: token.Pos(10),
|
||||
Name: name,
|
||||
}
|
||||
|
||||
var expr ast.Expr = ident
|
||||
expectedEnd := token.Pos(10 + len(name))
|
||||
actualEnd := expr.End()
|
||||
if actualEnd != expectedEnd {
|
||||
panic(fmt.Sprintf("End() returned wrong position: expected %d, got %d", expectedEnd, actualEnd))
|
||||
}
|
||||
fmt.Printf("End position: %d\n", actualEnd)
|
||||
fmt.Println("SUCCESS: Expr.End() returns correct position")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user