Skip to content

Add unit tests for AssemblyBlock.parse and parseFunctionSymbols - #30

Merged
DaanV2 merged 2 commits into
mainfrom
copilot/add-unit-tests-for-parser-utilities
Apr 2, 2026
Merged

DaanV2 merged 2 commits into
mainfrom
copilot/add-unit-tests-for-parser-utilities

Conversation

Copilot AI commented Apr 2, 2026 •

Copy link
Copy Markdown
Contributor

No test coverage existed for the core parsing routines, making regressions invisible. This adds a mocha-based unit test suite covering AssemblyBlock.parse and the gopls symbol-parsing logic.

Changes

src/go/symbols.ts (new)

Extracts the gopls output parsing from getFunctions into a pure, VS Code–free function parseFunctionSymbols(stdout: string): string[]. Required to make the logic importable by mocha without a VS Code runtime.

src/go/dependencies.ts

Delegates to parseFunctionSymbols and re-exports it for backwards compatibility.

src/test/assembly-info.test.ts (new — 9 tests)

Covers AssemblyBlock.parse: header extraction, tab-stripping, line counts, #-comment skipping, empty-header/no-data filtering, blank input.

src/test/symbols.test.ts (new — 9 tests)

Covers parseFunctionSymbols: function vs. struct/field discrimination, raw + stripped method name pairs (e.g. (*RSAKey).ID → also emits RSAKey.ID), deduplication, empty input, CRLF line endings.

package.json

  • Adds mocha@^10 to devDependencies
  • Replaces "test": "echo no test yet" with "test": "npm run compile-tests && mocha out/test/**/*.test.js"
$ npm test
  AssemblyBlock.parse
    ✔ returns one block per function
    ✔ parses the header line correctly
    ...9 passing

  parseFunctionSymbols
    ✔ extracts plain function names
    ✔ includes both raw and stripped method names
    ...9 passing

  18 passing (7ms)

Copilot AI linked an issue Apr 2, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add unit tests for parser and utilities Add unit tests for AssemblyBlock.parse and parseFunctionSymbols Apr 2, 2026
Copilot AI requested a review from DaanV2 April 2, 2026 10:04
@DaanV2
DaanV2 marked this pull request as ready for review April 2, 2026 11:03
@github-actions github-actions Bot added dependencies Pull requests that update a dependency file release labels Apr 2, 2026
@DaanV2
DaanV2 merged commit 71ee228 into main Apr 2, 2026
2 checks passed
@DaanV2
DaanV2 deleted the copilot/add-unit-tests-for-parser-utilities branch April 2, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Unit Tests for Parser and Utilities

2 participants