Bram Moolenaar | 8f79acd | 2016-01-01 14:48:20 +0100 | [diff] [blame] | 1 | " Tests for the :set command |
| 2 | |
| 3 | function Test_set_backslash() |
| 4 | let isk_save = &isk |
| 5 | |
| 6 | set isk=a,b,c |
| 7 | set isk+=d |
| 8 | call assert_equal('a,b,c,d', &isk) |
| 9 | set isk+=\\,e |
| 10 | call assert_equal('a,b,c,d,\,e', &isk) |
| 11 | set isk-=e |
| 12 | call assert_equal('a,b,c,d,\', &isk) |
| 13 | set isk-=\\ |
| 14 | call assert_equal('a,b,c,d', &isk) |
| 15 | |
| 16 | let &isk = isk_save |
| 17 | endfunction |
| 18 | |
| 19 | function Test_set_add() |
| 20 | let wig_save = &wig |
| 21 | |
| 22 | set wildignore=*.png, |
| 23 | set wildignore+=*.jpg |
| 24 | call assert_equal('*.png,*.jpg', &wig) |
| 25 | |
| 26 | let &wig = wig_save |
| 27 | endfunction |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 28 | |
Dominique Pelle | 042414f | 2021-07-12 21:43:19 +0200 | [diff] [blame] | 29 | |
| 30 | " :set, :setlocal, :setglobal without arguments show values of options. |
| 31 | func Test_set_no_arg() |
| 32 | set textwidth=79 |
| 33 | let a = execute('set') |
| 34 | call assert_match("^\n--- Options ---\n.*textwidth=79\\>", a) |
| 35 | set textwidth& |
| 36 | |
| 37 | setlocal textwidth=78 |
| 38 | let a = execute('setlocal') |
| 39 | call assert_match("^\n--- Local option values ---\n.*textwidth=78\\>", a) |
| 40 | setlocal textwidth& |
| 41 | |
| 42 | setglobal textwidth=77 |
| 43 | let a = execute('setglobal') |
| 44 | call assert_match("^\n--- Global option values ---\n.*textwidth=77\\>", a) |
| 45 | setglobal textwidth& |
| 46 | endfunc |
| 47 | |
Bram Moolenaar | 15a24f0 | 2021-12-03 20:43:24 +0000 | [diff] [blame] | 48 | func Test_set_termcap() |
| 49 | CheckNotGui |
| 50 | |
| 51 | let lines = split(execute('set termcap'), "\n") |
| 52 | call assert_match('--- Terminal codes ---', lines[0]) |
| 53 | " four columns |
| 54 | call assert_match('t_..=.*t_..=.*t_..=.*t_..=', lines[1]) |
| 55 | |
| 56 | for keys_idx in range(len(lines)) |
| 57 | if lines[keys_idx] =~ '--- Terminal keys ---' |
| 58 | break |
| 59 | endif |
| 60 | endfor |
| 61 | call assert_true(keys_idx < len(lines)) |
| 62 | " three columns |
Bram Moolenaar | cd2f8f0 | 2021-12-03 21:18:14 +0000 | [diff] [blame] | 63 | call assert_match('<[^>]*> .*<[^>]*> .*<[^>]*> ', lines[keys_idx + 1]) |
Bram Moolenaar | 15a24f0 | 2021-12-03 20:43:24 +0000 | [diff] [blame] | 64 | |
| 65 | let more_lines = split(execute('set! termcap'), "\n") |
| 66 | for i in range(len(more_lines)) |
| 67 | if more_lines[i] =~ '--- Terminal keys ---' |
| 68 | break |
| 69 | endif |
| 70 | endfor |
| 71 | call assert_true(i < len(more_lines)) |
| 72 | call assert_true(i > keys_idx) |
| 73 | call assert_true(len(more_lines) - i > len(lines) - keys_idx) |
| 74 | endfunc |
| 75 | |
Bram Moolenaar | 6d91bcb | 2020-08-12 18:50:36 +0200 | [diff] [blame] | 76 | " vim: shiftwidth=2 sts=2 expandtab |