Skip to content

Commit

Permalink
🔍 test(native): Add more tests to pinpoint the exact spec.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Sep 2, 2020
1 parent 8144e23 commit 11cfa0a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
24 changes: 18 additions & 6 deletions test/src/decreasing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,25 @@ import * as compare from '../../src';
test( "decreasing", t => {


t.truthy( compare.decreasing( Infinity, 0 ) < 0, "double <" );
t.truthy( compare.decreasing( Infinity, Infinity ) === 0, "double =" );
t.truthy( compare.decreasing( 0, Infinity ) > 0, "double >" );
t.true( compare.decreasing( Infinity, 0 ) < 0, "double <" );
t.true( compare.decreasing( Infinity, Infinity ) === 0, "double =" );
t.true( compare.decreasing( 0, Infinity ) > 0, "double >" );

t.truthy( compare.decreasing( "abc", "ab" ) < 0, "string <" );
t.truthy( compare.decreasing( "abc", "abc" ) === 0, "string =" );
t.truthy( compare.decreasing( "ab", "abc" ) > 0, "string >" );
t.true( compare.decreasing( "abc", "ab" ) < 0, "string <" );
t.true( compare.decreasing( "abc", "abc" ) === 0, "string =" );
t.true( compare.decreasing( "ab", "abc" ) > 0, "string >" );

t.true( compare.decreasing( NaN , NaN ) !== 0 , 'NaN != NaN');
t.true( compare.decreasing( NaN , 0 ) !== 0 , 'NaN != 0');
t.true( compare.decreasing( 0 , NaN ) !== 0 , '0 != NaN');
t.true( compare.decreasing( NaN , Infinity ) !== 0 , 'NaN != Infinity');
t.true( compare.decreasing( Infinity , NaN ) !== 0 , 'Infinity != NaN');
t.true( compare.decreasing( NaN , -Infinity ) !== 0 , 'NaN != -Infinity');
t.true( compare.decreasing( -Infinity , NaN ) !== 0 , '-Infinity != NaN');

t.true( compare.decreasing( new Date(1), new Date(1) ) !== 0, "this library is not suitable for date value equality checking" );
t.true( compare.decreasing( new Date(0), new Date(1) ) > 0, "date >" );
t.true( compare.decreasing( new Date(1), new Date(0) ) < 0, "date <" );


});
23 changes: 17 additions & 6 deletions test/src/increasing.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ import * as compare from '../../src';
test( "increasing", t => {


t.truthy( compare.increasing( 0, Infinity ) < 0, "double <" );
t.truthy( compare.increasing( Infinity, Infinity ) === 0, "double =" );
t.truthy( compare.increasing( Infinity, 0 ) > 0, "double >" );
t.true( compare.increasing( 0, Infinity ) < 0, "double <" );
t.true( compare.increasing( Infinity, Infinity ) === 0, "double =" );
t.true( compare.increasing( Infinity, 0 ) > 0, "double >" );

t.truthy( compare.increasing( "ab", "abc" ) < 0, "string <" );
t.truthy( compare.increasing( "abc", "abc" ) === 0, "string =" );
t.truthy( compare.increasing( "abc", "ab" ) > 0, "string >" );
t.true( compare.increasing( "ab", "abc" ) < 0, "string <" );
t.true( compare.increasing( "abc", "abc" ) === 0, "string =" );
t.true( compare.increasing( "abc", "ab" ) > 0, "string >" );

t.true( compare.increasing( NaN , NaN ) !== 0 , 'NaN != NaN');
t.true( compare.increasing( NaN , 0 ) !== 0 , 'NaN != 0');
t.true( compare.increasing( 0 , NaN ) !== 0 , '0 != NaN');
t.true( compare.increasing( NaN , Infinity ) !== 0 , 'NaN != Infinity');
t.true( compare.increasing( Infinity , NaN ) !== 0 , 'Infinity != NaN');
t.true( compare.increasing( NaN , -Infinity ) !== 0 , 'NaN != -Infinity');
t.true( compare.increasing( -Infinity , NaN ) !== 0 , '-Infinity != NaN');

t.true( compare.increasing( new Date(1), new Date(1) ) !== 0, "this library is not suitable for date value equality checking" );
t.true( compare.increasing( new Date(0), new Date(1) ) < 0, "date <" );
t.true( compare.increasing( new Date(1), new Date(0) ) > 0, "date >" );

});

0 comments on commit 11cfa0a

Please sign in to comment.