Skip to content

Commit 2cf8e39

Browse files
😒 chore: Patch tests.
1 parent 0c595ac commit 2cf8e39

File tree

14 files changed

+131
-120
lines changed

14 files changed

+131
-120
lines changed

test/src/undirected/offline/algo/eulerian/dup.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import test from 'ava';
12

23

34

@@ -68,7 +69,7 @@ var check = function(label, n, E, m){
6869
});
6970
});
7071

71-
deepEqual(count[1], count[0], 'check edge count');
72+
t.deepEqual(count[1], count[0], 'check edge count');
7273

7374

7475
});

test/src/undirected/offline/algo/eulerian/eventour.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import test from 'ava';
12

23

34
var check = function(label, n, x, E, _E){
@@ -45,20 +46,20 @@ var check = function(label, n, x, E, _E){
4546

4647
eventour(g, v, x, done, it, tour, []);
4748

48-
deepEqual(tour.length, E.length, 'check length');
49+
t.deepEqual(tour.length, E.length, 'check length');
4950

5051
var free = [];
5152
edges.forEach(function(e){
5253
free.push(e.free);
5354
});
5455

55-
deepEqual(free, gn.sqmat(1, E.length, false), 'check free');
56+
t.deepEqual(free, gn.sqmat(1, E.length, false), 'check free');
5657

5758

5859
i = tour.length;
5960
if(i){
6061
tour.push(tour[0]);
61-
while(i--) ok(d[tour[i]][tour[i+1]] < Infinity, 'check path component ' + i);
62+
while(i--) t.truthy(d[tour[i]][tour[i+1]] < Infinity, 'check path component ' + i);
6263
}
6364

6465

test/src/undirected/offline/algo/eulerian/oddgraph.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import test from 'ava';
12

23

34
var check = function(label, n, E){
@@ -45,16 +46,16 @@ var check = function(label, n, E){
4546
oddgraph(g, d, h);
4647

4748
h.vitr(function(v){
48-
ok(degree[v[1][0]] % 2, v[1][0] + ' odd');
49+
t.truthy(degree[v[1][0]] % 2, v[1][0] + ' odd');
4950
ainside[v[1][0]] = 1;
5051
if(degree[v[1][0]] % 2){
5152
h.eitr(v, function(_, u, w){
52-
deepEqual(w, d[v[1][0]][u[1][0]], 'd['+v[1][0]+']['+u[1][0]+'] check');
53+
t.deepEqual(w, d[v[1][0]][u[1][0]], 'd['+v[1][0]+']['+u[1][0]+'] check');
5354
});
5455
}
5556
});
5657

57-
deepEqual(ainside, einside, 'count all check')
58+
t.deepEqual(ainside, einside, 'count all check')
5859

5960
});
6061

test/src/undirected/offline/algo/eulerian/simplegraph.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import test from 'ava';
12
var check = function(name, order, E){
23

34

@@ -56,14 +57,14 @@ var check = function(name, order, E){
5657

5758
if(i !== j){
5859
edgecountg[i][j] = 1;
59-
ok(edgevalh[i][j] <= w, 'check (' + i + ', ' + j + ')');
60+
t.truthy(edgevalh[i][j] <= w, 'check (' + i + ', ' + j + ')');
6061
}
6162

6263
});
6364
});
6465

6566

66-
deepEqual(edgecounth, edgecountg, "check simplegraph");
67+
t.deepEqual(edgecounth, edgecountg, "check simplegraph");
6768

6869
});
6970

test/src/undirected/offline/algo/eulerian/wblossom_n3.js

+24-23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import test from 'ava';
12

