Files
moxa/_test/phase_1_1_complete_test.go
mleku b974bb23ea
Some checks failed
Build Cross OS / Go (/go, oldstable, macos-latest) (push) Has been cancelled
Build Cross OS / Go (/go, oldstable, ubuntu-latest) (push) Has been cancelled
Build Cross OS / Go (/go, stable, macos-latest) (push) Has been cancelled
Build Cross OS / Go (/go, stable, ubuntu-latest) (push) Has been cancelled
Build Cross OS / Go (\go, oldstable, windows-latest) (push) Has been cancelled
Build Cross OS / Go (\go, stable, windows-latest) (push) Has been cancelled
Main / Linting (push) Has been cancelled
Main / Checks code and generated code (oldstable) (push) Has been cancelled
Main / Checks code and generated code (stable) (push) Has been cancelled
Main / Build and Test (oldstable) (push) Has been cancelled
Main / Build and Test (stable) (push) Has been cancelled
implement 1.1 explicit collection type pointers
2025-11-22 09:58:03 +00:00

68 lines
2.1 KiB
Go

package main
import "fmt"
func main() {
fmt.Println("=== Phase 1.1: Explicit Pointer Types - Complete Test ===\n")
// Test 1: Slice creation and pointer wrapping
fmt.Println("=== Slice Tests ===")
s := &[]int{10, 20, 30, 40, 50}
fmt.Println("Created s := &[]int{10, 20, 30, 40, 50}")
fmt.Println("Type: *[]int")
// Test 2: Slice auto-dereference indexing
fmt.Println("\nAuto-dereference indexing:")
fmt.Println(" s[0] =", s[0])
fmt.Println(" s[1] =", s[1])
fmt.Println(" s[4] =", s[4])
// Test 3: Manual dereferencing
fmt.Println("\nManual dereference:")
deref := *s
fmt.Println(" deref := *s")
fmt.Println(" deref[0] =", deref[0])
fmt.Println(" (*s)[2] =", (*s)[2])
// Test 4: Built-in functions with auto-dereference
fmt.Println("\nBuilt-in functions (auto-dereference):")
fmt.Println(" len(s) =", len(s))
fmt.Println(" cap(s) =", cap(s))
fmt.Println(" len(*s) =", len(*s))
fmt.Println(" cap(*s) =", cap(*s))
// Test 5: Map creation and pointer wrapping
fmt.Println("\n=== Map Tests ===")
m := &map[string]int{"x": 100, "y": 200, "z": 300}
fmt.Println("Created m := &map[string]int{\"x\": 100, \"y\": 200, \"z\": 300}")
fmt.Println("Type: *map[string]int")
// Test 6: Map auto-dereference indexing
fmt.Println("\nAuto-dereference indexing:")
fmt.Println(" m[\"x\"] =", m["x"])
fmt.Println(" m[\"y\"] =", m["y"])
fmt.Println(" m[\"z\"] =", m["z"])
// Test 7: Manual map dereferencing
fmt.Println("\nManual dereference:")
fmt.Println(" (*m)[\"x\"] =", (*m)["x"])
mDeref := *m
fmt.Println(" mDeref := *m")
fmt.Println(" mDeref[\"y\"] =", mDeref["y"])
// Test 8: Map built-in functions
fmt.Println("\nBuilt-in functions:")
fmt.Println(" len(m) =", len(m))
fmt.Println(" len(*m) =", len(*m))
// Summary
fmt.Println("\n=== Summary ===")
fmt.Println("✅ Pointer-wrapped slices: &[]T")
fmt.Println("✅ Pointer-wrapped maps: &map[K]V")
fmt.Println("✅ Auto-dereference slice indexing: s[i]")
fmt.Println("✅ Auto-dereference map indexing: m[k]")
fmt.Println("✅ Auto-dereference len() and cap()")
fmt.Println("✅ Manual dereferencing: *s, *m")
fmt.Println("\n🎉 Phase 1.1 Implementation Complete!")
}