@@ -424,6 +424,174 @@ describe('MatrixLog', () => {
424
424
expect ( lines [ 10 ] ) . toBe ( '' ) ;
425
425
} ) ;
426
426
} ) ;
427
+ describe ( 'child points used more than once in matrix' , ( ) => {
428
+ it ( 'can track 2 points' , ( ) => {
429
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
430
+ matrixLog . at ( { x : 0 , y : 0 } )
431
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
432
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } ) ;
433
+
434
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
435
+ expect ( lines . length ) . toBe ( 7 ) ;
436
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
437
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
438
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [2][ ][ ][ ]' ) ;
439
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ]' ) ;
440
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
441
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
442
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
443
+ } ) ;
444
+ it ( 'can track 5 points' , ( ) => {
445
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
446
+ matrixLog . at ( { x : 0 , y : 0 } )
447
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
448
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
449
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
450
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
451
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } ) ;
452
+
453
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
454
+ expect ( lines . length ) . toBe ( 7 ) ;
455
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
456
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
457
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [5][ ][ ][ ]' ) ;
458
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ]' ) ;
459
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
460
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
461
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
462
+ } ) ;
463
+ it ( 'can track 9 points' , ( ) => {
464
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
465
+ matrixLog . at ( { x : 0 , y : 0 } )
466
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
467
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
468
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
469
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
470
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
471
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
472
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
473
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
474
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } ) ;
475
+
476
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
477
+ expect ( lines . length ) . toBe ( 7 ) ;
478
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
479
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
480
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [9][ ][ ][ ]' ) ;
481
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ]' ) ;
482
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
483
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
484
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
485
+ } ) ;
486
+ it ( 'can track for more than 9 points' , ( ) => {
487
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
488
+ matrixLog . at ( { x : 0 , y : 0 } )
489
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
490
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
491
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
492
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
493
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
494
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
495
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
496
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
497
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } )
498
+ . add ( { name : 'child-matrix' , x : 0 , y : 0 , width : 4 , height : 4 } ) ;
499
+
500
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
501
+ expect ( lines . length ) . toBe ( 7 ) ;
502
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
503
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
504
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [+][ ][ ][ ]' ) ;
505
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ]' ) ;
506
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
507
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ]' ) ;
508
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
509
+ } ) ;
510
+ } ) ;
511
+ describe ( 'child points used more than once out of matrix' , ( ) => {
512
+ it ( 'can track 2 points' , ( ) => {
513
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
514
+ matrixLog . at ( { x : 0 , y : 0 } )
515
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
516
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } ) ;
517
+
518
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
519
+ expect ( lines . length ) . toBe ( 7 ) ;
520
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
521
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
522
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [ ][ ][ ][ ] 2 ' ) ;
523
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ] - ' ) ;
524
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
525
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
526
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
527
+ } ) ;
528
+ it ( 'can track 5 points' , ( ) => {
529
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
530
+ matrixLog . at ( { x : 0 , y : 0 } )
531
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
532
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
533
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
534
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
535
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } ) ;
536
+
537
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
538
+ expect ( lines . length ) . toBe ( 7 ) ;
539
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
540
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
541
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [ ][ ][ ][ ] 5 ' ) ;
542
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ] - ' ) ;
543
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
544
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
545
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
546
+ } ) ;
547
+ it ( 'can track 9 points' , ( ) => {
548
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
549
+ matrixLog . at ( { x : 0 , y : 0 } )
550
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
551
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
552
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
553
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
554
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
555
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
556
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
557
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
558
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } ) ;
559
+
560
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
561
+ expect ( lines . length ) . toBe ( 7 ) ;
562
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
563
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
564
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [ ][ ][ ][ ] 9 ' ) ;
565
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ] - ' ) ;
566
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
567
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
568
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
569
+ } ) ;
570
+ it ( 'can track for more than 9 points' , ( ) => {
571
+ const matrixLog = new MatrixLog ( 'test-matrix' , 2 , 2 ) ;
572
+ matrixLog . at ( { x : 0 , y : 0 } )
573
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
574
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
575
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
576
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
577
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
578
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
579
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
580
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
581
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } )
582
+ . add ( { name : 'child-matrix' , x : 4 , y : 0 , width : 4 , height : 4 } ) ;
583
+
584
+ const lines = matrixLog . toString ( 'child-matrix' ) . split ( / \n / ) ;
585
+ expect ( lines . length ) . toBe ( 7 ) ;
586
+ expect ( lines [ 0 ] ) . toBe ( 'test-matrix x=0,y=0 child-matrix' ) ;
587
+ expect ( lines [ 1 ] ) . toBe ( 'width=2,height=2 width=4,height=4' ) ;
588
+ expect ( lines [ 2 ] ) . toBe ( '[*][ ] [ ][ ][ ][ ] + ' ) ;
589
+ expect ( lines [ 3 ] ) . toBe ( '[ ][ ] [ ][ ][ ][ ] - ' ) ;
590
+ expect ( lines [ 4 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
591
+ expect ( lines [ 5 ] ) . toBe ( ' [ ][ ][ ][ ] - ' ) ;
592
+ expect ( lines [ 6 ] ) . toBe ( '' ) ;
593
+ } ) ;
594
+ } ) ;
427
595
} ) ;
428
596
} ) ;
429
597
describe ( '3d mode' , ( ) => {
0 commit comments