23
var check = function(key, alg, callback){
34
test(key, function(assert){
@@ -10,98 +11,98 @@ var tests = {
1011

1112
test10_empty : function(alg){
1213
// empty input graph
13-
deepEqual(alg([]), []);
14+
t.deepEqual(alg([]), []);
1415
},
1516
test11_singleedge : function(alg){
1617
// single edge
17-
deepEqual(alg([ [0,1,1] ]), [1, 0]);
18+
t.deepEqual(alg([ [0,1,1] ]), [1, 0]);
1819
},
1920

2021
test12 : function(alg){
21-
deepEqual(alg([ [1,2,10], [2,3,11] ]), [ -1, -1, 3, 2 ]);
22+
t.deepEqual(alg([ [1,2,10], [2,3,11] ]), [ -1, -1, 3, 2 ]);
2223
},
2324

2425
test13 : function(alg){
25-
deepEqual(alg([ [1,2,5], [2,3,11], [3,4,5] ]), [ -1, -1, 3, 2, -1 ]);
26+
t.deepEqual(alg([ [1,2,5], [2,3,11], [3,4,5] ]), [ -1, -1, 3, 2, -1 ]);
2627
},
2728

2829
test14_maxcard : function(alg){
2930
// maximum cardinality
30-
deepEqual(alg([ [1,2,5], [2,3,11], [3,4,5] ], true), [ -1, 2, 1, 4, 3 ]);
31+
t.deepEqual(alg([ [1,2,5], [2,3,11], [3,4,5] ], true), [ -1, 2, 1, 4, 3 ]);
3132
},
3233

3334
test15_float : function(alg){
3435
// floating point weigths
35-
deepEqual(alg([ [1,2,Math.PI], [2,3,Math.E], [1,3,3.0], [1,4,Math.sqrt(2.0)] ]), [ -1, 4, 3, 2, 1 ]);
36+
t.deepEqual(alg([ [1,2,Math.PI], [2,3,Math.E], [1,3,3.0], [1,4,Math.sqrt(2.0)] ]), [ -1, 4, 3, 2, 1 ]);
3637
},
3738

3839
test16_negative : function(alg){
3940
// negative weights
40-
deepEqual(alg([ [1,2,2], [1,3,-2], [2,3,1], [2,4,-1], [3,4,-6] ], false), [ -1, 2, 1, -1, -1 ]);
41-
deepEqual(alg([ [1,2,2], [1,3,-2], [2,3,1], [2,4,-1], [3,4,-6] ], true), [ -1, 3, 4, 1, 2 ]);
41+
t.deepEqual(alg([ [1,2,2], [1,3,-2], [2,3,1], [2,4,-1], [3,4,-6] ], false), [ -1, 2, 1, -1, -1 ]);
42+
t.deepEqual(alg([ [1,2,2], [1,3,-2], [2,3,1], [2,4,-1], [3,4,-6] ], true), [ -1, 3, 4, 1, 2 ]);
4243
},
4344

4445
test20_sblossom : function(alg){
4546
// create S-blossom and use it for augmentation
46-
deepEqual(alg([ [1,2,8], [1,3,9], [2,3,10], [3,4,7] ]), [ -1, 2, 1, 4, 3 ]);
47-
deepEqual(alg([ [1,2,8], [1,3,9], [2,3,10], [3,4,7], [1,6,5], [4,5,6] ]), [ -1, 6, 3, 2, 5, 4, 1 ]);
47+
t.deepEqual(alg([ [1,2,8], [1,3,9], [2,3,10], [3,4,7] ]), [ -1, 2, 1, 4, 3 ]);
48+
t.deepEqual(alg([ [1,2,8], [1,3,9], [2,3,10], [3,4,7], [1,6,5], [4,5,6] ]), [ -1, 6, 3, 2, 5, 4, 1 ]);
4849
},
4950

5051
test21_tblossom : function(alg){
5152
// create S-blossom, relabel as T-blossom, use for augmentation
52-
deepEqual(alg([ [1,2,9], [1,3,8], [2,3,10], [1,4,5], [4,5,4], [1,6,3] ]), [ -1, 6, 3, 2, 5, 4, 1 ]);
53-
deepEqual(alg([ [1,2,9], [1,3,8], [2,3,10], [1,4,5], [4,5,3], [1,6,4] ]), [ -1, 6, 3, 2, 5, 4, 1 ]);
54-
deepEqual(alg([ [1,2,9], [1,3,8], [2,3,10], [1,4,5], [4,5,3], [3,6,4] ]), [ -1, 2, 1, 6, 5, 4, 3 ]);
53+
t.deepEqual(alg([ [1,2,9], [1,3,8], [2,3,10], [1,4,5], [4,5,4], [1,6,3] ]), [ -1, 6, 3, 2, 5, 4, 1 ]);
54+
t.deepEqual(alg([ [1,2,9], [1,3,8], [2,3,10], [1,4,5], [4,5,3], [1,6,4] ]), [ -1, 6, 3, 2, 5, 4, 1 ]);
55+
t.deepEqual(alg([ [1,2,9], [1,3,8], [2,3,10], [1,4,5], [4,5,3], [3,6,4] ]), [ -1, 2, 1, 6, 5, 4, 3 ]);
5556
},
5657

5758
test22_s_nest : function(alg){
5859
// create nested S-blossom, use for augmentation
59-
deepEqual(alg([ [1,2,9], [1,3,9], [2,3,10], [2,4,8], [3,5,8], [4,5,10], [5,6,6] ]), [ -1, 3, 4, 1, 2, 6, 5 ]);
60+
t.deepEqual(alg([ [1,2,9], [1,3,9], [2,3,10], [2,4,8], [3,5,8], [4,5,10], [5,6,6] ]), [ -1, 3, 4, 1, 2, 6, 5 ]);
6061
},
6162

6263
test23_s_relabel_nest : function(alg){
6364
// create S-blossom, relabel as S, include in nested S-blossom
64-
deepEqual(alg([ [1,2,10], [1,7,10], [2,3,12], [3,4,20], [3,5,20], [4,5,25], [5,6,10], [6,7,10], [7,8,8] ]), [ -1, 2, 1, 4, 3, 6, 5, 8, 7 ]);
65+
t.deepEqual(alg([ [1,2,10], [1,7,10], [2,3,12], [3,4,20], [3,5,20], [4,5,25], [5,6,10], [6,7,10], [7,8,8] ]), [ -1, 2, 1, 4, 3, 6, 5, 8, 7 ]);
6566
},
6667

6768
test24_s_nest_expand : function(alg){
6869
// create nested S-blossom, augment, expand recursively
69-
deepEqual(alg([ [1,2,8], [1,3,8], [2,3,10], [2,4,12], [3,5,12], [4,5,14], [4,6,12], [5,7,12], [6,7,14], [7,8,12] ]), [ -1, 2, 1, 5, 6, 3, 4, 8, 7 ]);
70+
t.deepEqual(alg([ [1,2,8], [1,3,8], [2,3,10], [2,4,12], [3,5,12], [4,5,14], [4,6,12], [5,7,12], [6,7,14], [7,8,12] ]), [ -1, 2, 1, 5, 6, 3, 4, 8, 7 ]);
7071
},
7172

7273
test25_s_t_expand : function(alg){
7374
// create S-blossom, relabel as T, expand
74-
deepEqual(alg([ [1,2,23], [1,5,22], [1,6,15], [2,3,25], [3,4,22], [4,5,25], [4,8,14], [5,7,13] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4 ]);
75+
t.deepEqual(alg([ [1,2,23], [1,5,22], [1,6,15], [2,3,25], [3,4,22], [4,5,25], [4,8,14], [5,7,13] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4 ]);
7576
},
7677

7778
test26_s_nest_t_expand : function(alg){
7879
// create nested S-blossom, relabel as T, expand
79-
deepEqual(alg([ [1,2,19], [1,3,20], [1,8,8], [2,3,25], [2,4,18], [3,5,18], [4,5,13], [4,7,7], [5,6,7] ]), [ -1, 8, 3, 2, 7, 6, 5, 4, 1 ]);
80+
t.deepEqual(alg([ [1,2,19], [1,3,20], [1,8,8], [2,3,25], [2,4,18], [3,5,18], [4,5,13], [4,7,7], [5,6,7] ]), [ -1, 8, 3, 2, 7, 6, 5, 4, 1 ]);
8081
},
8182

8283
test30_tnasty_expand : function(alg){
8384
// create blossom, relabel as T in more than one way, expand, augment
84-
deepEqual(alg([ [1,2,45], [1,5,45], [2,3,50], [3,4,45], [4,5,50], [1,6,30], [3,9,35], [4,8,35], [5,7,26], [9,10,5] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4, 10, 9 ]);
85+
t.deepEqual(alg([ [1,2,45], [1,5,45], [2,3,50], [3,4,45], [4,5,50], [1,6,30], [3,9,35], [4,8,35], [5,7,26], [9,10,5] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4, 10, 9 ]);
8586
},
8687

8788
test31_tnasty2_expand : function(alg){
8889
// again but slightly different
89-
deepEqual(alg([ [1,2,45], [1,5,45], [2,3,50], [3,4,45], [4,5,50], [1,6,30], [3,9,35], [4,8,26], [5,7,40], [9,10,5] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4, 10, 9 ]);
90+
t.deepEqual(alg([ [1,2,45], [1,5,45], [2,3,50], [3,4,45], [4,5,50], [1,6,30], [3,9,35], [4,8,26], [5,7,40], [9,10,5] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4, 10, 9 ]);
9091
},
9192

9293
test32_t_expand_leastslack : function(alg){
9394
// create blossom, relabel as T, expand such that a new least-slack S-to-free edge is produced, augment
94-
deepEqual(alg([ [1,2,45], [1,5,45], [2,3,50], [3,4,45], [4,5,50], [1,6,30], [3,9,35], [4,8,28], [5,7,26], [9,10,5] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4, 10, 9 ]);
95+
t.deepEqual(alg([ [1,2,45], [1,5,45], [2,3,50], [3,4,45], [4,5,50], [1,6,30], [3,9,35], [4,8,28], [5,7,26], [9,10,5] ]), [ -1, 6, 3, 2, 8, 7, 1, 5, 4, 10, 9 ]);
9596
},
9697

9798
test33_nest_tnasty_expand : function(alg){
9899
// create nested blossom, relabel as T in more than one way, expand outer blossom such that inner blossom ends up on an augmenting path
99-
deepEqual(alg([ [1,2,45], [1,7,45], [2,3,50], [3,4,45], [4,5,95], [4,6,94], [5,6,94], [6,7,50], [1,8,30], [3,11,35], [5,9,36], [7,10,26], [11,12,5] ]), [ -1, 8, 3, 2, 6, 9, 4, 10, 1, 5, 7, 12, 11 ]);
100+
t.deepEqual(alg([ [1,2,45], [1,7,45], [2,3,50], [3,4,45], [4,5,95], [4,6,94], [5,6,94], [6,7,50], [1,8,30], [3,11,35], [5,9,36], [7,10,26], [11,12,5] ]), [ -1, 8, 3, 2, 6, 9, 4, 10, 1, 5, 7, 12, 11 ]);
100101
},
101102

102103
test34_nest_relabel_expand : function(alg){
103104
// create nested S-blossom, relabel as S, expand recursively
104-
deepEqual(alg([ [1,2,40], [1,3,40], [2,3,60], [2,4,55], [3,5,55], [4,5,50], [1,8,15], [5,7,30], [7,6,10], [8,10,10], [4,9,30] ]), [ -1, 2, 1, 5, 9, 3, 7, 6, 10, 4, 8 ]);
105+
t.deepEqual(alg([ [1,2,40], [1,3,40], [2,3,60], [2,4,55], [3,5,55], [4,5,50], [1,8,15], [5,7,30], [7,6,10], [8,10,10], [4,9,30] ]), [ -1, 2, 1, 5, 9, 3, 7, 6, 10, 4, 8 ]);
105106
}
106107
};
107108

test/src/undirected/offline/algo/sp/dijkstra.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import test from 'ava';
12

2-
var one, binomialheap, functools;
33

4-
binomialheap = require( "@aureooms/js-binomial-heap" );
5-
functools = require( "@aureooms/js-functools" );
4+
import binomialheap from "@aureooms/js-binomial-heap" ;
5+
import functools from "@aureooms/js-functools" ;
66

7-
one = function ( label, n, s, edges, prev, dist ) {
7+
function one ( label, n, s, edges, prev, dist ) {
88

9-
test( "dijkstra #" + label, function () {
9+
test( "dijkstra #" + label, t => {
1010

1111
var Graph, PriorityQueue;
1212
var g, i, v, e, j, p, d, used, ref, left, predicate;
@@ -42,8 +42,8 @@ one = function ( label, n, s, edges, prev, dist ) {
4242

4343
gn.dijkstra( g, n, v[s], p, d, used, ref, left );
4444

45-
deepEqual( p, prev, "prev" );
46-
deepEqual( d, dist, "dist" );
45+
t.deepEqual( p, prev, "prev" );
46+
t.deepEqual( d, dist, "dist" );
4747

4848
});
4949

test/src/undirected/offline/algo/sp/floyd.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import test from 'ava';
12

2-
var one, binomialheap, functools;
33

4-
binomialheap = require( "@aureooms/js-binomial-heap" );
5-
functools = require( "@aureooms/js-functools" );
4+
import binomialheap from "@aureooms/js-binomial-heap" ;
5+
import functools from "@aureooms/js-functools" ;
66

7-
one = function ( label, n, edges ) {
7+
function one ( label, n, edges ) {
88

9-
test( "floyd #" + label, function () {
9+
test( "floyd #" + label, t => {
1010

1111
var prev, dist, used, ref, left, predicate;
1212

@@ -70,7 +70,7 @@ one = function ( label, n, edges ) {
7070
amat( g, n, d );
7171
floyd( n, d );
7272

73-
deepEqual( d, dist, "dist" );
73+
t.deepEqual( d, dist, "dist" );
7474

7575
});
7676

test/src/undirected/offline/algo/sp/sptreedfs.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import test from 'ava';
12

2-
var one, binomialheap, functools;
33

4-
binomialheap = require( "@aureooms/js-binomial-heap" );
5-
functools = require( "@aureooms/js-functools" );
4+
import binomialheap from "@aureooms/js-binomial-heap" ;
5+
import functools from "@aureooms/js-functools" ;
66

7-
one = function ( label, n, edges ) {
7+
function one ( label, n, edges ) {
88

9-
test( "sptreedfs #" + label, function () {
9+
test( "sptreedfs #" + label, t => {
1010

1111
var g, i, v, e, j, prev, dist, used, ref, left, predicate;
1212

@@ -78,7 +78,7 @@ one = function ( label, n, edges ) {
7878
sptreedfs( g, n, successors, d );
7979

8080

81-
deepEqual( successors, next, "next" );
81+
t.deepEqual( successors, next, "next" );
8282

8383
});
8484

test/src/undirected/offline/algo/util/copy.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import test from 'ava';
12

23
var check = function(label, n, edges){
34

4-
test('copy', function(){
5+
test( 'copy', t => {
56

67
var DGraph = gn.dense_graph_t();
78
var SGraph = gn.sparse_graph_t();
@@ -34,7 +35,7 @@ var check = function(label, n, edges){
3435
amat(G, n, dist_G);
3536
amat(H, n, dist_H);
3637

37-
deepEqual(dist_G, dist_H, 'H === copy(G)');
38+
t.deepEqual(dist_G, dist_H, 'H === copy(G)');
3839

3940

4041

@@ -61,7 +62,7 @@ var check = function(label, n, edges){
6162
amat(G, n, dist_G);
6263
amat(H, n, dist_H);
6364

64-
deepEqual(dist_G, dist_H, 'H === copy(G)');
65+
t.deepEqual(dist_G, dist_H, 'H === copy(G)');
6566

6667

6768
});

test/src/undirected/online/data/aeitr.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import test from 'ava';
12

23
var check = function(label, n, edges){
34

4-
test('aeitr', function(){
5+
test( 'aeitr', t => {
56

67
var DGraph = gn.dense_graph_t();
78
var SGraph = gn.sparse_graph_t();
@@ -49,7 +50,7 @@ var check = function(label, n, edges){
4950
G.aeitr(push_expected);
5051

5152

52-
deepEqual(seq[0], seq[1], 'sparse aeitr consistent');
53+
t.deepEqual(seq[0], seq[1], 'sparse aeitr consistent');
5354

5455

5556
e = undefined;
@@ -63,7 +64,7 @@ var check = function(label, n, edges){
6364
H.aeitr(push_expected);
6465

6566

66-
deepEqual(seq[0], seq[1], 'dense aeitr consistent');
67+
t.deepEqual(seq[0], seq[1], 'dense aeitr consistent');
6768

6869

6970
});

0 commit comments

Comments
 (0)