comparison src/testdir/test_vim9_script.vim @ 19593:043989a2f449 v8.2.0353

patch 8.2.0353: Vim9: while loop not tested Commit: https://github.com/vim/vim/commit/d0df1aacd81000d95815bea397257d8dc0d2c72d Author: Bram Moolenaar <Bram@vim.org> Date: Wed Mar 4 21:50:46 2020 +0100 patch 8.2.0353: Vim9: while loop not tested Problem: Vim9: while loop not tested. Solution: Add test with "while", "break" and "continue"
author Bram Moolenaar <Bram@vim.org>
date Wed, 04 Mar 2020 22:00:04 +0100
parents 0303f920a7d4
children 2fee087c94cb
comparison
equal deleted inserted replaced
19592:5dc5f9bacd60 19593:043989a2f449
851 writefile(lines, 'XToDelFunc') 851 writefile(lines, 'XToDelFunc')
852 assert_fails('so XToDelFunc', 'E933') 852 assert_fails('so XToDelFunc', 'E933')
853 assert_fails('so XToDelFunc', 'E933') 853 assert_fails('so XToDelFunc', 'E933')
854 854
855 delete('XToDelFunc') 855 delete('XToDelFunc')
856 enddef
857
858 def Test_substitute_cmd()
859 new
860 setline(1, 'something')
861 :substitute(some(other(
862 assert_equal('otherthing', getline(1))
863 bwipe!
864
865 " also when the context is Vim9 script
866 let lines =<< trim END
867 vim9script
868 new
869 setline(1, 'something')
870 :substitute(some(other(
871 assert_equal('otherthing', getline(1))
872 bwipe!
873 END
874 writefile(lines, 'Xvim9lines')
875 source Xvim9lines
876
877 delete('Xvim9lines')
878 enddef 856 enddef
879 857
880 def Test_execute_cmd() 858 def Test_execute_cmd()
881 new 859 new
882 setline(1, 'default') 860 setline(1, 'default')
918 writefile(lines, 'Xvim9for.vim') 896 writefile(lines, 'Xvim9for.vim')
919 source Xvim9for.vim 897 source Xvim9for.vim
920 delete('Xvim9for.vim') 898 delete('Xvim9for.vim')
921 enddef 899 enddef
922 900
901 def Test_while_loop()
902 let result = ''
903 let cnt = 0
904 while cnt < 555
905 if cnt == 3
906 break
907 endif
908 cnt += 1
909 if cnt == 2
910 continue
911 endif
912 result ..= cnt .. '_'
913 endwhile
914 assert_equal('1_3_', result)
915 enddef
916
917 def Test_substitute_cmd()
918 new
919 setline(1, 'something')
920 :substitute(some(other(
921 assert_equal('otherthing', getline(1))
922 bwipe!
923
924 " also when the context is Vim9 script
925 let lines =<< trim END
926 vim9script
927 new
928 setline(1, 'something')
929 :substitute(some(other(
930 assert_equal('otherthing', getline(1))
931 bwipe!
932 END
933 writefile(lines, 'Xvim9lines')
934 source Xvim9lines
935
936 delete('Xvim9lines')
937 enddef
938
923 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 939 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker