p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

[p5.js 2.0+ Bug Report]: Missing unit tests for isLooping() return value

Open harshiltewari2004 opened this issue 4 months ago • 2 comments

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [x] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [ ] Events
  • [ ] Image
  • [ ] IO
  • [ ] Math
  • [ ] Typography
  • [ ] Utilities
  • [ ] WebGL
  • [ ] WebGPU
  • [ ] p5.strands
  • [ ] Build process
  • [x] Unit testing
  • [ ] Internationalization
  • [ ] Friendly errors
  • [ ] Other (specify if possible)

p5.js version

current main (5743cb5ba)

Web browser and version

N/A — test coverage gap, not a runtime bug

Operating system

N/A — same reason

Steps to reproduce this

isLooping() (src/core/structure.js) returns the internal _loop flag and is documented in its JSDoc as supported usage — but its return value is never tested. There are currently zero references to isLooping anywhere under test/; the existing loop()/noLoop() suite in test/unit/core/structure.js asserts only on frameCount behavior and never calls isLooping().

Proposed tests (test-only, no source changes):

  • isLooping() returns true by default while the draw loop is running
  • returns false after noLoop()
  • returns true again after a subsequent loop()

I'd like to fix this myself if approved.

harshiltewari2004 avatar Jul 15 '26 16:07 harshiltewari2004

Thanks for reporting this @harshiltewari2004 ! It looks like a valid test coverage gap since isLooping() is part of the public API, having direct unit test for its behavior will be useful. The proposed test cases for the default state, noLoop(), and loop() again all make sense for covering its expected behavior.

I've assigned this to you, feel free to work on it. Looking forward to the PR!

cc @davepagurek @ksen0

aashu2006 avatar Jul 15 '26 16:07 aashu2006

Thanks @aashu2006! I'll follow the conventions of the existing structure.js test suite and put up a PR soon!

harshiltewari2004 avatar Jul 15 '26 16:07 harshiltewari2004