blob: 1715a3f03b3c1d5bb5af20730177a5d1f96d3798 [file] [log] [blame]
Bram Moolenaarf6f32c32016-03-12 19:03:59 +01001" Test for assignment
2
3func Test_no_type_checking()
4 let v = 1
5 let v = [1,2,3]
6 let v = {'a': 1, 'b': 2}
7 let v = 3.4
8 let v = 'hello'
9endfunc
Bram Moolenaare353c402017-02-04 19:49:16 +010010
11func Test_let_termcap()
12 " Terminal code
13 let old_t_te = &t_te
14 let &t_te = "\<Esc>[yes;"
15 call assert_match('t_te.*^[[yes;', execute("set termcap"))
16 let &t_te = old_t_te
17
Bram Moolenaar1c410402017-02-23 15:20:03 +010018 if exists("+t_k1")
Bram Moolenaar1fb0d492017-02-04 21:50:19 +010019 " Key code
20 let old_t_k1 = &t_k1
21 let &t_k1 = "that"
22 call assert_match('t_k1.*that', execute("set termcap"))
23 let &t_k1 = old_t_k1
24 endif
Bram Moolenaare353c402017-02-04 19:49:16 +010025
Bram Moolenaarc0f5a782019-01-13 15:16:13 +010026 call assert_fails('let x = &t_xx', 'E113')
Bram Moolenaare353c402017-02-04 19:49:16 +010027 let &t_xx = "yes"
28 call assert_equal("yes", &t_xx)
29 let &t_xx = ""
Bram Moolenaarc0f5a782019-01-13 15:16:13 +010030 call assert_fails('let x = &t_xx', 'E113')
Bram Moolenaare353c402017-02-04 19:49:16 +010031endfunc
Bram Moolenaar2a6a6c32017-10-02 19:29:48 +020032
33func Test_let_option_error()
34 let _w = &tw
35 let &tw = 80
36 call assert_fails('let &tw .= 1', 'E734')
37 call assert_equal(80, &tw)
38 let &tw = _w
39
40 let _w = &fillchars
41 let &fillchars = "vert:|"
42 call assert_fails('let &fillchars += "diff:-"', 'E734')
43 call assert_equal("vert:|", &fillchars)
44 let &fillchars = _w
45endfunc
Bram Moolenaarc0f5a782019-01-13 15:16:13 +010046
47func Test_let_errors()
48 let s = 'abcd'
49 call assert_fails('let s[1] = 5', 'E689:')
50
51 let l = [1, 2, 3]
52 call assert_fails('let l[:] = 5', 'E709:')
53endfunc