Skip to content

Commit

Permalink
Merge pull request #88 from sanctuary-js/davidchambers/lte
Browse files Browse the repository at this point in the history
fix handling of NaN in Number$prototype$lte to guarantee totality
  • Loading branch information
davidchambers authored Feb 28, 2018
2 parents 2403d09 + b932b19 commit f758e17
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
function Number$prototype$lte(other) {
return typeof this === 'object' ?
lte(this.valueOf(), other.valueOf()) :
isNaN(this) && isNaN(other) || this <= other;
isNaN(this) || this <= other;
}

// Date$prototype$toString :: Date ~> () -> String
Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ test('lte', function() {
eq(Z.lte(Infinity, -Infinity), false);
eq(Z.lte(-Infinity, Infinity), true);
eq(Z.lte(-Infinity, -Infinity), true);
eq(Z.lte(NaN, Math.PI), false);
eq(Z.lte(NaN, Math.PI), true);
eq(Z.lte(Math.PI, NaN), false);
eq(Z.lte(new Number(0), new Number(0)), true);
eq(Z.lte(new Number(0), new Number(-0)), true);
Expand All @@ -694,7 +694,7 @@ test('lte', function() {
eq(Z.lte(new Number(Infinity), new Number(-Infinity)), false);
eq(Z.lte(new Number(-Infinity), new Number(Infinity)), true);
eq(Z.lte(new Number(-Infinity), new Number(-Infinity)), true);
eq(Z.lte(new Number(NaN), new Number(Math.PI)), false);
eq(Z.lte(new Number(NaN), new Number(Math.PI)), true);
eq(Z.lte(new Number(Math.PI), new Number(NaN)), false);
eq(Z.lte(42, new Number(42)), false);
eq(Z.lte(new Number(42), 42), false);
Expand Down

0 comments on commit f758e17

Please sign in to comment.