comparison src/testdir/test_textformat.vim @ 18906:bb87c5c1e29b v8.2.0014

patch 8.2.0014: test69 and test95 are old style Commit: https://github.com/vim/vim/commit/afc13bd8271819c7871ff2ae2cfebb22190a0d39 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Dec 16 22:43:31 2019 +0100 patch 8.2.0014: test69 and test95 are old style Problem: Test69 and test95 are old style. Solution: Convert to new style tests. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5365)
author Bram Moolenaar <Bram@vim.org>
date Mon, 16 Dec 2019 22:45:04 +0100
parents 50c0a9fb07ae
children e8fe65da4198
comparison
equal deleted inserted replaced
18905:c1b0da0ac838 18906:bb87c5c1e29b
507 augroup testing 507 augroup testing
508 au! 508 au!
509 augroup END 509 augroup END
510 augroup! testing 510 augroup! testing
511 endfunc 511 endfunc
512
513 " Test for formatting multi-byte text with 'fo=t'
514 func Test_tw_2_fo_t()
515 new
516 let t =<< trim END
517 {
518 XYZ
519 abc XYZ
520 }
521 END
522 call setline(1, t)
523 call cursor(2, 1)
524
525 set tw=2 fo=t
526 let t =<< trim END
527 XYZ
528 abc XYZ
529 END
530 exe "normal gqgqjgqgq"
531 exe "normal o\n" . join(t, "\n")
532
533 let expected =<< trim END
534 {
535 XYZ
536 abc
537 XYZ
538
539 XYZ
540 abc
541 XYZ
542 }
543 END
544 call assert_equal(expected, getline(1, '$'))
545
546 set tw& fo&
547 bwipe!
548 endfunc
549
550 " Test for formatting multi-byte text with 'fo=tm' and 'tw=1'
551 func Test_tw_1_fo_tm()
552 new
553 let t =<< trim END
554 {
555
556 Xa
557 X a
558 XY
559 X Y
560 }
561 END
562 call setline(1, t)
563 call cursor(2, 1)
564
565 set tw=1 fo=tm
566 let t =<< trim END
567
568 Xa
569 X a
570 XY
571 X Y
572 END
573 exe "normal gqgqjgqgqjgqgqjgqgqjgqgq"
574 exe "normal o\n" . join(t, "\n")
575
576 let expected =<< trim END
577 {
578
579
580 a
581
582 a
583
584
585
586
587
588
589
590 a
591
592 a
593
594
595
596
597 }
598 END
599 call assert_equal(expected, getline(1, '$'))
600
601 set tw& fo&
602 bwipe!
603 endfunc
604
605 " Test for formatting multi-byte text with 'fo=tm' and 'tw=2'
606 func Test_tw_2_fo_tm()
607 new
608 let t =<< trim END
609 {
610
611 Xa
612 X a
613 XY
614 X Y
615 aX
616 abX
617 abcX
618 abX c
619 abXY
620 }
621 END
622 call setline(1, t)
623 call cursor(2, 1)
624
625 set tw=2 fo=tm
626 let t =<< trim END
627
628 Xa
629 X a
630 XY
631 X Y
632 aX
633 abX
634 abcX
635 abX c
636 abXY
637 END
638 exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
639 exe "normal o\n" . join(t, "\n")
640
641 let expected =<< trim END
642 {
643
644
645 a
646
647 a
648
649
650
651
652 a
653
654 ab
655
656 abc
657
658 ab
659
660 c
661 ab
662
663
664
665
666
667 a
668
669 a
670
671
672
673
674 a
675
676 ab
677
678 abc
679
680 ab
681
682 c
683 ab
684
685
686 }
687 END
688 call assert_equal(expected, getline(1, '$'))
689
690 set tw& fo&
691 bwipe!
692 endfunc
693
694 " Test for formatting multi-byte text with 'fo=tm', 'tw=2' and 'autoindent'.
695 func Test_tw_2_fo_tm_ai()
696 new
697 let t =<< trim END
698 {
699
700 Xa
701 }
702 END
703 call setline(1, t)
704 call cursor(2, 1)
705
706 set ai tw=2 fo=tm
707 let t =<< trim END
708
709 Xa
710 END
711 exe "normal gqgqjgqgq"
712 exe "normal o\n" . join(t, "\n")
713
714 let expected =<< trim END
715 {
716
717
718 a
719
720
721
722 a
723 }
724 END
725 call assert_equal(expected, getline(1, '$'))
726
727 set tw& fo& ai&
728 bwipe!
729 endfunc
730
731 " Test for formatting multi-byte text with 'fo=tm', 'tw=2' and 'noai'.
732 func Test_tw_2_fo_tm_noai()
733 new
734 let t =<< trim END
735 {
736
737 Xa
738 }
739 END
740 call setline(1, t)
741 call cursor(2, 1)
742
743 set noai tw=2 fo=tm
744 exe "normal gqgqjgqgqo\n X\n Xa"
745
746 let expected =<< trim END
747 {
748
749
750 a
751
752
753
754 a
755 }
756 END
757 call assert_equal(expected, getline(1, '$'))
758
759 set tw& fo& ai&
760 bwipe!
761 endfunc
762
763 func Test_tw_2_fo_cqm_com()
764 new
765 let t =<< trim END
766 {
767
768 Xa
769 XaY
770 XY
771 XYZ
772 X Y
773 X YZ
774 XX
775 XXa
776 XXY
777 }
778 END
779 call setline(1, t)
780 call cursor(2, 1)
781
782 set tw=2 fo=cqm comments=n:X
783 exe "normal gqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgqjgqgq"
784 let t =<< trim END
785
786 Xa
787 XaY
788 XY
789 XYZ
790 X Y
791 X YZ
792 XX
793 XXa
794 XXY
795 END
796 exe "normal o\n" . join(t, "\n")
797
798 let expected =<< trim END
799 {
800
801 Xa
802 Xa
803 XY
804 XY
805 XY
806 XZ
807 X Y
808 X Y
809 X Z
810 XX
811 XXa
812 XXY
813
814
815 Xa
816 Xa
817 XY
818 XY
819 XY
820 XZ
821 X Y
822 X Y
823 X Z
824 XX
825 XXa
826 XXY
827 }
828 END
829 call assert_equal(expected, getline(1, '$'))
830
831 set tw& fo& comments&
832 bwipe!
833 endfunc
834
835 func Test_tw_2_fo_tm_replace()
836 new
837 let t =<< trim END
838 {
839
840 }
841 END
842 call setline(1, t)
843 call cursor(2, 1)
844
845 set tw=2 fo=tm
846 exe "normal RXa"
847
848 let expected =<< trim END
849 {
850
851 a
852 }
853 END
854 call assert_equal(expected, getline(1, '$'))
855
856 set tw& fo&
857 bwipe!
858 endfunc
859
860 " Test for 'matchpairs' with multibyte chars
861 func Test_mps()
862 new
863 let t =<< trim END
864 {
865 ‘ two three ’ four
866 }
867 END
868 call setline(1, t)
869 call cursor(2, 1)
870
871 exe "set mps+=\u2018:\u2019"
872 normal d%
873
874 let expected =<< trim END
875 {
876 four
877 }
878 END
879 call assert_equal(expected, getline(1, '$'))
880
881 set mps&
882 bwipe!
883 endfunc
884
885 " Test for ra on multi-byte characters
886 func Test_ra_multibyte()
887 new
888 let t =<< trim END
889 ra test
890 abba
891 aab
892 END
893 call setline(1, t)
894 call cursor(1, 1)
895
896 normal jVjra
897
898 let expected =<< trim END
899 ra test
900 aaaa
901 aaa
902 END
903 call assert_equal(expected, getline(1, '$'))
904
905 bwipe!
906 endfunc
907
908 " Test for 'whichwrap' with multi-byte character
909 func Test_whichwrap()
910 new
911 let t =<< trim END
912 á
913 x
914 END
915 call setline(1, t)
916 call cursor(2, 1)
917
918 set whichwrap+=h
919 normal dh
920 set whichwrap-=h
921
922 let expected =<< trim END
923 áx
924 END
925 call assert_equal(expected, getline(1, '$'))
926
927 bwipe!
928 endfunc
929
930 func Test_substitute()
931 call assert_equal('a1a2a3a', substitute('123', '\zs', 'a', 'g'))
932 endfunc
933
934 " vim: shiftwidth=2 sts=2 expandtab