Skip to content

Commit

Permalink
😒 chore: Patch tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Apr 27, 2020
1 parent 368a88a commit f25d49b
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 100 deletions.
13 changes: 7 additions & 6 deletions test/src/attr/attr.js
@@ -1,22 +1,23 @@
import test from 'ava';
import * as compare from '../../../src';


var util, increasing, decreasing, t;

util = require( "util" );
import util from "util" ;

increasing = compare.attr( compare.increasing , "length" ) ;
decreasing = compare.attr( compare.decreasing , "length" ) ;


t = function ( a, b, z ) {
function t ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -25,7 +26,7 @@ t = function ( a, b, z ) {
};


test( "attr" , function ( ) {
test( "attr" , t => {

t( [], [], 0 );
t( [], [0], -1 );
Expand Down
13 changes: 7 additions & 6 deletions test/src/attr/len.js
@@ -1,22 +1,23 @@
import test from 'ava';
import * as compare from '../../../src';


var util, increasing, decreasing, t;

util = require( "util" );
import util from "util" ;

increasing = compare.len( compare.increasing ) ;
decreasing = compare.len( compare.decreasing ) ;


t = function ( a, b, z ) {
function t ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -25,7 +26,7 @@ t = function ( a, b, z ) {
};


test( "attr" , function ( ) {
test( "attr" , t => {

t( [], [], 0 );
t( [], [0], -1 );
Expand Down
16 changes: 9 additions & 7 deletions test/src/decreasing.js
@@ -1,15 +1,17 @@
import test from 'ava';
import * as compare from '../../src';


test( "decreasing", function () {
test( "decreasing", t => {


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

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


});
15 changes: 8 additions & 7 deletions test/src/fn.js
@@ -1,23 +1,24 @@
import test from 'ava';
import * as compare from '../../src';


var util, increasing, decreasing, operator, t;

util = require( "util" );
operator = require( "@aureooms/js-operator" ) ;
import util from "util" ;
import operator from "@aureooms/js-operator" ;

increasing = compare.fn( compare.increasing , operator.len ) ;
decreasing = compare.fn( compare.decreasing , operator.len ) ;


t = function ( a, b, z ) {
function t ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -26,7 +27,7 @@ t = function ( a, b, z ) {
};


test( "attr" , function ( ) {
test( "attr" , t => {

t( [], [], 0 );
t( [], [0], -1 );
Expand Down
16 changes: 9 additions & 7 deletions test/src/increasing.js
@@ -1,15 +1,17 @@
import test from 'ava';
import * as compare from '../../src';


test( "increasing", function () {
test( "increasing", t => {


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

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


});
13 changes: 7 additions & 6 deletions test/src/lexicographical/colexicographical.js
@@ -1,22 +1,23 @@
import test from 'ava';
import * as compare from '../../../src';


var util, increasing, decreasing, one;

util = require( "util" );
import util from "util" ;

increasing = compare.colexicographical( compare.increasing );
decreasing = compare.reverse( increasing );


one = function ( a, b, z ) {
function one ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -25,7 +26,7 @@ one = function ( a, b, z ) {
};


test( "colexicographical", function () {
test( "colexicographical", t => {

one( [], [], 0 );
one( [], [0], -1 );
Expand Down
17 changes: 9 additions & 8 deletions test/src/lexicographical/fixedcolexicographical.js
@@ -1,22 +1,23 @@
import test from 'ava';
import * as compare from '../../../src';


var util, increasing, decreasing, t;

util = require( "util" );
import util from "util" ;

increasing = compare.fixedcolexicographical( compare.increasing , 5 );
decreasing = compare.fixedcolexicographical( compare.decreasing , 5 );


t = function ( a, b, z ) {
function t ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -25,13 +26,13 @@ t = function ( a, b, z ) {
a = a.concat( Math.random( ) ) ;
b = b.concat( Math.random( ) ) ;

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -40,7 +41,7 @@ t = function ( a, b, z ) {
};


test( "fixedcolexicographical", function () {
test( "fixedcolexicographical", t => {

t( [1, 6, 7, 8, 9], [1, 6, 7, 8, 9], 0 );

Expand Down
17 changes: 9 additions & 8 deletions test/src/lexicographical/fixedlexicographical.js
@@ -1,22 +1,23 @@
import test from 'ava';
import * as compare from '../../../src';


var util, increasing, decreasing, t;

util = require( "util" );
import util from "util" ;

increasing = compare.fixedlexicographical( compare.increasing , 5 );
decreasing = compare.fixedlexicographical( compare.decreasing , 5 );


t = function ( a, b, z ) {
function t ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -25,13 +26,13 @@ t = function ( a, b, z ) {
a = a.concat( Math.random( ) ) ;
b = b.concat( Math.random( ) ) ;

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -40,7 +41,7 @@ t = function ( a, b, z ) {
};


test( "fixedlexicographical", function () {
test( "fixedlexicographical", t => {

t( [1, 6, 7, 8, 9], [1, 6, 7, 8, 9], 0 );

Expand Down
13 changes: 7 additions & 6 deletions test/src/lexicographical/lexicographical.js
@@ -1,22 +1,23 @@
import test from 'ava';
import * as compare from '../../../src';


var util, increasing, decreasing, one;

util = require( "util" );
import util from "util" ;

increasing = compare.lexicographical( compare.increasing );
decreasing = compare.reverse( increasing );


one = function ( a, b, z ) {
function one ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -25,7 +26,7 @@ one = function ( a, b, z ) {
};


test( "lexicographical", function () {
test( "lexicographical", t => {

one( [], [], 0 );
one( [], [0], -1 );
Expand Down
13 changes: 7 additions & 6 deletions test/src/lexicographical/quasicolexicographical.js
@@ -1,22 +1,23 @@
import test from 'ava';
import * as compare from '../../../src';


var util, increasing, decreasing, one;

util = require( "util" );
import util from "util" ;

increasing = compare.quasicolexicographical( compare.increasing );
decreasing = compare.reverse( increasing );


one = function ( a, b, z ) {
function one ( a, b, z ) {

deepEqual(
t.deepEqual(
compare.sign( increasing( a, b ) ),
z,
util.format( "i %s %s", JSON.stringify( a ), JSON.stringify( b ) )
);

deepEqual(
t.deepEqual(
compare.sign( decreasing( a, b ) ),
-z,
util.format( "d %s %s", JSON.stringify( a ), JSON.stringify( b ) )
Expand All @@ -25,7 +26,7 @@ one = function ( a, b, z ) {
};


test( "quasicolexicographical", function () {
test( "quasicolexicographical", t => {

one( [], [], 0 );
one( [], [0], -1 );
Expand Down

0 comments on commit f25d49b

Please sign in to comment.