Bram Moolenaar | c8ce615 | 2016-08-07 13:48:20 +0200 | [diff] [blame] | 1 | " Test for options |
| 2 | |
| 3 | function! Test_whichwrap() |
| 4 | set whichwrap=b,s |
| 5 | call assert_equal('b,s', &whichwrap) |
| 6 | |
| 7 | set whichwrap+=h,l |
| 8 | call assert_equal('b,s,h,l', &whichwrap) |
| 9 | |
| 10 | set whichwrap+=h,l |
| 11 | call assert_equal('b,s,h,l', &whichwrap) |
| 12 | |
| 13 | set whichwrap+=h,l |
| 14 | call assert_equal('b,s,h,l', &whichwrap) |
| 15 | |
| 16 | set whichwrap& |
| 17 | endfunction |
| 18 | |
Bram Moolenaar | 95ec9d6 | 2016-08-12 18:29:59 +0200 | [diff] [blame] | 19 | function Test_options() |
Bram Moolenaar | c8ce615 | 2016-08-07 13:48:20 +0200 | [diff] [blame] | 20 | let caught = 'ok' |
| 21 | try |
| 22 | options |
| 23 | catch |
| 24 | let caught = v:throwpoint . "\n" . v:exception |
| 25 | endtry |
| 26 | call assert_equal('ok', caught) |
| 27 | |
| 28 | " close option-window |
| 29 | close |
| 30 | endfunction |
| 31 | |
Bram Moolenaar | 95ec9d6 | 2016-08-12 18:29:59 +0200 | [diff] [blame] | 32 | function Test_path_keep_commas() |
Bram Moolenaar | c8ce615 | 2016-08-07 13:48:20 +0200 | [diff] [blame] | 33 | " Test that changing 'path' keeps two commas. |
| 34 | set path=foo,,bar |
| 35 | set path-=bar |
| 36 | set path+=bar |
| 37 | call assert_equal('foo,,bar', &path) |
| 38 | |
| 39 | set path& |
| 40 | endfunction |
Bram Moolenaar | 95ec9d6 | 2016-08-12 18:29:59 +0200 | [diff] [blame] | 41 | |
| 42 | func Test_signcolumn() |
Bram Moolenaar | ebcccad | 2016-08-12 19:17:13 +0200 | [diff] [blame] | 43 | if has('signs') |
| 44 | call assert_equal("auto", &signcolumn) |
| 45 | set signcolumn=yes |
| 46 | set signcolumn=no |
| 47 | call assert_fails('set signcolumn=nope') |
| 48 | endif |
Bram Moolenaar | 95ec9d6 | 2016-08-12 18:29:59 +0200 | [diff] [blame] | 49 | endfunc |
| 50 | |
Bram Moolenaar | d0b5138 | 2016-11-04 15:23:45 +0100 | [diff] [blame] | 51 | func Test_filetype_valid() |
Bram Moolenaar | 9376f5f | 2016-11-04 16:41:20 +0100 | [diff] [blame] | 52 | if !has('autocmd') |
| 53 | return |
| 54 | endif |
Bram Moolenaar | d0b5138 | 2016-11-04 15:23:45 +0100 | [diff] [blame] | 55 | set ft=valid_name |
| 56 | call assert_equal("valid_name", &filetype) |
| 57 | set ft=valid-name |
| 58 | call assert_equal("valid-name", &filetype) |
| 59 | |
| 60 | call assert_fails(":set ft=wrong;name", "E474:") |
| 61 | call assert_fails(":set ft=wrong\\\\name", "E474:") |
| 62 | call assert_fails(":set ft=wrong\\|name", "E474:") |
| 63 | call assert_fails(":set ft=wrong/name", "E474:") |
| 64 | call assert_fails(":set ft=wrong\\\nname", "E474:") |
| 65 | call assert_equal("valid-name", &filetype) |
| 66 | |
| 67 | exe "set ft=trunc\x00name" |
| 68 | call assert_equal("trunc", &filetype) |
| 69 | endfunc |
| 70 | |
| 71 | func Test_syntax_valid() |
Bram Moolenaar | 9376f5f | 2016-11-04 16:41:20 +0100 | [diff] [blame] | 72 | if !has('syntax') |
| 73 | return |
| 74 | endif |
Bram Moolenaar | d0b5138 | 2016-11-04 15:23:45 +0100 | [diff] [blame] | 75 | set syn=valid_name |
| 76 | call assert_equal("valid_name", &syntax) |
| 77 | set syn=valid-name |
| 78 | call assert_equal("valid-name", &syntax) |
| 79 | |
| 80 | call assert_fails(":set syn=wrong;name", "E474:") |
| 81 | call assert_fails(":set syn=wrong\\\\name", "E474:") |
| 82 | call assert_fails(":set syn=wrong\\|name", "E474:") |
| 83 | call assert_fails(":set syn=wrong/name", "E474:") |
| 84 | call assert_fails(":set syn=wrong\\\nname", "E474:") |
| 85 | call assert_equal("valid-name", &syntax) |
| 86 | |
| 87 | exe "set syn=trunc\x00name" |
| 88 | call assert_equal("trunc", &syntax) |
| 89 | endfunc |
| 90 | |
| 91 | func Test_keymap_valid() |
Bram Moolenaar | 9376f5f | 2016-11-04 16:41:20 +0100 | [diff] [blame] | 92 | if !has('keymap') |
| 93 | return |
| 94 | endif |
Bram Moolenaar | d0b5138 | 2016-11-04 15:23:45 +0100 | [diff] [blame] | 95 | call assert_fails(":set kmp=valid_name", "E544:") |
| 96 | call assert_fails(":set kmp=valid_name", "valid_name") |
| 97 | call assert_fails(":set kmp=valid-name", "E544:") |
| 98 | call assert_fails(":set kmp=valid-name", "valid-name") |
| 99 | |
| 100 | call assert_fails(":set kmp=wrong;name", "E474:") |
| 101 | call assert_fails(":set kmp=wrong\\\\name", "E474:") |
| 102 | call assert_fails(":set kmp=wrong\\|name", "E474:") |
| 103 | call assert_fails(":set kmp=wrong/name", "E474:") |
| 104 | call assert_fails(":set kmp=wrong\\\nname", "E474:") |
| 105 | |
| 106 | call assert_fails(":set kmp=trunc\x00name", "E544:") |
| 107 | call assert_fails(":set kmp=trunc\x00name", "trunc") |
| 108 | endfunc |
Bram Moolenaar | 7554da4 | 2016-11-25 22:04:13 +0100 | [diff] [blame] | 109 | |
| 110 | func Test_dictionary() |
| 111 | " Check that it's possible to set the option. |
| 112 | set dictionary=/usr/share/dict/words |
| 113 | call assert_equal('/usr/share/dict/words', &dictionary) |
| 114 | set dictionary=/usr/share/dict/words,/and/there |
| 115 | call assert_equal('/usr/share/dict/words,/and/there', &dictionary) |
| 116 | set dictionary=/usr/share/dict\ words |
| 117 | call assert_equal('/usr/share/dict words', &dictionary) |
| 118 | |
| 119 | " Check rejecting weird characters. |
| 120 | call assert_fails("set dictionary=/not&there", "E474:") |
| 121 | call assert_fails("set dictionary=/not>there", "E474:") |
| 122 | call assert_fails("set dictionary=/not.*there", "E474:") |
| 123 | endfunc |