Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/friendly_errors/param_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ function validateParams(p5, fn, lifecycles) {
args.every(arg => arg === undefined)
) {
const undefinedErrorMessage = `🌸 p5.js says: All arguments for ${func}() are undefined. There is likely an error in the code.`;

console.log(undefinedErrorMessage);
return {
success: false,
error: undefinedErrorMessage
Expand Down
1 change: 1 addition & 0 deletions src/math/noise.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ function noise(p5, fn){
* @return {Number} Perlin noise value at specified coordinates.
*/
fn.noise = function(x, y = 0, z = 0) {
if (x === null || y === null || z === null) return NaN;
if (perlin == null) {
perlin = new Array(PERLIN_SIZE + 1);
for (let i = 0; i < PERLIN_SIZE + 1; i++) {
Expand Down
10 changes: 10 additions & 0 deletions test/unit/math/noise.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ suite('Noise', function() {
});
});

// Test for null arguments
suite('null arguments', function() {
test('null should returns NaN', function() {
assert.isNaN(mockP5Prototype.noise(null));
});
test('noise(0, 0, null) returns NaN', function() {
assert.isNaN(mockP5Prototype.noise(0, 0, null));
});
});

// Test for noiseSeed
suite('p5.prototype.noiseSeed', function() {
beforeEach(function() {
Expand Down