Add unit tests for noiseDetail()
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript
- Domain
- testing
Research direction
Read src/math/noise.js around noiseDetail() and the existing tests in test/unit/math/noise.js. Add tests for setting octaves and falloff, invalid values, and omitted falloff; restore the default state afterward so other tests are unaffected. Run the noise unit tests and update the outdated comment; done when the requested behaviors are covered and the suite passes.
Written by the indexing model from the issue text.
Description
Increasing access
Tests make noiseDetail()'s behaviour explicit and protect it from regressions, so sketches that rely on it keep working across releases. They also give new contributors a clear reference for how the function is meant to behave.
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
Feature enhancement details
noiseDetail() (src/math/noise.js:403-410) has no unit tests. test/unit/math/noise.js:19 notes this:
// ALso need test for noiseSeed and noiseDetail
noiseSeed has since been covered (lines 36-60), but noiseDetail hasn't.
The private getters _getNoiseOctaves() and _getNoiseAmpFalloff() (lines 416-425) make the state directly assertable. Proposed tests:
- sets octaves and falloff when both are given
- ignores
lod <= 0andfalloff <= 0, keeping the previous values - when
falloffis omitted it defaults to 0.5, so a previously set falloff is reset rather than kept
Since the suite shares one mockP5Prototype and noiseDetail state persists in the module closure, the new tests would restore the defaults (4 octaves, 0.5 falloff) afterwards so the existing noise() tests aren't affected.
I'd also update the comment at line 19, since noiseSeed is now tested.
Checked against main at 3193703. The strands noiseDetail tests in the WebGL/WebGPU shader suites cover state leaking between shaders, not this function.
I'd like to fix this myself if approved.
- Dominant language
- JavaScript
- Stars
- 24.1k
- Forks
- 3.9k
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 33
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from processing/p5.js
-
[p5.js 2.0+ Bug Report]: SVG importer does not respect preserveAspectRatio="none" for <symbol>/<use>Possibly taken @Danyccsf claimed this today. OpenArea:Core p5.js 2.0+
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
processing/p5.js#9257 · 2 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
[p5.js 2.0+ Bug Report]: storeItem() validation branches are missing `return`, so bad input throws a TypeError or is stored anywayPossibly taken @iUjjwalRaj claimed this 2 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
processing/p5.js#9242 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
processing/p5.js#9241 ·
Maintainers usually reply within 2 days
-
[p5.js 2.0+ Bug Report]: Typo in Spanish reference documentation for ellipseMode()Possibly taken @cgutierrezval claimed this 5 days ago. OpenInternationalization p5.js 2.0+
Difficulty 1/5 Under an hour Newbie friendliness 95/100
processing/p5.js#9231 · 3 comments ·
Maintainers usually reply within 2 days
-
[p5.js 2.0+ Bug Report]: ReferenceError: p5 is not defined when calling loadPixels/get/copy/mask on p5.MediaElement in ESMPossibly taken @Pcmhacker-piro claimed this 10 days ago. OpenArea:Core Area:DOM
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
processing/p5.js#9189 · 1 comment ·
Maintainers usually reply within 2 days
All issues in processing/p5.js
Similar issues
-
component:sight
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
agentic-os-org/ANOLISA#6738 · 2 comments ·
Maintainers usually reply within 1 day
-
bug Durable Agents Observability (AI Telemetry) status: needs triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
mastra-ai/mastra#26470 · 1 comment ·
Maintainers usually reply within 1 day
-
feature/cohorts feature/feature-flags team/feature-flags
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Orbit-xyz/orbit-docs#11 ·
-
area/build area/tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days