@@ -438,199 +438,4 @@ describe("Snippet Body Parser", () => {
438
438
] ) ;
439
439
} ) ;
440
440
} ) ;
441
-
442
- describe ( "examples" , ( ) => {
443
- it ( "breaks a snippet body into lines, with each line containing tab stops at the appropriate position" , ( ) => {
444
- expectMatch ( "the quick brown $1fox ${2:jumped ${3:over}\n}the ${4:lazy} dog" , [
445
- "the quick brown " ,
446
- { index : 1 } ,
447
- "fox " ,
448
- {
449
- index : 2 ,
450
- content : [
451
- "jumped " ,
452
- { index : 3 , content : [ "over" ] } ,
453
- "\n"
454
- ] ,
455
- } ,
456
- "the " ,
457
- { index : 4 , content : [ "lazy" ] } ,
458
- " dog"
459
- ] ) ;
460
- } ) ;
461
-
462
- it ( "supports interpolated variables in placeholder text" , ( ) => {
463
- expectMatch ( "module ${1:ActiveRecord::${TM_FILENAME/(?:\\A|_)([A-Za-z0-9]+)(?:\\.rb)?/(?2::\\u$1)/g}}" , [
464
- "module " ,
465
- {
466
- index : 1 ,
467
- content : [
468
- "ActiveRecord::" ,
469
- {
470
- variable : "TM_FILENAME" ,
471
- transformation : {
472
- find : / (?: \A | _ ) ( [ A - Z a - z 0 - 9 ] + ) (?: \. r b ) ? / g,
473
- replace : [
474
- "(?2::" ,
475
- {
476
- modifier : "u" ,
477
- } ,
478
- {
479
- backreference : 1 ,
480
- } ,
481
- ")" ,
482
- ]
483
- }
484
- }
485
- ] ,
486
- }
487
- ] ) ;
488
- } ) ;
489
-
490
- it ( "parses a snippet with transformations" , ( ) => {
491
- expectMatch ( "<${1:p}>$0</${1/f/F/}>" , [
492
- '<' ,
493
- { index : 1 , content : [ 'p' ] } ,
494
- '>' ,
495
- { index : 0 } ,
496
- '</' ,
497
- { index : 1 , transformation : { find : / f / , replace : [ 'F' ] } } ,
498
- '>' ,
499
- ] ) ;
500
- } ) ;
501
-
502
- it ( "parses a snippet with multiple tab stops with transformations" , ( ) => {
503
- expectMatch ( "${1:placeholder} ${1/(.)/\\u$1/} $1 ${2:ANOTHER} ${2/^(.*)$/\\L$1/} $2" , [
504
- { index : 1 , content : [ 'placeholder' ] } ,
505
- ' ' ,
506
- {
507
- index : 1 ,
508
- transformation : {
509
- find : / ( .) / ,
510
- replace : [
511
- { modifier : 'u' } ,
512
- { backreference : 1 } ,
513
- ] ,
514
- } ,
515
- } ,
516
- ' ' ,
517
- { index : 1 } ,
518
- ' ' ,
519
- { index : 2 , content : [ 'ANOTHER' ] } ,
520
- ' ' ,
521
- {
522
- index : 2 ,
523
- transformation : {
524
- find : / ^ ( .* ) $ / ,
525
- replace : [
526
- { modifier : 'L' } ,
527
- { backreference : 1 } ,
528
- ] ,
529
- } ,
530
- } ,
531
- ' ' ,
532
- { index : 2 } ,
533
- ] ) ;
534
- } ) ;
535
-
536
- it ( "parses a snippet with transformations and mirrors" , ( ) => {
537
- expectMatch ( "${1:placeholder}\n${1/(.)/\\u$1/}\n$1" , [
538
- { index : 1 , content : [ 'placeholder' ] } ,
539
- '\n' ,
540
- {
541
- index : 1 ,
542
- transformation : {
543
- find : / ( .) / ,
544
- replace : [
545
- { modifier : 'u' } ,
546
- { backreference : 1 } ,
547
- ] ,
548
- } ,
549
- } ,
550
- '\n' ,
551
- { index : 1 } ,
552
- ] ) ;
553
- } ) ;
554
-
555
- it ( "parses a snippet with a format string and case-control flags" , ( ) => {
556
- expectMatch ( "<${1:p}>$0</${1/(.)(.*)/\\u$1$2/}>" , [
557
- '<' ,
558
- { index : 1 , content : [ 'p' ] } ,
559
- '>' ,
560
- { index : 0 } ,
561
- '</' ,
562
- {
563
- index : 1 ,
564
- transformation : {
565
- find : / ( .) ( .* ) / ,
566
- replace : [
567
- { modifier : 'u' } ,
568
- { backreference : 1 } ,
569
- { backreference : 2 } ,
570
- ] ,
571
- } ,
572
- } ,
573
- '>' ,
574
- ] ) ;
575
- } ) ;
576
-
577
- it ( "parses a snippet with an escaped forward slash in a transform" , ( ) => {
578
- expectMatch ( "<${1:p}>$0</${1/(.)\\/(.*)/\\u$1$2/}>" , [
579
- '<' ,
580
- { index : 1 , content : [ 'p' ] } ,
581
- '>' ,
582
- { index : 0 } ,
583
- '</' ,
584
- {
585
- index : 1 ,
586
- transformation : {
587
- find : / ( .) \/ ( .* ) / ,
588
- replace : [
589
- { modifier : 'u' } ,
590
- { backreference : 1 } ,
591
- { backreference : 2 } ,
592
- ] ,
593
- } ,
594
- } ,
595
- '>' ,
596
- ] ) ;
597
- } ) ;
598
-
599
- it ( "parses a snippet with a placeholder that mirrors another tab stop's content" , ( ) => {
600
- expectMatch ( "$4console.${3:log}('${2:$1}', $1);$0" , [
601
- { index : 4 } ,
602
- 'console.' ,
603
- { index : 3 , content : [ 'log' ] } ,
604
- '(\'' ,
605
- {
606
- index : 2 , content : [
607
- { index : 1 }
608
- ]
609
- } ,
610
- '\', ' ,
611
- { index : 1 } ,
612
- ');' ,
613
- { index : 0 }
614
- ] ) ;
615
- } ) ;
616
-
617
- it ( "parses a snippet with a placeholder that mixes text and tab stop references" , ( ) => {
618
- expectMatch ( "$4console.${3:log}('${2:uh $1}', $1);$0" , [
619
- { index : 4 } ,
620
- 'console.' ,
621
- { index : 3 , content : [ 'log' ] } ,
622
- '(\'' ,
623
- {
624
- index : 2 , content : [
625
- 'uh ' ,
626
- { index : 1 }
627
- ]
628
- } ,
629
- '\', ' ,
630
- { index : 1 } ,
631
- ');' ,
632
- { index : 0 }
633
- ] ) ;
634
- } ) ;
635
- } ) ;
636
441
} ) ;
0 commit comments