comparison src/testdir/test_functions.vim @ 30226:b6b803ed4a53 v9.0.0449

patch 9.0.0449: there is no easy way to translate a key code into a string Commit: https://github.com/vim/vim/commit/cdc839353f68ca43db6446e1b727fc7ba657b738 Author: zeertzjq <zeertzjq@outlook.com> Date: Mon Sep 12 13:38:41 2022 +0100 patch 9.0.0449: there is no easy way to translate a key code into a string Problem: There is no easy way to translate a string with a key code into a readable string. Solution: Add the keytrans() function. (closes #11114)
author Bram Moolenaar <Bram@vim.org>
date Mon, 12 Sep 2022 14:45:04 +0200
parents 13b02c1ea0f7
children 029c59bf78f1
comparison
equal deleted inserted replaced
30225:51f58c2d23fa 30226:b6b803ed4a53
2762 " Test for the eval() function 2762 " Test for the eval() function
2763 func Test_eval() 2763 func Test_eval()
2764 call assert_fails("call eval('5 a')", 'E488:') 2764 call assert_fails("call eval('5 a')", 'E488:')
2765 endfunc 2765 endfunc
2766 2766
2767 " Test for the keytrans() function
2768 func Test_keytrans()
2769 call assert_equal('<Space>', keytrans(' '))
2770 call assert_equal('<lt>', keytrans('<'))
2771 call assert_equal('<lt>Tab>', keytrans('<Tab>'))
2772 call assert_equal('<Tab>', keytrans("\<Tab>"))
2773 call assert_equal('<C-V>', keytrans("\<C-V>"))
2774 call assert_equal('<BS>', keytrans("\<BS>"))
2775 call assert_equal('<Home>', keytrans("\<Home>"))
2776 call assert_equal('<C-Home>', keytrans("\<C-Home>"))
2777 call assert_equal('<M-Home>', keytrans("\<M-Home>"))
2778 call assert_equal('<C-Space>', keytrans("\<C-Space>"))
2779 call assert_equal('<M-Space>', keytrans("\<*M-Space>"))
2780 call assert_equal('<M-x>', "\<*M-x>"->keytrans())
2781 call assert_equal('<C-I>', "\<*C-I>"->keytrans())
2782 call assert_equal('<S-3>', "\<*S-3>"->keytrans())
2783 call assert_equal('π', 'π'->keytrans())
2784 call assert_equal('<M-π>', "\<M-π>"->keytrans())
2785 call assert_equal('ě', 'ě'->keytrans())
2786 call assert_equal('<M-ě>', "\<M-ě>"->keytrans())
2787 call assert_equal('', ''->keytrans())
2788 call assert_equal('', test_null_string()->keytrans())
2789 call assert_fails('call keytrans(1)', 'E1174:')
2790 call assert_fails('call keytrans()', 'E119:')
2791 endfunc
2792
2767 " Test for the nr2char() function 2793 " Test for the nr2char() function
2768 func Test_nr2char() 2794 func Test_nr2char()
2769 set encoding=latin1 2795 set encoding=latin1
2770 call assert_equal('@', nr2char(64)) 2796 call assert_equal('@', nr2char(64))
2771 set encoding=utf8 2797 set encoding=utf8