My dotfiles. Period.

test-toggle-menu.vim 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. "=============================================================================
  2. " $Id: test-toggle-menu.vim 520 2012-03-19 18:09:15Z luc.hermitte $
  3. " File: tests/lh/test-toggle-menu.vim {{{1
  4. " Author: Luc Hermitte <EMAIL:hermitte {at} free {dot} fr>
  5. " <URL:http://code.google.com/p/lh-vim/>
  6. " License: GPLv3 with exceptions
  7. " <URL:http://code.google.com/p/lh-vim/wiki/License>
  8. " Version: 3.0.0
  9. " Created: 17th Apr 2007
  10. " Last Update: $Date: 2012-03-19 19:09:15 +0100 (Mon, 19 Mar 2012) $
  11. "------------------------------------------------------------------------
  12. " Description:
  13. " Tests for lh-vim-lib . lh#menu#def_toggle_item()
  14. "
  15. "------------------------------------------------------------------------
  16. " Installation: «install details»
  17. " History: «history»
  18. " TODO: «missing features»
  19. " }}}1
  20. "=============================================================================
  21. runtime autoload/lh/menu.vim
  22. let Data = {
  23. \ "variable": "bar",
  24. \ "idx_crt_value": 1,
  25. \ "values": [ 'a', 'b', 'c', 'd' ],
  26. \ "menu": { "priority": '42.50.10', "name": '&LH-Tests.&TogMenu.&bar'}
  27. \}
  28. call lh#menu#def_toggle_item(Data)
  29. let Data2 = {
  30. \ "variable": "foo",
  31. \ "idx_crt_value": 3,
  32. \ "texts": [ 'un', 'deux', 'trois', 'quatre' ],
  33. \ "values": [ 1, 2, 3, 4 ],
  34. \ "menu": { "priority": '42.50.11', "name": '&LH-Tests.&TogMenu.&foo'}
  35. \}
  36. call lh#menu#def_toggle_item(Data2)
  37. " No default
  38. let Data3 = {
  39. \ "variable": "nodef",
  40. \ "texts": [ 'one', 'two', 'three', 'four' ],
  41. \ "values": [ 1, 2, 3, 4 ],
  42. \ "menu": { "priority": '42.50.12', "name": '&LH-Tests.&TogMenu.&nodef'}
  43. \}
  44. call lh#menu#def_toggle_item(Data3)
  45. " No default
  46. let g:def = 2
  47. let Data4 = {
  48. \ "variable": "def",
  49. \ "values": [ 1, 2, 3, 4 ],
  50. \ "menu": { "priority": '42.50.13', "name": '&LH-Tests.&TogMenu.&def'}
  51. \}
  52. call lh#menu#def_toggle_item(Data4)
  53. " What follows does not work because we can't build an exportable FuncRef on top
  54. " of a script local function
  55. " finish
  56. function! s:getSNR()
  57. if !exists("s:SNR")
  58. let s:SNR=matchstr(expand("<sfile>"), "<SNR>\\d\\+_\\zegetSNR$")
  59. endif
  60. return s:SNR
  61. endfunction
  62. function! s:Yes()
  63. echomsg "Yes"
  64. endfunction
  65. function! s:No()
  66. echomsg "No"
  67. endfunction
  68. let Data4 = {
  69. \ "variable": "yesno",
  70. \ "values": [ 1, 2 ],
  71. \ "text": [ "No", "Yes" ],
  72. \ "actions": [ function(s:getSNR()."No"), function(s:getSNR()."Yes") ],
  73. \ "menu": { "priority": '42.50.20', "name": '&LH-Tests.&TogMenu.&yesno'}
  74. \}
  75. call lh#menu#def_toggle_item(Data4)