Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add unit tests for noiseDetail()

Đang mở Phù hợp với người mới
#9,253 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@Pcmhacker-piro đang làm issue này rồi.

Từ ngày 6/10/2026.

  • #9255 của @Pcmhacker-piro — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
testing

Hướng nghiên cứu

Đọc src/math/noise.js xung quanh noiseDetail() và các test hiện có trong test/unit/math/noise.js. Thêm các test để cấu hình octaves và falloff, giá trị không hợp lệ và falloff bị bỏ qua; khôi phục trạng thái mặc định sau đó để các test khác không bị ảnh hưởng. Chạy các test đơn vị của noise và cập nhật bình luận lỗi thời; hoàn thành khi các hành vi được yêu cầu được bao phủ và bộ test vượt qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Area:Math Enhancement
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 <= 0 and falloff <= 0, keeping the previous values
  • when falloff is 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.

Ngôn ngữ chính
JavaScript
Star
24.1k
Fork
3.9k
Merge trung bình
3 ngày 19 giờ
Pull request đã merge (30 ngày)
33

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của processing/p5.js

Tất cả issue của processing/p5.js

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.