test: fix fragile/vacuous assertions (#75)#149
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 bydescribe.skipIf(!hasGpp || !oscatStlibAvailable), so a missing artifact means the preceding transpile test failed — a real failure. Replaced the silent return withexpect.fail(...), and removed a deadreturnafter an existingexpect.fail.2.
located-variables.test.ts— fragile string-contains (fixed)should error on located variable in function blockassertedmessage.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.3.
codesys-import.test.ts— already fixedThe "V3 vs V2.3 counts comparable" test already uses
toBeGreaterThan(...)tolerance checks, not the brittle exacttoBe(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.tsand the already-fixed codesys test, and conflicts against currentdevelopment).🤖 Generated with Claude Code