fix: skip assertion tracking injection for namespace function calls#385
Open
TwitchBronBron wants to merge 1 commit into
Open
fix: skip assertion tracking injection for namespace function calls#385TwitchBronBron wants to merge 1 commit into
TwitchBronBron wants to merge 1 commit into
Conversation
When a test method contains a call like `some.space.assertEqual(...)`, the assertion rewriter was computing `callPath = "some.space"` and injecting `some.space.currentAssertLineNumber = N`. BrighterScript then correctly transpiles `some.space` as a namespace to `some_space.`, producing invalid output (`some_space.currentAssertLineNumber`). The fix checks whether the first part of callPath is a known namespace name before injecting assertion tracking. If it is, the call is a namespaced function (not a method on an object like m) and tracking is skipped. The bug was always latent in Rooibos but became visible after BrighterScript 0.72.0 made namespace recognition more reliable during transpile via the new ScopeNamespaceLookup.
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.
Summary
some.space.assertEqual(...)inside a test method incorrectly had assertion tracking (currentAssertLineNumber,currentResult?.isFail,done()) injected usingsome.spaceas the target objectTestGroup.modifyAssertions(): if the first part of the call path is a known namespace name, the call is a namespaced function (not a method on an object likem) and assertion tracking injection is skippedBackground
When a test contains a namespaced function call whose name matches the assertion regex (e.g.
some.space.assertEqual(...)), the rewriter was computingcallPath = "some.space"and injecting:The bug was latent in Rooibos but became visible after BrighterScript 0.72.0 made namespace recognition more reliable during transpile (via the new
ScopeNamespaceLookup), causingsome.spacein the injected code to be correctly transpiled tosome_space..Test plan
plugin.spec.tsverifies thatsome.space.assertEqual(1, 1)inside a test method does NOT producesome_space.currentAssertLineNumber, whilem.assertEqual(2, 2)still correctly getsm.currentAssertLineNumberinjected🤖 Generated with Claude Code