From f25d49bcd6c6fec766cbf91a22408e3c1916d586 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Ooms?= Date: Mon, 27 Apr 2020 14:30:27 +0200 Subject: [PATCH] :unamused: chore: Patch tests. --- test/src/attr/attr.js | 13 ++++++----- test/src/attr/len.js | 13 ++++++----- test/src/decreasing.js | 16 +++++++------ test/src/fn.js | 15 ++++++------ test/src/increasing.js | 16 +++++++------ test/src/lexicographical/colexicographical.js | 13 ++++++----- .../lexicographical/fixedcolexicographical.js | 17 +++++++------- .../lexicographical/fixedlexicographical.js | 17 +++++++------- test/src/lexicographical/lexicographical.js | 13 ++++++----- .../lexicographical/quasicolexicographical.js | 13 ++++++----- .../lexicographical/quasilexicographical.js | 13 ++++++----- .../rangedcolexicographical.js | 17 +++++++------- .../lexicographical/rangedlexicographical.js | 17 +++++++------- test/src/reverse.js | 23 ++++++++++--------- 14 files changed, 116 insertions(+), 100 deletions(-) diff --git a/test/src/attr/attr.js b/test/src/attr/attr.js index 4ecb9a1..039653a 100644 --- a/test/src/attr/attr.js +++ b/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 ) ) @@ -25,7 +26,7 @@ t = function ( a, b, z ) { }; -test( "attr" , function ( ) { +test( "attr" , t => { t( [], [], 0 ); t( [], [0], -1 ); diff --git a/test/src/attr/len.js b/test/src/attr/len.js index 32b8d07..dadf820 100644 --- a/test/src/attr/len.js +++ b/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 ) ) @@ -25,7 +26,7 @@ t = function ( a, b, z ) { }; -test( "attr" , function ( ) { +test( "attr" , t => { t( [], [], 0 ); t( [], [0], -1 ); diff --git a/test/src/decreasing.js b/test/src/decreasing.js index b46c622..56ad5d2 100644 --- a/test/src/decreasing.js +++ b/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 >" ); }); diff --git a/test/src/fn.js b/test/src/fn.js index a587513..d604a9e 100644 --- a/test/src/fn.js +++ b/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 ) ) @@ -26,7 +27,7 @@ t = function ( a, b, z ) { }; -test( "attr" , function ( ) { +test( "attr" , t => { t( [], [], 0 ); t( [], [0], -1 ); diff --git a/test/src/increasing.js b/test/src/increasing.js index 931d695..8101ed7 100644 --- a/test/src/increasing.js +++ b/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 >" ); }); diff --git a/test/src/lexicographical/colexicographical.js b/test/src/lexicographical/colexicographical.js index 2e291e9..f9ec9a4 100644 --- a/test/src/lexicographical/colexicographical.js +++ b/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 ) ) @@ -25,7 +26,7 @@ one = function ( a, b, z ) { }; -test( "colexicographical", function () { +test( "colexicographical", t => { one( [], [], 0 ); one( [], [0], -1 ); diff --git a/test/src/lexicographical/fixedcolexicographical.js b/test/src/lexicographical/fixedcolexicographical.js index 4e1aa51..e02393a 100644 --- a/test/src/lexicographical/fixedcolexicographical.js +++ b/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 ) ) @@ -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 ) ) @@ -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 ); diff --git a/test/src/lexicographical/fixedlexicographical.js b/test/src/lexicographical/fixedlexicographical.js index 9ad255a..e636f0b 100644 --- a/test/src/lexicographical/fixedlexicographical.js +++ b/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 ) ) @@ -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 ) ) @@ -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 ); diff --git a/test/src/lexicographical/lexicographical.js b/test/src/lexicographical/lexicographical.js index f506e3e..c754786 100644 --- a/test/src/lexicographical/lexicographical.js +++ b/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 ) ) @@ -25,7 +26,7 @@ one = function ( a, b, z ) { }; -test( "lexicographical", function () { +test( "lexicographical", t => { one( [], [], 0 ); one( [], [0], -1 ); diff --git a/test/src/lexicographical/quasicolexicographical.js b/test/src/lexicographical/quasicolexicographical.js index 6da7ece..1a5b4f6 100644 --- a/test/src/lexicographical/quasicolexicographical.js +++ b/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 ) ) @@ -25,7 +26,7 @@ one = function ( a, b, z ) { }; -test( "quasicolexicographical", function () { +test( "quasicolexicographical", t => { one( [], [], 0 ); one( [], [0], -1 ); diff --git a/test/src/lexicographical/quasilexicographical.js b/test/src/lexicographical/quasilexicographical.js index ee830b6..86e3120 100644 --- a/test/src/lexicographical/quasilexicographical.js +++ b/test/src/lexicographical/quasilexicographical.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.quasilexicographical( 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 ) ) @@ -25,7 +26,7 @@ one = function ( a, b, z ) { }; -test( "quasilexicographical", function () { +test( "quasilexicographical", t => { one( [], [], 0 ); one( [], [0], -1 ); diff --git a/test/src/lexicographical/rangedcolexicographical.js b/test/src/lexicographical/rangedcolexicographical.js index 605f6b6..025041a 100644 --- a/test/src/lexicographical/rangedcolexicographical.js +++ b/test/src/lexicographical/rangedcolexicographical.js @@ -1,25 +1,26 @@ +import test from 'ava'; +import * as compare from '../../../src'; -var util, increasing, decreasing, t; -util = require( "util" ); +import util from "util" ; increasing = compare.rangedcolexicographical( compare.increasing , 1 , 6 ) ; decreasing = compare.rangedcolexicographical( compare.decreasing , 1 , 6 ) ; -t = function ( a, b, z ) { +function t ( a, b, z ) { a = [ Math.random( ) ].concat( a ) ; b = [ Math.random( ) ].concat( b ) ; - 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 ) ) @@ -28,13 +29,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 ) ) @@ -43,7 +44,7 @@ t = function ( a, b, z ) { }; -test( "rangedcolexicographical", function () { +test( "rangedcolexicographical", t => { t( [1, 6, 7, 8, 9], [1, 6, 7, 8, 9], 0 ); diff --git a/test/src/lexicographical/rangedlexicographical.js b/test/src/lexicographical/rangedlexicographical.js index 8167917..0fc079c 100644 --- a/test/src/lexicographical/rangedlexicographical.js +++ b/test/src/lexicographical/rangedlexicographical.js @@ -1,25 +1,26 @@ +import test from 'ava'; +import * as compare from '../../../src'; -var util, increasing, decreasing, t; -util = require( "util" ); +import util from "util" ; increasing = compare.rangedlexicographical( compare.increasing , 1 , 6 ) ; decreasing = compare.rangedlexicographical( compare.decreasing , 1 , 6 ) ; -t = function ( a, b, z ) { +function t ( a, b, z ) { a = [ Math.random( ) ].concat( a ) ; b = [ Math.random( ) ].concat( b ) ; - 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 ) ) @@ -28,13 +29,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 ) ) @@ -43,7 +44,7 @@ t = function ( a, b, z ) { }; -test( "rangedlexicographical", function () { +test( "rangedlexicographical", t => { t( [1, 6, 7, 8, 9], [1, 6, 7, 8, 9], 0 ); diff --git a/test/src/reverse.js b/test/src/reverse.js index 8db79a6..90d1425 100644 --- a/test/src/reverse.js +++ b/test/src/reverse.js @@ -1,15 +1,16 @@ +import test from 'ava'; +import * as compare from '../../src'; -var util, increasing, decreasing, increasing2, decreasing2, one; -util = require( "util" ); +import util from "util" ; increasing = compare.increasing; decreasing = compare.decreasing; increasing2 = compare.reverse( decreasing ); decreasing2 = compare.reverse( increasing ); -one = function ( a, b ) { +function one ( a, b ) { var i, d, i2, d2, ri, rd, ri2, rd2; @@ -22,18 +23,18 @@ one = function ( a, b ) { ri2 = increasing2( b, a ); rd2 = decreasing2( b, a ); - deepEqual( i, i2, util.format( "i i2 ( %f, %f)", a, b ) ); - deepEqual( -i, ri, util.format( "-i ri ( %f, %f)", a, b ) ); - deepEqual( -i, ri2, util.format( "-i ri2 ( %f, %f)", a, b ) ); - deepEqual( -i, d, util.format( "-i d ( %f, %f)", a, b ) ); - deepEqual( -i, d2, util.format( "-i d2 ( %f, %f)", a, b ) ); - deepEqual( i, rd, util.format( "i rd ( %f, %f)", a, b ) ); - deepEqual( i, rd2, util.format( "i rd2 ( %f, %f)", a, b ) ); + t.deepEqual( i, i2, util.format( "i i2 ( %f, %f)", a, b ) ); + t.deepEqual( -i, ri, util.format( "-i ri ( %f, %f)", a, b ) ); + t.deepEqual( -i, ri2, util.format( "-i ri2 ( %f, %f)", a, b ) ); + t.deepEqual( -i, d, util.format( "-i d ( %f, %f)", a, b ) ); + t.deepEqual( -i, d2, util.format( "-i d2 ( %f, %f)", a, b ) ); + t.deepEqual( i, rd, util.format( "i rd ( %f, %f)", a, b ) ); + t.deepEqual( i, rd2, util.format( "i rd2 ( %f, %f)", a, b ) ); }; -test( "reverse", function () { +test( "reverse", t => { var n;