Commit Graph

4 Commits

Author SHA1 Message Date
xgopilot
ebd041082b feat(demo): add result verification to go/token and go/types demos
Added comprehensive result verification and assertions to ensure correctness:

go/token demo:
- Verify Pos values and IsValid() results
- Check token string representations
- Validate keyword detection (IsKeyword())
- Assert operator precedence relationships
- Verify file and position operations

go/types demo:
- Validate basic type kinds
- Check object names and types (Var, Const, Func, TypeName)
- Verify package path and name
- Assert interface method counts and names
- Check struct field counts, names, and types
- Validate signature params and results
- Verify tuple, array, slice, pointer, map, and chan properties

All demos now fail fast with panic() if results don't match expected values,
providing better test coverage than just printing output.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-28 06:56:14 +00:00
xgopilot
75e77caf29 feat(demo): add comprehensive public API tests to gotypes and gotoken
Expanded demo tests to cover more public methods and functions from go/types and go/token packages, as discovered via `go doc`.

**go/types additions:**
- Type comparison functions: Identical, AssignableTo, Comparable, ConvertibleTo
- Interface checking: Implements, AssertableTo
- String formatting: TypeString, ObjectString with qualifiers
- Lookup utilities: LookupFieldOrMethod, NewMethodSet
- Type utilities: IsInterface, Default, Id

**go/token additions:**
- Utility functions: IsExported, IsIdentifier, IsKeyword, Lookup

These additions provide better coverage of the packages' public APIs and demonstrate proper usage patterns for interface conversions and method calls.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-28 06:27:36 +00:00
xgopilot
0256ce2232 style(demo): align gotypes and gotoken demos with standard demo pattern
- Removed header/footer print statements from main()
- Added '\n' prefix to section headers (except first) for consistent spacing
- Follows the pattern established in maphash and other demo files

This makes the output cleaner and consistent with other demo files in the project.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-28 04:02:36 +00:00
xgopilot
6507e3410c refactor(demo): rename and expand go/types and go/token test demos
- Renamed _demo/go/issue1370_case1 to _demo/go/gotypes
- Renamed _demo/go/issue1370_case2 to _demo/go/gotoken
- Expanded gotypes demo to test comprehensive go/types APIs:
  - Basic types (Int, String, Bool, Float64)
  - Objects (Var, Const, Func, TypeName)
  - Scope operations (Insert, Lookup, Names, Len)
  - Package operations
  - Named types
  - Interface types with methods
  - Struct types with fields
  - Signature types with params and results
  - Tuple operations
  - Composite types (Array, Slice, Pointer, Map, Chan)
- Expanded gotoken demo to test comprehensive go/token APIs:
  - Pos operations and validation
  - Token types (operators, literals, keywords)
  - Token methods (String, IsKeyword, Precedence)
  - FileSet operations (AddFile, File, Position)
  - File operations (AddLine, Pos, Offset, Line, LineStart)
  - Position struct and methods

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-28 02:40:15 +00:00