File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ function writtenNumber(n, options) {
4545 options = options || { } ;
4646 options = util . defaults ( options , writtenNumber . defaults ) ;
4747
48+ if ( n < 0 ) {
49+ return "" ;
50+ }
51+
4852 n = Math . round ( + n ) ;
4953
5054 var language = typeof options . lang === "string"
Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ describe("written-number", function() {
1313 writtenNumber . should . be . instanceof ( Function ) ;
1414 } ) ;
1515
16+ it ( "negative numbers return \"\"" , function ( ) {
17+ writtenNumber ( - 3 ) . should . equal ( "" ) ;
18+ writtenNumber ( - 5 ) . should . equal ( "" ) ;
19+ } ) ;
20+
1621 it ( "doesn't blow up weirdly with invalid input" , function ( ) {
1722 writtenNumber ( "asdfasdfasdf" ) . should . equal ( "" ) ;
1823 writtenNumber ( "0.as" ) . should . equal ( "" ) ;
You can’t perform that action at this time.
0 commit comments