File tree 2 files changed +5
-10
lines changed
2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -215,9 +215,10 @@ p5.prototype.textStyle = function(theStyle) {
215
215
*Letter P and p5.js are displayed with vertical lines at end. P is wide
216
216
*
217
217
*/
218
- p5 . prototype . textWidth = function ( theText ) {
218
+ p5 . prototype . textWidth = function ( ) {
219
+ arguments [ 0 ] += '' ;
219
220
p5 . _validateParameters ( 'textWidth' , arguments ) ;
220
- if ( theText . length === 0 ) {
221
+ if ( arguments [ 0 ] . length === 0 ) {
221
222
return 0 ;
222
223
}
223
224
return this . _renderer . textWidth . apply ( this . _renderer , arguments ) ;
Original file line number Diff line number Diff line change @@ -95,14 +95,8 @@ suite('Typography Attributes', function() {
95
95
assert . isNumber ( myp5 . textWidth ( 'p5.js' ) ) ;
96
96
} ) ;
97
97
// Either should not throw error
98
- test ( 'wrong param type at #0.' , function ( ) {
99
- assert . validationError ( function ( ) {
100
- myp5 . textWidth ( 9 ) ;
101
- } ) ;
102
- } ) ;
103
- // Or should return NaN
104
- test . skip ( 'should return NaN for wrong param.' , function ( ) {
105
- assert . isNumber ( myp5 . textWidth ( 100 ) ) ;
98
+ test ( 'should return a number for number input' , function ( ) {
99
+ assert . isNumber ( myp5 . textWidth ( 'p5.js' ) ) ;
106
100
} ) ;
107
101
} ) ;
108
102
You can’t perform that action at this time.
0 commit comments