@@ -6,9 +6,13 @@ import { list , range , sorted , head , iter , exhaust } from '@aureooms/js-iter
66
77import { randint , shuffle } from '@aureooms/js-random' ;
88
9- import { RedBlackTree , debug } from '../../../src' ;
9+ import { RedBlackTree , _debug } from '../../../src' ;
1010
11- import chalk from 'chalk' ;
11+ import { bgRed , bgBlack } from 'chalk' ;
12+
13+ const red = bgRed ;
14+ const black = bgBlack ;
15+ const debug = _debug ( { red, black} ) ;
1216
1317test ( 'RedBlackTree::remove' , t => {
1418
@@ -72,15 +76,15 @@ test( 'delete root with right child' , t => {
7276 tree . add ( 0 ) ;
7377 tree . add ( 1 ) ;
7478
75- const repr1 = `(${ chalk . bgBlack ( 'L' ) } , ${ chalk . bgBlack ( 0 ) } , (${ chalk . bgBlack ( 'L' ) } , ${ chalk . bgRed ( 1 ) } , ${ chalk . bgBlack ( 'L' ) } ))` ;
79+ const repr1 = `(${ black ( 'L' ) } , ${ black ( 0 ) } , (${ black ( 'L' ) } , ${ red ( 1 ) } , ${ black ( 'L' ) } ))` ;
7680
7781 t . deepEqual ( debug ( tree . root ) , repr1 , 'debug string 1 is correct' ) ;
7882
7983 tree . remove ( 0 ) ;
8084
8185 t . deepEqual ( list ( tree ) , [ 1 ] ) ;
8286
83- const repr2 = `(${ chalk . bgBlack ( 'L' ) } , ${ chalk . bgBlack ( 1 ) } , ${ chalk . bgBlack ( 'L' ) } )` ;
87+ const repr2 = `(${ black ( 'L' ) } , ${ black ( 1 ) } , ${ black ( 'L' ) } )` ;
8488
8589 t . deepEqual ( debug ( tree . root ) , repr2 , 'debug string 2 is correct' ) ;
8690
@@ -93,15 +97,15 @@ test( 'delete root with left child' , t => {
9397 tree . add ( 0 ) ;
9498 tree . add ( - 1 ) ;
9599
96- const repr1 = `((${ chalk . bgBlack ( 'L' ) } , ${ chalk . bgRed ( - 1 ) } , ${ chalk . bgBlack ( 'L' ) } ), ${ chalk . bgBlack ( 0 ) } , ${ chalk . bgBlack ( 'L' ) } )` ;
100+ const repr1 = `((${ black ( 'L' ) } , ${ red ( - 1 ) } , ${ black ( 'L' ) } ), ${ black ( 0 ) } , ${ black ( 'L' ) } )` ;
97101
98102 t . deepEqual ( debug ( tree . root ) , repr1 , 'debug string 1 is correct' ) ;
99103
100104 tree . remove ( 0 ) ;
101105
102106 t . deepEqual ( list ( tree ) , [ - 1 ] ) ;
103107
104- const repr2 = `(${ chalk . bgBlack ( 'L' ) } , ${ chalk . bgBlack ( - 1 ) } , ${ chalk . bgBlack ( 'L' ) } )` ;
108+ const repr2 = `(${ black ( 'L' ) } , ${ black ( - 1 ) } , ${ black ( 'L' ) } )` ;
105109
106110 t . deepEqual ( debug ( tree . root ) , repr2 , 'debug string 2 is correct' ) ;
107111
0 commit comments