@@ -6,9 +6,13 @@ import { list , range , sorted , head , iter , exhaust } from '@aureooms/js-iter
6
6
7
7
import { randint , shuffle } from '@aureooms/js-random' ;
8
8
9
- import { RedBlackTree , debug } from '../../../src' ;
9
+ import { RedBlackTree , _debug } from '../../../src' ;
10
10
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} ) ;
12
16
13
17
test ( 'RedBlackTree::remove' , t => {
14
18
@@ -72,15 +76,15 @@ test( 'delete root with right child' , t => {
72
76
tree . add ( 0 ) ;
73
77
tree . add ( 1 ) ;
74
78
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' ) } ))` ;
76
80
77
81
t . deepEqual ( debug ( tree . root ) , repr1 , 'debug string 1 is correct' ) ;
78
82
79
83
tree . remove ( 0 ) ;
80
84
81
85
t . deepEqual ( list ( tree ) , [ 1 ] ) ;
82
86
83
- const repr2 = `(${ chalk . bgBlack ( 'L' ) } , ${ chalk . bgBlack ( 1 ) } , ${ chalk . bgBlack ( 'L' ) } )` ;
87
+ const repr2 = `(${ black ( 'L' ) } , ${ black ( 1 ) } , ${ black ( 'L' ) } )` ;
84
88
85
89
t . deepEqual ( debug ( tree . root ) , repr2 , 'debug string 2 is correct' ) ;
86
90
@@ -93,15 +97,15 @@ test( 'delete root with left child' , t => {
93
97
tree . add ( 0 ) ;
94
98
tree . add ( - 1 ) ;
95
99
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' ) } )` ;
97
101
98
102
t . deepEqual ( debug ( tree . root ) , repr1 , 'debug string 1 is correct' ) ;
99
103
100
104
tree . remove ( 0 ) ;
101
105
102
106
t . deepEqual ( list ( tree ) , [ - 1 ] ) ;
103
107
104
- const repr2 = `(${ chalk . bgBlack ( 'L' ) } , ${ chalk . bgBlack ( - 1 ) } , ${ chalk . bgBlack ( 'L' ) } )` ;
108
+ const repr2 = `(${ black ( 'L' ) } , ${ black ( - 1 ) } , ${ black ( 'L' ) } )` ;
105
109
106
110
t . deepEqual ( debug ( tree . root ) , repr2 , 'debug string 2 is correct' ) ;
107
111
0 commit comments