Skip to content

test: fix fragile/vacuous assertions (#75)#149

Merged
thiagoralves merged 1 commit into
developmentfrom
fix/75-fragile-test-assertions
Jun 1, 2026
Merged

test: fix fragile/vacuous assertions (#75)#149
thiagoralves merged 1 commit into
developmentfrom
fix/75-fragile-test-assertions

Conversation

@thiagoralves
Copy link
Copy Markdown
Contributor

@thiagoralves thiagoralves commented Jun 1, 2026

Closes #75.

Summary

Addresses #75. Of its three sub-items, two are still valid and fixed here; one was already resolved.

1. oscat-gpp-compile.test.ts — vacuous pass (fixed)

The "compiles and runs full OSCAT" test silently returned when no transpiled output existed, so it could pass without testing anything. The suite is already gated by describe.skipIf(!hasGpp || !oscatStlibAvailable), so a missing artifact means the preceding transpile test failed — a real failure. Replaced the silent return with expect.fail(...), and removed a dead return after an existing expect.fail.

2. located-variables.test.ts — fragile string-contains (fixed)

should error on located variable in function block asserted message.includes('FUNCTION_BLOCK') — a generic token that any unrelated FB error would satisfy (vacuous match). Anchored it to the distinctive rule text "Located variables can only be declared …" so the test fails if a different error fires or the located-var check regresses.

Note: the issue suggested "assert on error code/type instead", but CompileError.code is not populated anywhere in src/semantic/ — introducing an error-code taxonomy across the analyzer is a much larger, separate change. Anchoring on distinctive message text removes the actual fragility (vacuous matching) without that scope.

3. codesys-import.test.ts — already fixed

The "V3 vs V2.3 counts comparable" test already uses toBeGreaterThan(...) tolerance checks, not the brittle exact toBe(v23fn) equality the issue described. No change needed.

Verification

Affected files pass (76 tests); the OSCAT test genuinely ran (172 FB instantiation tests), confirming it's no longer vacuous.

Supersedes the stale, conflicting PR #83 (it touched src/index.ts/analyzer.ts and the already-fixed codesys test, and conflicts against current development).

🤖 Generated with Claude Code

Two of the three issues in #75 are still valid; the third was already
fixed.

1. oscat-gpp-compile.test.ts — the "compiles and runs full OSCAT" test
   silently `return`ed when no transpiled output existed, so it could
   pass without testing anything. The suite is already gated by
   `describe.skipIf(!hasGpp || !oscatStlibAvailable)`, so a missing
   artifact means the preceding transpile test failed — a real failure.
   Replaced the silent return with `expect.fail(...)`, and removed a
   dead `return` after an existing `expect.fail`.

2. located-variables.test.ts — "error on located variable in FB" asserted
   `message.includes('FUNCTION_BLOCK')`, a generic token any unrelated FB
   error would satisfy (vacuous match). Anchored it to the distinctive
   rule text "Located variables can only be declared …" so the test fails
   if a different error fires or the located-var check regresses.
   (CompileError has no populated `code` field — introducing an
   error-code taxonomy across the analyzer would be a much larger change,
   out of scope here.)

3. codesys-import.test.ts "V3 vs V2.3 counts" — already uses
   `toBeGreaterThan(...)` tolerance checks, not the brittle exact
   `toBe(v23fn)` equality the issue described. No change needed.

Supersedes the stale, conflicting PR #83. Affected files pass (76 tests).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@thiagoralves thiagoralves merged commit 1a0ec3e into development Jun 1, 2026
@thiagoralves thiagoralves deleted the fix/75-fragile-test-assertions branch June 1, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: fragile/vacuous assertions in oscat, codesys-import, located-variables tests

1 participant