Add unit tests for isLooping() default, noLoop() and loop() states#8981
Open
harshiltewari2004 wants to merge 1 commit into
Open
Add unit tests for isLooping() default, noLoop() and loop() states#8981harshiltewari2004 wants to merge 1 commit into
harshiltewari2004 wants to merge 1 commit into
Conversation
lirenjie95
approved these changes
Jul 17, 2026
lirenjie95
left a comment
Member
There was a problem hiding this comment.
LGTM once the placeholder in the PR description is cleaned up.
Contributor
Author
|
Cleaned up-thanks for the catch! |
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.
Resolves #8979
Changes
p5.prototype.isLoopingsuite totest/unit/core/structure.jscovering the three states scoped in the issue:trueby default,falseafternoLoop(),trueagain afterloop().noLoop()/loop()within the same frame on the shared instance double-pumps its draw loop —noLoop()doesn't cancel the pendingrequestAnimationFrametick, andloop()immediately starts a new chain, so the stale tick resurrects alongside it. This made the existing timing-based "noLoop should stop" test fail (reproduced consistently; passes consistently without the new suite). A private instance isolates the toggling completely.loop/noLooptests: The tests are synchronous, unlike the neighboring loop/noLoop tests: those verify the draw loop's actual behavior, which needs real time to elapse so pending requestAnimationFrame ticks can fire (or fail to). These tests only assert the state flag, which noLoop()/loop() set synchronously before returning, so there's nothing to wait for.PR Checklist
npm run lintpasses