@@ -160,32 +160,27 @@ describe('transform()', () => {
160160 expect ( op4 ) . toStrictEqual ( [ 2 , - 1 ] ) ;
161161 } ) ;
162162
163- // type TestCase = [name: string, str: string, op1: StringTypeOp, op2: StringTypeOp, expected: string, only?: boolean];
164-
165- // const testCases: TestCase[] = [
166- // ['insert-insert', 'abc', [1, 'a'], [1, 'b'], 'ababc'],
167- // ['insert-delete', 'abc', [1, 'a'], [1, -1], 'abc'],
168- // ['insert-delete-2', 'abc', [1, 'a'], [2, -1], 'aac'],
169- // ['insert in previous insert', 'aabb', [2, '1111'], [4, '22'], 'aa112211bb'],
170- // ['fuzzer bug #1', 'd6', [' }B'], [[' }'], ';0q', 2, ['6']], ';0qBd'],
171- // ['fuzzer bug #2', 'Ai', [['A'], '#', -1], [-1], ''],
172- // ['fuzzer bug #3', 'M }', ['!y1'], ["'/*s", 2, ',/@', -2, [' }']], "'/*s!y,/@"],
173- // ['fuzzer bug #4', '8sL', [-2, 'w', ['L']], [['w']], ''],
174- // ['fuzzer bug #5', '%V=', [2, ';'], ['3O"', 1, 'J', -2], '3O"%J='],
175- // ];
176-
177- // describe('can compose', () => {
178- // for (const [name, str, op1, op2, expected, only] of testCases) {
179- // (only ? test.only : test)(`${name}`, () => {
180- // const res1 = apply(apply(str, op1), op2);
181- // // console.log('res1', res1);
182- // const op3 = compose(op1, op2);
183- // // console.log('op3', op3);
184- // const res2 = apply(str, op3);
185- // // console.log('res2', res2);
186- // expect(res2).toStrictEqual(res1);
187- // expect(res2).toStrictEqual(expected);
188- // });
189- // }
190- // });
163+ type TestCase = [ name : string , str : string , op1 : StringTypeOp , op2 : StringTypeOp , expected : string , only ?: boolean ] ;
164+
165+ const testCases : TestCase [ ] = [
166+ [ 'delete-delete' , 'abc' , [ 1 , - 1 ] , [ 2 , - 1 ] , 'a' ] ,
167+ [ 'insert-insert' , '12345' , [ 1 , 'one' , 2 , 'three' ] , [ 2 , 'two' , 2 , 'four' ] , '1one2two3three4four5' ] ,
168+ ] ;
169+
170+ describe ( 'can transform' , ( ) => {
171+ for ( const [ name , str , op1 , op2 , expected , only ] of testCases ) {
172+ ( only ? test . only : test ) ( `${ name } ` , ( ) => {
173+ const op11 = transform ( op1 , op2 , true ) ;
174+ const op22 = transform ( op2 , op1 , false ) ;
175+ const res1 = apply ( apply ( str , op1 ) , op22 ) ;
176+ const res2 = apply ( apply ( str , op2 ) , op11 ) ;
177+ // console.log('op11', op11);
178+ // console.log('op22', op22);
179+ // console.log('res1', res1);
180+ // console.log('res2', res2);
181+ expect ( res2 ) . toStrictEqual ( res1 ) ;
182+ expect ( res2 ) . toStrictEqual ( expected ) ;
183+ } ) ;
184+ }
185+ } ) ;
191186} ) ;
0 commit comments