Commit Graph

22 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
e46d22976a fix(demo): remove unused go/ast import from gotypes demo
Removed the unused "go/ast" import from _demo/go/gotypes/main.go
that was causing compilation errors. The demo now compiles and runs
successfully with both standard go and llgo.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-28 03:32:59 +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
xgopilot
902ac3b35a 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>
2025-10-27 13:41:40 +00:00
xgopilot
b62dafbc3a fix(ssa): use abi.PathOf() for correct package path in interface metadata
Fixes os.ReadDir segfault caused by package path mismatch between llgo
overlay packages and canonical standard library paths.

The issue occurred in: os.ReadDir → sort.Slice → reflectlite.Swapper
where internal/reflectlite.Type interface has private methods common()
and uncommon(). Using mPkg.Path() returned the overlay path
'github.com/goplus/llgo/runtime/internal/lib/internal/reflectlite'
instead of the canonical 'internal/reflectlite', causing runtime to
only fill public methods and leave private method pointers NULL.

Changed to use abi.PathOf() which returns the correct canonical package
path for matching, ensuring all interface methods (both public and
private) are properly filled in the interface table.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 11:32:38 +00:00
xgopilot
89e483b8ec test(demo): add regression demos for issue #1370 cases
- case1: go/types.Object with Scope.Insert() calling private setParent()
- case2: go/ast.Expr interface conversion with private exprNode()

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-27 10:34:53 +00:00
xgopilot
670f880c78 refactor(test): move issue #1370 geometry test to cl/_testgo/interface1370
- Move geometry package from _demo to cl/_testdata/geometry1370
- Create simplified test in cl/_testgo/interface1370 following interface test pattern
- Generate .ll file with llgen to verify interface metadata package path fix
- Remove old demo files (issue1370_geometry, issue1370_goast, issue1370_gotypes)
- Remove .tmp-comment files

The new test structure is simpler and follows the existing cl/_testgo/interface pattern,
focusing on demonstrating the interface metadata fix for private methods across packages.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
2025-10-27 08:03:58 +00:00
xgopilot
0ee2530c2e refactor: move issue #1370 regression tests to _demo/go
Move the three regression test cases from _demo/ to _demo/go/:
- 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>
2025-10-27 07:25:20 +00:00
xgopilot
dcf0898f3b test(cl): regenerate test .ll files and remove go/types test
- Regenerated all test case .ll files using llgen to reflect the
  interface metadata package path fix
- Updated debug/out.ll which was previously a placeholder
- Removed cl/_testdata/gotypesissue test case as requested
- Removed _demo/go/gotypesissue demo as requested
- All cl tests pass

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-23 12:34:59 +00:00
xgopilot
816854c9cc test(demo): add go/types Scope.Insert demo
Add a demo program to demonstrate the fix for cross-package interface
private method calls. This demo uses go/types.Scope.Insert which has
private methods in the go/types package, making it a good test case
for the bug fix in PR #1371.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-23 10:44:56 +00:00
xgopilot
2b92b527e1 fix: resolve compilation errors in maphash demo
- Fix line 67: Change unused variable 'n' to blank identifier '_'
- Fix line 102: Correct WriteByte call to expect only error return value
  (WriteByte returns only error, not (int, error))

These fixes resolve the compilation errors reported by the CI.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-14 10:33:30 +00:00
xgopilot
ed3176a6cc test: expand maphash demo with comprehensive API coverage
- Add tests for all major hash/maphash public APIs:
  * Hash basics (WriteString, Sum64, Reset)
  * MakeSeed and SetSeed functionality
  * Write methods (Write, WriteByte, WriteString)
  * Bytes and String convenience functions
- Use panic() for unexpected errors instead of silent failures
- Add proper error checking and validation
- Document Comparable/WriteComparable limitations in overlay

Note: Comparable() and WriteComparable() are not yet supported and will
panic with 'intrinsic' error as they require runtime intrinsic support.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
2025-10-14 10:18:28 +00:00
xgopilot
8aadfde64a style: apply linter fixes to maphash test
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-14 07:11:42 +00:00
xgopilot
441b4b15a8 test: add hash/maphash demo test case
Add test case in _demo/go/maphash to verify hash/maphash functionality
with the new runtime.rand and runtime.memhash support.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>
Co-authored-by: xgopilot <noreply@goplus.org>
2025-10-14 07:11:17 +00:00
visualfc
ccaf59ec62 runtime/internal/lib/reflect: fix Field closure kind to func 2025-09-26 10:27:56 +08:00
Haolan
e4f77f00a6 ci: fix clite init() causing linting failure 2025-09-14 23:06:09 +08:00
xushiwei
a202b484a9 Merge pull request #1285 from cpunion/impl-build-mode
Implement llgo build mode support
2025-09-14 10:30:47 +08:00
Li Jie
cc65ee18b5 full test params passing of exported functions 2025-09-12 10:08:01 +08:00
Li Jie
c3b674d804 add export demo and test 2025-09-11 14:08:52 +08:00
Li Jie
64df39b3c5 reorganize: consolidate demo directories
- Consolidate _demo, _pydemo, _embdemo into single _demo directory structure
- Organize demos by language: _demo/{go,py,c,embed}/
- Categorize demos based on imports:
- Python library demos (py imports) → _demo/py/
- C/C++ library demos (c/cpp imports) → _demo/c/
- Go-specific demos → _demo/go/
- Embedded demos → _demo/embed/
- Move C-related demos (asm*, cabi*, cgo*, linkname, targetsbuild) from go/ to c/
- Update all path references in README.md and GitHub workflows
- Improve demo organization and navigation as requested in #1256

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-09 15:06:55 +08:00