comparison src/testdir/test_vim9_disassemble.vim @ 24220:a7a9176bb542 v8.2.2651

patch 8.2.2651: Vim9: restoring command modifiers happens after jump Commit: https://github.com/vim/vim/commit/a91a71322dc2e6a1640e73b6da1f1a2f94f39a54 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 25 21:12:15 2021 +0100 patch 8.2.2651: Vim9: restoring command modifiers happens after jump Problem: Vim9: restoring command modifiers happens after jump. Solution: Move the restore instruction to before the jump. (closes https://github.com/vim/vim/issues/8006) Also handle for and while.
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Mar 2021 21:15:04 +0100
parents c308076e225e
children a2e6029d354e
comparison
equal deleted inserted replaced
24219:529521098193 24220:a7a9176bb542
1894 'silent! echoerr "error"\_s*' .. 1894 'silent! echoerr "error"\_s*' ..
1895 '\d CMDMOD silent!\_s*' .. 1895 '\d CMDMOD silent!\_s*' ..
1896 '\d PUSHS "error"\_s*' .. 1896 '\d PUSHS "error"\_s*' ..
1897 '\d ECHOERR 1\_s*' .. 1897 '\d ECHOERR 1\_s*' ..
1898 '\d CMDMOD_REV\_s*' .. 1898 '\d CMDMOD_REV\_s*' ..
1899 '\d RETURN 0', 1899 '\d\+ RETURN 0',
1900 res)
1901 enddef
1902
1903 def s:SilentIf()
1904 silent if 4 == g:five
1905 silent elseif 4 == g:five
1906 silent endif
1907 enddef
1908
1909 def Test_silent_if()
1910 var res = execute('disass s:SilentIf')
1911 assert_match('<SNR>\d*_SilentIf\_s*' ..
1912 'silent if 4 == g:five\_s*' ..
1913 '\d\+ CMDMOD silent\_s*' ..
1914 '\d\+ PUSHNR 4\_s*' ..
1915 '\d\+ LOADG g:five\_s*' ..
1916 '\d\+ COMPAREANY ==\_s*' ..
1917 '\d\+ CMDMOD_REV\_s*' ..
1918 '\d\+ JUMP_IF_FALSE -> \d\+\_s*' ..
1919 'silent elseif 4 == g:five\_s*' ..
1920 '\d\+ JUMP -> \d\+\_s*' ..
1921 '\d\+ CMDMOD silent\_s*' ..
1922 '\d\+ PUSHNR 4\_s*' ..
1923 '\d\+ LOADG g:five\_s*' ..
1924 '\d\+ COMPAREANY ==\_s*' ..
1925 '\d\+ CMDMOD_REV\_s*' ..
1926 '\d\+ JUMP_IF_FALSE -> \d\+\_s*' ..
1927 'silent endif\_s*' ..
1928 '\d\+ RETURN 0',
1929 res)
1930 enddef
1931
1932 def s:SilentFor()
1933 silent for i in [0]
1934 silent endfor
1935 enddef
1936
1937 def Test_silent_for()
1938 var res = execute('disass s:SilentFor')
1939 assert_match('<SNR>\d*_SilentFor\_s*' ..
1940 'silent for i in \[0\]\_s*' ..
1941 '\d CMDMOD silent\_s*' ..
1942 '\d STORE -1 in $0\_s*' ..
1943 '\d PUSHNR 0\_s*' ..
1944 '\d NEWLIST size 1\_s*' ..
1945 '\d CMDMOD_REV\_s*' ..
1946 '5 FOR $0 -> 8\_s*' ..
1947 '\d STORE $1\_s*' ..
1948 'silent endfor\_s*' ..
1949 '\d JUMP -> 5\_s*' ..
1950 '8 DROP\_s*' ..
1951 '\d RETURN 0\_s*',
1952 res)
1953 enddef
1954
1955 def s:SilentWhile()
1956 silent while g:not
1957 silent endwhile
1958 enddef
1959
1960 def Test_silent_while()
1961 var res = execute('disass s:SilentWhile')
1962 assert_match('<SNR>\d*_SilentWhile\_s*' ..
1963 'silent while g:not\_s*' ..
1964 '0 CMDMOD silent\_s*' ..
1965 '\d LOADG g:not\_s*' ..
1966 '\d COND2BOOL\_s*' ..
1967 '\d CMDMOD_REV\_s*' ..
1968 '\d JUMP_IF_FALSE -> 6\_s*' ..
1969
1970 'silent endwhile\_s*' ..
1971 '\d JUMP -> 0\_s*' ..
1972 '6 RETURN 0\_s*',
1973 res)
1974 enddef
1975
1976 def s:SilentReturn(): string
1977 silent return "done"
1978 enddef
1979
1980 def Test_silent_return()
1981 var res = execute('disass s:SilentReturn')
1982 assert_match('<SNR>\d*_SilentReturn\_s*' ..
1983 'silent return "done"\_s*' ..
1984 '\d CMDMOD silent\_s*' ..
1985 '\d PUSHS "done"\_s*' ..
1986 '\d CMDMOD_REV\_s*' ..
1987 '\d RETURN',
1900 res) 1988 res)
1901 enddef 1989 enddef
1902 1990
1903 def s:Profiled(): string 1991 def s:Profiled(): string
1904 echo "profiled" 1992 echo "profiled"
1922 '\d RETURN\_s*' .. 2010 '\d RETURN\_s*' ..
1923 '\d PROFILE END', 2011 '\d PROFILE END',
1924 res) 2012 res)
1925 enddef 2013 enddef
1926 2014
1927 def s:SilentReturn(): string
1928 silent return "done"
1929 enddef
1930
1931 def Test_silent_return()
1932 var res = execute('disass s:SilentReturn')
1933 assert_match('<SNR>\d*_SilentReturn\_s*' ..
1934 'silent return "done"\_s*' ..
1935 '\d CMDMOD silent\_s*' ..
1936 '\d PUSHS "done"\_s*' ..
1937 '\d CMDMOD_REV\_s*' ..
1938 '\d RETURN',
1939 res)
1940 enddef
1941 2015
1942 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker 2016 " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker