Bram Moolenaar | af8af8b | 2016-01-04 22:05:24 +0100 | [diff] [blame] | 1 | " Tests for :unlet |
| 2 | |
| 3 | func Test_read_only() |
| 4 | try |
| 5 | " this caused a crash |
| 6 | unlet count |
| 7 | catch |
| 8 | call assert_true(v:exception =~ ':E795:') |
| 9 | endtry |
Bram Moolenaar | 254b105 | 2016-01-10 16:10:17 +0100 | [diff] [blame] | 10 | try |
| 11 | " this caused a crash |
| 12 | unlet errmsg |
| 13 | catch |
| 14 | call assert_true(v:exception =~ ':E795:') |
| 15 | endtry |
Bram Moolenaar | af8af8b | 2016-01-04 22:05:24 +0100 | [diff] [blame] | 16 | endfunc |
| 17 | |
| 18 | func Test_existing() |
| 19 | let does_exist = 1 |
| 20 | call assert_true(exists('does_exist')) |
| 21 | unlet does_exist |
| 22 | call assert_false(exists('does_exist')) |
| 23 | endfunc |
| 24 | |
| 25 | func Test_not_existing() |
| 26 | unlet! does_not_exist |
| 27 | try |
| 28 | unlet does_not_exist |
| 29 | catch |
| 30 | call assert_true(v:exception =~ ':E108:') |
| 31 | endtry |
| 32 | endfunc |