You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to match the test cases
- split the error messages, to get a type in line 418 and 462
- `actualType` will never be undefined which is checked in line 394 so make it undefined in line 430 to pass all test cases
Copy file name to clipboardExpand all lines: test/unit/core/param_errors.js
+18-18Lines changed: 18 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -110,10 +110,10 @@ suite('Validate Params', function () {
110
110
111
111
constinvalidInputs=[
112
112
{name: 'missing required arc parameters #4, #5',input: [200,100,100,80],msg: '🌸 p5.js says: Expected at least 6 arguments, but received fewer in p5.arc(). For more information, see https://p5js.org/reference/p5/arc.'},
113
-
{name: 'missing required param #0',input: [undefined,100,100,80,0,Math.PI,constants.PIE,30],msg: '🌸 p5.js says: Expected number at the first parameter, but received Invalid input: expected number, received undefined in p5.arc().'},
114
-
{name: 'missing required param #4',input: [200,100,100,80,undefined,0],msg: '🌸 p5.js says: Expected number at the fifth parameter, but received Invalid input: expected number, received undefined in p5.arc().'},
115
-
{name: 'missing optional param #5',input: [200,100,100,80,0,undefined,Math.PI],msg: '🌸 p5.js says: Expected number at the sixth parameter, but received Invalid input: expected number, received undefined in p5.arc().'},
116
-
{name: 'wrong param type at #0',input: ['a',100,100,80,0,Math.PI,constants.PIE,30],msg: '🌸 p5.js says: Expected number at the first parameter, but received Invalid input: expected number, received string in p5.arc().'}
113
+
{name: 'missing required param #0',input: [undefined,100,100,80,0,Math.PI,constants.PIE,30],msg: '🌸 p5.js says: Expected number at the first parameter, but received undefined in p5.arc().'},
114
+
{name: 'missing required param #4',input: [200,100,100,80,undefined,0],msg: '🌸 p5.js says: Expected number at the fifth parameter, but received undefined in p5.arc().'},
115
+
{name: 'missing optional param #5',input: [200,100,100,80,0,undefined,Math.PI],msg: '🌸 p5.js says: Expected number at the sixth parameter, but received undefined in p5.arc().'},
116
+
{name: 'wrong param type at #0',input: ['a',100,100,80,0,Math.PI,constants.PIE,30],msg: '🌸 p5.js says: Expected number at the first parameter, but received string in p5.arc().'}
117
117
];
118
118
119
119
invalidInputs.forEach(({ name, input, msg })=>{
@@ -130,7 +130,7 @@ suite('Validate Params', function () {
130
130
console.log(result);
131
131
assert.equal(
132
132
result.error,
133
-
'🌸 p5.js says: Did you mean to put `await` before a loading function? An unexpected Promise was found. Expected Image or Element or Texture or Framebuffer or FramebufferTexture or Renderer or Graphics at the first parameter, but received Input not instance of Image in p5.image().'
133
+
'🌸 p5.js says: Did you mean to put `await` before a loading function? An unexpected Promise was found. Expected Image or Element or Texture or Framebuffer or FramebufferTexture or Renderer or Graphics at the first parameter in p5.image().'
134
134
);
135
135
});
136
136
});
@@ -144,13 +144,13 @@ suite('Validate Params', function () {
144
144
145
145
suite('validateParams: a few edge cases',function(){
146
146
constinvalidInputs=[
147
-
{fn: 'color',name: 'wrong type for optional parameter',input: [0,0,0,'A'],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received Invalid input: expected number, received string in p5.color().'},
148
-
{fn: 'color',name: 'superfluous parameter',input: [[0,0,0],0],msg: '🌸 p5.js says: Expected number at the first parameter, but received Invalid input: expected number, received array in p5.color().'},
149
-
{fn: 'color',name: 'wrong element types',input: [['A','B','C']],msg: '🌸 p5.js says: Expected number at the first parameter, but received Invalid input: expected number, received array in p5.color().'},
150
-
{fn: 'rect',name: 'null, non-trailing, optional parameter',input: [0,0,0,0,null,0,0,0],msg: '🌸 p5.js says: Expected number at the fifth parameter, but received Invalid input: expected number, received null in p5.rect().'},
147
+
{fn: 'color',name: 'wrong type for optional parameter',input: [0,0,0,'A'],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received string in p5.color().'},
148
+
{fn: 'color',name: 'superfluous parameter',input: [[0,0,0],0],msg: '🌸 p5.js says: Expected number at the first parameter, but received array in p5.color().'},
149
+
{fn: 'color',name: 'wrong element types',input: [['A','B','C']],msg: '🌸 p5.js says: Expected number at the first parameter, but received array in p5.color().'},
150
+
{fn: 'rect',name: 'null, non-trailing, optional parameter',input: [0,0,0,0,null,0,0,0],msg: '🌸 p5.js says: Expected number at the fifth parameter, but received null in p5.rect().'},
151
151
{fn: 'color',name: 'too many args + wrong types too',input: ['A','A',0,0,0,0,0,0,0,0],msg: '🌸 p5.js says: Expected at most 4 arguments, but received more in p5.color(). For more information, see https://p5js.org/reference/p5/color.'},
152
-
{fn: 'line',name: 'null string given',input: [1,2,4,'null'],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received Invalid input: expected number, received string in p5.line().'},
153
-
{fn: 'line',name: 'NaN value given',input: [1,2,4,NaN],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received Invalid input: expected number, received NaN in p5.line().'}
152
+
{fn: 'line',name: 'null string given',input: [1,2,4,'null'],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received string in p5.line().'},
153
+
{fn: 'line',name: 'NaN value given',input: [1,2,4,NaN],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received NaN in p5.line().'}
{fn: 'color',name: 'missing params #1, #2',input: [12,undefined,undefined],msg: '🌸 p5.js says: Expected number at the second parameter, but received Invalid input: expected number, received undefined in p5.color().'},
166
+
{fn: 'color',name: 'missing params #1, #2',input: [12,undefined,undefined],msg: '🌸 p5.js says: Expected number at the second parameter, but received undefined in p5.color().'},
167
167
// Even though the undefined arguments are technically allowed for
168
168
// optional parameters, it is more likely that the user wanted to call
169
169
// the function with meaningful arguments.
170
170
{fn: 'random',name: 'missing params #0, #1',input: [undefined,undefined],msg: '🌸 p5.js says: All arguments for p5.random() are undefined. There is likely an error in the code.'},
171
-
{fn: 'circle',name: 'missing compulsory parameter #2',input: [5,5,undefined],msg: '🌸 p5.js says: Expected number at the third parameter, but received Invalid input: expected number, received undefined in p5.circle().'}
171
+
{fn: 'circle',name: 'missing compulsory parameter #2',input: [5,5,undefined],msg: '🌸 p5.js says: Expected number at the third parameter, but received undefined in p5.circle().'}
@@ -193,9 +193,9 @@ suite('Validate Params', function () {
193
193
});
194
194
195
195
constinvalidInputs=[
196
-
{name: 'optional parameter, incorrect type',input: [65,100,100,'a'],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received Invalid input: expected number, received string in p5.color().'},
197
-
{name: 'extra parameter',input: [[65,100,100],100],msg: '🌸 p5.js says: Expected number at the first parameter, but received Invalid input: expected number, received array in p5.color().'},
198
-
{name: 'incorrect element type',input: ['A','B','C'],msg: '🌸 p5.js says: Expected number at the first parameter, but received Invalid input: expected number, received string in p5.color().'},
196
+
{name: 'optional parameter, incorrect type',input: [65,100,100,'a'],msg: '🌸 p5.js says: Expected number at the fourth parameter, but received string in p5.color().'},
197
+
{name: 'extra parameter',input: [[65,100,100],100],msg: '🌸 p5.js says: Expected number at the first parameter, but received array in p5.color().'},
198
+
{name: 'incorrect element type',input: ['A','B','C'],msg: '🌸 p5.js says: Expected number at the first parameter, but received string in p5.color().'},
199
199
{name: 'incorrect parameter count',input: ['A','A',0,0,0,0,0,0],msg: '🌸 p5.js says: Expected at most 4 arguments, but received more in p5.color(). For more information, see https://p5js.org/reference/p5/color.'}
200
200
];
201
201
@@ -223,7 +223,7 @@ suite('Validate Params', function () {
assert.equal(result.error,'🌸 p5.js says: Expected number or array or object at the third parameter, but received Invalid input: expected number, received boolean in p5.set().');
226
+
assert.equal(result.error,'🌸 p5.js says: Expected number or array or object at the third parameter, but received boolean in p5.set().');
227
227
});
228
228
});
229
229
@@ -278,4 +278,4 @@ suite('Validate Params', function () {
0 commit comments