annotate src/testdir/test_vim9_expr.vim @ 19854:eddc81783052 v8.2.0483

patch 8.2.0483: Vim9: "let x = x + 1" does not give an error Commit: https://github.com/vim/vim/commit/d25ec2cfa0c25c3b00b7f8963b8aea799df1f20a Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 30 21:05:45 2020 +0200 patch 8.2.0483: Vim9: "let x = x + 1" does not give an error Problem: Vim9: "let x = x + 1" does not give an error. Solution: Hide the variable when compiling the expression.
author Bram Moolenaar <Bram@vim.org>
date Mon, 30 Mar 2020 21:15:03 +0200
parents 36d629aa3d6e
children 90eec641cc8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for Vim9 script expressions
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 source check.vim
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " Check that "line" inside ":def" results in an "error" message.
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6 func CheckDefFailure(line, error)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 call writefile(['def! Func()', a:line, 'enddef'], 'Xdef')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 call assert_fails('so Xdef', a:error, a:line)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 call delete('Xdef')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11
19558
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
12 func CheckDefFailureMult(lines, error)
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
13 call writefile(['def! Func()'] + a:lines + ['enddef'], 'Xdef')
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
14 call assert_fails('so Xdef', a:error, join(a:lines, ' | '))
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
15 call delete('Xdef')
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
16 endfunc
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
17
19437
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
18 " Check that "line" inside ":def" results in an "error" message when executed.
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
19 func CheckDefExecFailure(line, error)
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
20 call writefile(['def! Func()', a:line, 'enddef'], 'Xdef')
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
21 so Xdef
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
22 call assert_fails('call Func()', a:error, a:line)
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
23 call delete('Xdef')
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
24 endfunc
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
25
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 func CheckDefFailureList(lines, error)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 call writefile(['def! Func()'] + a:lines + ['enddef'], 'Xdef')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 call assert_fails('so Xdef', a:error, string(a:lines))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 call delete('Xdef')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 " test cond ? expr : expr
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 def Test_expr1()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 assert_equal('one', true ? 'one' : 'two')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 assert_equal('one', 1 ? 'one' : 'two')
19249
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19219
diff changeset
36 if has('float')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19219
diff changeset
37 assert_equal('one', 0.1 ? 'one' : 'two')
2a017e9dc6da patch 8.2.0183: tests fail when the float feature is disabled
Bram Moolenaar <Bram@vim.org>
parents: 19219
diff changeset
38 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 assert_equal('one', 'x' ? 'one' : 'two')
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
40 assert_equal('one', 0z1234 ? 'one' : 'two')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 assert_equal('one', [0] ? 'one' : 'two')
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
42 assert_equal('one', #{x: 0} ? 'one' : 'two')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43 let var = 1
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 assert_equal('one', var ? 'one' : 'two')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 assert_equal('two', false ? 'one' : 'two')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 assert_equal('two', 0 ? 'one' : 'two')
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
48 if has('float')
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
49 assert_equal('two', 0.0 ? 'one' : 'two')
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
50 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 assert_equal('two', '' ? 'one' : 'two')
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
52 assert_equal('two', 0z ? 'one' : 'two')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 assert_equal('two', [] ? 'one' : 'two')
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
54 assert_equal('two', {} ? 'one' : 'two')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 var = 0
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 assert_equal('two', var ? 'one' : 'two')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59 func Test_expr1_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 call CheckDefFailure("let x = 1 ? 'one'", "Missing ':' after '?'")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 let msg = "white space required before and after '?'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 call CheckDefFailure("let x = 1? 'one' : 'two'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
64 call CheckDefFailure("let x = 1 ?'one' : 'two'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
65 call CheckDefFailure("let x = 1?'one' : 'two'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
66
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
67 let msg = "white space required before and after ':'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
68 call CheckDefFailure("let x = 1 ? 'one': 'two'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
69 call CheckDefFailure("let x = 1 ? 'one' :'two'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
70 call CheckDefFailure("let x = 1 ? 'one':'two'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
71 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
72
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
73 " TODO: define inside test function
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
74 def Record(val: any): any
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
75 g:vals->add(val)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
76 return val
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
77 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
78
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
79 " test ||
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
80 def Test_expr2()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
81 assert_equal(2, 2 || 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
82 assert_equal(7, 0 || 0 || 7)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
83 assert_equal(0, 0 || 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
84 assert_equal('', 0 || '')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
85
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
86 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
87 assert_equal(3, Record(3) || Record(1))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
88 assert_equal([3], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
89
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
90 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
91 assert_equal(5, Record(0) || Record(5))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
92 assert_equal([0, 5], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
93
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
94 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
95 assert_equal(4, Record(0) || Record(4) || Record(0))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
96 assert_equal([0, 4], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
97
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
98 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
99 assert_equal(0, Record([]) || Record('') || Record(0))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
100 assert_equal([[], '', 0], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
101 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
102
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
103 func Test_expr2_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
104 let msg = "white space required before and after '||'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
105 call CheckDefFailure("let x = 1||2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
106 call CheckDefFailure("let x = 1 ||2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
107 call CheckDefFailure("let x = 1|| 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
108 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
109
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
110 " test &&
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
111 def Test_expr3()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
112 assert_equal(0, 2 && 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 assert_equal(0, 0 && 0 && 7)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
114 assert_equal(7, 2 && 3 && 7)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
115 assert_equal(0, 0 && 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
116 assert_equal(0, 0 && '')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
117 assert_equal('', 8 && '')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
120 assert_equal(1, Record(3) && Record(1))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
121 assert_equal([3, 1], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
123 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 assert_equal(0, Record(0) && Record(5))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
125 assert_equal([0], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 assert_equal(0, Record(0) && Record(4) && Record(0))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
129 assert_equal([0], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
131 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
132 assert_equal(0, Record(8) && Record(4) && Record(0))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133 assert_equal([8, 4, 0], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
135 g:vals = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
136 assert_equal(0, Record([1]) && Record('z') && Record(0))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 assert_equal([[1], 'z', 0], g:vals)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
139
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 func Test_expr3_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
141 let msg = "white space required before and after '&&'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 call CheckDefFailure("let x = 1&&2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 call CheckDefFailure("let x = 1 &&2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
144 call CheckDefFailure("let x = 1&& 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
145 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
147 let atrue = v:true
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
148 let afalse = v:false
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
149 let anone = v:none
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
150 let anull = v:null
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
151 let anint = 10
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
152 let alsoint = 4
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
153 if has('float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
154 let afloat = 0.1
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
155 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
156 let astring = 'asdf'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
157 let ablob = 0z01ab
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
158 let alist = [2, 3, 4]
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
159 let adict = #{aaa: 2, bbb: 8}
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
160
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
161 " test == comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 def Test_expr4_equal()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
163 assert_equal(true, true == true)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
164 assert_equal(false, true == false)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
165 assert_equal(true, true == g:atrue)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
166 assert_equal(false, g:atrue == false)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
167
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
168 assert_equal(true, v:none == v:none)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
169 assert_equal(false, v:none == v:null)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 assert_equal(true, g:anone == v:none)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
171 assert_equal(false, v:none == g:anull)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
173 assert_equal(false, 2 == 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
174 assert_equal(true, 61 == 61)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
175 assert_equal(true, g:anint == 10)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
176 assert_equal(false, 61 == g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
177
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
178 if has('float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
179 assert_equal(true, 0.3 == 0.3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
180 assert_equal(false, 0.4 == 0.3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
181 assert_equal(true, 0.1 == g:afloat)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
182 assert_equal(false, g:afloat == 0.3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
183
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
184 assert_equal(true, 3.0 == 3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
185 assert_equal(true, 3 == 3.0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
186 assert_equal(false, 3.1 == 3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
187 assert_equal(false, 3 == 3.1)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
188 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
189
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
190 assert_equal(true, 'abc' == 'abc')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
191 assert_equal(false, 'xyz' == 'abc')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
192 assert_equal(true, g:astring == 'asdf')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
193 assert_equal(false, 'xyz' == g:astring)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
194
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
195 assert_equal(false, 'abc' == 'ABC')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
196 set ignorecase
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 assert_equal(false, 'abc' == 'ABC')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
198 set noignorecase
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
199
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
200 assert_equal(true, 0z3f == 0z3f)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
201 assert_equal(false, 0z3f == 0z4f)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
202 assert_equal(true, g:ablob == 0z01ab)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
203 assert_equal(false, 0z3f == g:ablob)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
204
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
205 assert_equal(true, [1, 2, 3] == [1, 2, 3])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 assert_equal(false, [1, 2, 3] == [2, 3, 1])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
207 assert_equal(true, [2, 3, 4] == g:alist)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
208 assert_equal(false, g:alist == [2, 3, 1])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
209 assert_equal(false, [1, 2, 3] == [])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 assert_equal(false, [1, 2, 3] == ['1', '2', '3'])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
211
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
212 assert_equal(true, #{one: 1, two: 2} == #{one: 1, two: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 assert_equal(false, #{one: 1, two: 2} == #{one: 2, two: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 assert_equal(false, #{one: 1, two: 2} == #{two: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
215 assert_equal(false, #{one: 1, two: 2} == #{})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
216 assert_equal(true, g:adict == #{bbb: 8, aaa: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 assert_equal(false, #{ccc: 9, aaa: 2} == g:adict)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
219 assert_equal(true, function('Test_expr4_equal') == function('Test_expr4_equal'))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
220 assert_equal(false, function('Test_expr4_equal') == function('Test_expr4_is'))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 assert_equal(true, function('Test_expr4_equal', [123]) == function('Test_expr4_equal', [123]))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 assert_equal(false, function('Test_expr4_equal', [123]) == function('Test_expr4_is', [123]))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
224 assert_equal(false, function('Test_expr4_equal', [123]) == function('Test_expr4_equal', [999]))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
225 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
227 " test != comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
228 def Test_expr4_notequal()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
229 assert_equal(false, true != true)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
230 assert_equal(true, true != false)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231 assert_equal(false, true != g:atrue)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
232 assert_equal(true, g:atrue != false)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
233
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
234 assert_equal(false, v:none != v:none)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
235 assert_equal(true, v:none != v:null)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
236 assert_equal(false, g:anone != v:none)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
237 assert_equal(true, v:none != g:anull)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
238
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
239 assert_equal(true, 2 != 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
240 assert_equal(false, 55 != 55)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
241 assert_equal(false, g:anint != 10)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
242 assert_equal(true, 61 != g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
243
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
244 if has('float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
245 assert_equal(false, 0.3 != 0.3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
246 assert_equal(true, 0.4 != 0.3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
247 assert_equal(false, 0.1 != g:afloat)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
248 assert_equal(true, g:afloat != 0.3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
249
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
250 assert_equal(false, 3.0 != 3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
251 assert_equal(false, 3 != 3.0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
252 assert_equal(true, 3.1 != 3)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
253 assert_equal(true, 3 != 3.1)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
254 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
255
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
256 assert_equal(false, 'abc' != 'abc')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
257 assert_equal(true, 'xyz' != 'abc')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
258 assert_equal(false, g:astring != 'asdf')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
259 assert_equal(true, 'xyz' != g:astring)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
260
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
261 assert_equal(true, 'abc' != 'ABC')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
262 set ignorecase
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
263 assert_equal(true, 'abc' != 'ABC')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
264 set noignorecase
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
265
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
266 assert_equal(false, 0z3f != 0z3f)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
267 assert_equal(true, 0z3f != 0z4f)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
268 assert_equal(false, g:ablob != 0z01ab)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
269 assert_equal(true, 0z3f != g:ablob)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
270
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
271 assert_equal(false, [1, 2, 3] != [1, 2, 3])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
272 assert_equal(true, [1, 2, 3] != [2, 3, 1])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
273 assert_equal(false, [2, 3, 4] != g:alist)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
274 assert_equal(true, g:alist != [2, 3, 1])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
275 assert_equal(true, [1, 2, 3] != [])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
276 assert_equal(true, [1, 2, 3] != ['1', '2', '3'])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
277
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
278 assert_equal(false, #{one: 1, two: 2} != #{one: 1, two: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
279 assert_equal(true, #{one: 1, two: 2} != #{one: 2, two: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
280 assert_equal(true, #{one: 1, two: 2} != #{two: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
281 assert_equal(true, #{one: 1, two: 2} != #{})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
282 assert_equal(false, g:adict != #{bbb: 8, aaa: 2})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
283 assert_equal(true, #{ccc: 9, aaa: 2} != g:adict)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
284
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
285 assert_equal(false, function('Test_expr4_equal') != function('Test_expr4_equal'))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
286 assert_equal(true, function('Test_expr4_equal') != function('Test_expr4_is'))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
287
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
288 assert_equal(false, function('Test_expr4_equal', [123]) != function('Test_expr4_equal', [123]))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
289 assert_equal(true, function('Test_expr4_equal', [123]) != function('Test_expr4_is', [123]))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
290 assert_equal(true, function('Test_expr4_equal', [123]) != function('Test_expr4_equal', [999]))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
291 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
292
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
293 " test > comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
294 def Test_expr4_greater()
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
295 assert_true(2 > 0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
296 assert_true(2 > 1)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
297 assert_false(2 > 2)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
298 assert_false(2 > 3)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
299 if has('float')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
300 assert_true(2.0 > 0.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
301 assert_true(2.0 > 1.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
302 assert_false(2.0 > 2.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
303 assert_false(2.0 > 3.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
304 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
305 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
306
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
307 " test >= comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
308 def Test_expr4_greaterequal()
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
309 assert_true(2 >= 0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
310 assert_true(2 >= 2)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
311 assert_false(2 >= 3)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
312 if has('float')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
313 assert_true(2.0 >= 0.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
314 assert_true(2.0 >= 2.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
315 assert_false(2.0 >= 3.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
316 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
317 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
318
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
319 " test < comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
320 def Test_expr4_smaller()
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
321 assert_false(2 < 0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
322 assert_false(2 < 2)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
323 assert_true(2 < 3)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
324 if has('float')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
325 assert_false(2.0 < 0.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
326 assert_false(2.0 < 2.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
327 assert_true(2.0 < 3.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
328 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
329 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
330
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
331 " test <= comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
332 def Test_expr4_smallerequal()
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
333 assert_false(2 <= 0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
334 assert_false(2 <= 1)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
335 assert_true(2 <= 2)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
336 assert_true(2 <= 3)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
337 if has('float')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
338 assert_false(2.0 <= 0.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
339 assert_false(2.0 <= 1.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
340 assert_true(2.0 <= 2.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
341 assert_true(2.0 <= 3.0)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
342 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
343 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
344
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
345 " test =~ comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
346 def Test_expr4_match()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
347 assert_equal(false, '2' =~ '0')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
348 assert_equal(true, '2' =~ '[0-9]')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
349 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
350
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
351 " test !~ comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
352 def Test_expr4_nomatch()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
353 assert_equal(true, '2' !~ '0')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
354 assert_equal(false, '2' !~ '[0-9]')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
355 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
356
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
357 " test is comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
358 def Test_expr4_is()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
359 let mylist = [2]
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
360 assert_false(mylist is [2])
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
361 let other = mylist
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
362 assert_true(mylist is other)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
363
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
364 let myblob = 0z1234
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
365 assert_false(myblob is 0z1234)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
366 let otherblob = myblob
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
367 assert_true(myblob is otherblob)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
368 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
369
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
370 " test isnot comperator
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
371 def Test_expr4_isnot()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
372 let mylist = [2]
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
373 assert_true('2' isnot '0')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
374 assert_true(mylist isnot [2])
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
375 let other = mylist
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
376 assert_false(mylist isnot other)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
377
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
378 let myblob = 0z1234
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
379 assert_true(myblob isnot 0z1234)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
380 let otherblob = myblob
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
381 assert_false(myblob isnot otherblob)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
382 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
383
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
384 def RetVoid()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
385 let x = 1
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
386 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
387
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
388 func Test_expr4_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
389 let msg = "white space required before and after '>'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
390 call CheckDefFailure("let x = 1>2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
391 call CheckDefFailure("let x = 1 >2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
392 call CheckDefFailure("let x = 1> 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
393
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
394 let msg = "white space required before and after '=='"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
395 call CheckDefFailure("let x = 1==2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
396 call CheckDefFailure("let x = 1 ==2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
397 call CheckDefFailure("let x = 1== 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
398
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
399 let msg = "white space required before and after 'is'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
400 call CheckDefFailure("let x = '1'is'2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
401 call CheckDefFailure("let x = '1' is'2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
402 call CheckDefFailure("let x = '1'is '2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
403
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
404 let msg = "white space required before and after 'isnot'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
405 call CheckDefFailure("let x = '1'isnot'2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
406 call CheckDefFailure("let x = '1' isnot'2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
407 call CheckDefFailure("let x = '1'isnot '2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
408
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
409 call CheckDefFailure("let x = 1 is# 2", 'E15:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
410 call CheckDefFailure("let x = 1 is? 2", 'E15:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
411 call CheckDefFailure("let x = 1 isnot# 2", 'E15:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
412 call CheckDefFailure("let x = 1 isnot? 2", 'E15:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
413
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
414 call CheckDefFailure("let x = 1 == '2'", 'Cannot compare number with string')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
415 call CheckDefFailure("let x = '1' == 2", 'Cannot compare string with number')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
416 call CheckDefFailure("let x = 1 == RetVoid()", 'Cannot use void value')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
417 call CheckDefFailure("let x = RetVoid() == 1", 'Cannot compare void with number')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
418
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
419 call CheckDefFailure("let x = true > false", 'Cannot compare bool with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
420 call CheckDefFailure("let x = true >= false", 'Cannot compare bool with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
421 call CheckDefFailure("let x = true < false", 'Cannot compare bool with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
422 call CheckDefFailure("let x = true <= false", 'Cannot compare bool with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
423 call CheckDefFailure("let x = true =~ false", 'Cannot compare bool with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
424 call CheckDefFailure("let x = true !~ false", 'Cannot compare bool with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
425 call CheckDefFailure("let x = true is false", 'Cannot use "is" with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
426 call CheckDefFailure("let x = true isnot false", 'Cannot use "isnot" with bool')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
427
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
428 call CheckDefFailure("let x = v:none is v:null", 'Cannot use "is" with special')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
429 call CheckDefFailure("let x = v:none isnot v:null", 'Cannot use "isnot" with special')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
430 call CheckDefFailure("let x = 123 is 123", 'Cannot use "is" with number')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
431 call CheckDefFailure("let x = 123 isnot 123", 'Cannot use "isnot" with number')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
432 if has('float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
433 call CheckDefFailure("let x = 1.3 is 1.3", 'Cannot use "is" with float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
434 call CheckDefFailure("let x = 1.3 isnot 1.3", 'Cannot use "isnot" with float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
435 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
436
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
437 call CheckDefFailure("let x = 0za1 > 0z34", 'Cannot compare blob with blob')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
438 call CheckDefFailure("let x = 0za1 >= 0z34", 'Cannot compare blob with blob')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
439 call CheckDefFailure("let x = 0za1 < 0z34", 'Cannot compare blob with blob')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
440 call CheckDefFailure("let x = 0za1 <= 0z34", 'Cannot compare blob with blob')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
441 call CheckDefFailure("let x = 0za1 =~ 0z34", 'Cannot compare blob with blob')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
442 call CheckDefFailure("let x = 0za1 !~ 0z34", 'Cannot compare blob with blob')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
443
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
444 call CheckDefFailure("let x = [13] > [88]", 'Cannot compare list with list')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
445 call CheckDefFailure("let x = [13] >= [88]", 'Cannot compare list with list')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
446 call CheckDefFailure("let x = [13] < [88]", 'Cannot compare list with list')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
447 call CheckDefFailure("let x = [13] <= [88]", 'Cannot compare list with list')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
448 call CheckDefFailure("let x = [13] =~ [88]", 'Cannot compare list with list')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
449 call CheckDefFailure("let x = [13] !~ [88]", 'Cannot compare list with list')
19583
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
450
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
451 call CheckDefFailureMult(['let j: job', 'let chan: channel', 'let r = j == chan'], 'Cannot compare job with channel')
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
452 call CheckDefFailureMult(['let j: job', 'let x: list<any>', 'let r = j == x'], 'Cannot compare job with list')
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
453 call CheckDefFailureMult(['let j: job', 'let x: func', 'let r = j == x'], 'Cannot compare job with func')
ba35daca6553 patch 8.2.0348: Vim9: not all code tested
Bram Moolenaar <Bram@vim.org>
parents: 19558
diff changeset
454 call CheckDefFailureMult(['let j: job', 'let x: partial', 'let r = j == x'], 'Cannot compare job with partial')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
455 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
456
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
457 " test addition, subtraction, concatenation
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
458 def Test_expr5()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
459 assert_equal(66, 60 + 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
460 assert_equal(70, 60 + g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
461 assert_equal(9, g:alsoint + 5)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
462 assert_equal(14, g:alsoint + g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
463
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
464 assert_equal(54, 60 - 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
465 assert_equal(50, 60 - g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
466 assert_equal(-1, g:alsoint - 5)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
467 assert_equal(-6, g:alsoint - g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
468
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
469 assert_equal('hello', 'hel' .. 'lo')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
470 assert_equal('hello 123', 'hello ' .. 123)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
471 assert_equal('123 hello', 123 .. ' hello')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
472 assert_equal('123456', 123 .. 456)
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
473
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
474 assert_equal([1, 2, 3, 4], [1, 2] + [3, 4])
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
475 assert_equal(0z11223344, 0z1122 + 0z3344)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
476 assert_equal(0z112201ab, 0z1122 + g:ablob)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
477 assert_equal(0z01ab3344, g:ablob + 0z3344)
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
478 assert_equal(0z01ab01ab, g:ablob + g:ablob)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
479 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
480
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
481 def Test_expr5_float()
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
482 if !has('float')
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
483 MissingFeature 'float'
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
484 else
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
485 assert_equal(66.0, 60.0 + 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
486 assert_equal(66.0, 60.0 + 6)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
487 assert_equal(66.0, 60 + 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
488 assert_equal(5.1, g:afloat + 5)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
489 assert_equal(8.1, 8 + g:afloat)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
490 assert_equal(10.1, g:anint + g:afloat)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
491 assert_equal(10.1, g:afloat + g:anint)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
492
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
493 assert_equal(54.0, 60.0 - 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
494 assert_equal(54.0, 60.0 - 6)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
495 assert_equal(54.0, 60 - 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
496 assert_equal(-4.9, g:afloat - 5)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
497 assert_equal(7.9, 8 - g:afloat)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
498 assert_equal(9.9, g:anint - g:afloat)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
499 assert_equal(-9.9, g:afloat - g:anint)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
500 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
501 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
502
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
503 func Test_expr5_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
504 let msg = "white space required before and after '+'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
505 call CheckDefFailure("let x = 1+2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
506 call CheckDefFailure("let x = 1 +2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
507 call CheckDefFailure("let x = 1+ 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
508
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
509 let msg = "white space required before and after '-'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
510 call CheckDefFailure("let x = 1-2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
511 call CheckDefFailure("let x = 1 -2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
512 call CheckDefFailure("let x = 1- 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
513
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
514 let msg = "white space required before and after '..'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
515 call CheckDefFailure("let x = '1'..'2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
516 call CheckDefFailure("let x = '1' ..'2'", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
517 call CheckDefFailure("let x = '1'.. '2'", msg)
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
518
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
519 call CheckDefFailure("let x = 0z1122 + 33", 'E1035')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
520 call CheckDefFailure("let x = 0z1122 + [3]", 'E1035')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
521 call CheckDefFailure("let x = 0z1122 + 'asd'", 'E1035')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
522 call CheckDefFailure("let x = 33 + 0z1122", 'E1035')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
523 call CheckDefFailure("let x = [3] + 0z1122", 'E1035')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
524 call CheckDefFailure("let x = 'asdf' + 0z1122", 'E1035')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
525 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
526
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
527 " test multiply, divide, modulo
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
528 def Test_expr6()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
529 assert_equal(36, 6 * 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
530 assert_equal(24, 6 * g:alsoint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
531 assert_equal(24, g:alsoint * 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
532 assert_equal(40, g:anint * g:alsoint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
533
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
534 assert_equal(10, 60 / 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
535 assert_equal(6, 60 / g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
536 assert_equal(1, g:anint / 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
537 assert_equal(2, g:anint / g:alsoint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
538
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
539 assert_equal(5, 11 % 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
540 assert_equal(4, g:anint % 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
541 assert_equal(3, 13 % g:anint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
542 assert_equal(2, g:anint % g:alsoint)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
543
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
544 assert_equal(4, 6 * 4 / 6)
19423
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
545
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
546 let x = [2]
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
547 let y = [3]
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
548 assert_equal(5, x[0] + y[0])
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
549 assert_equal(6, x[0] * y[0])
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
550 if has('float')
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
551 let xf = [2.0]
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
552 let yf = [3.0]
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
553 assert_equal(5.0, xf[0] + yf[0])
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
554 assert_equal(6.0, xf[0] * yf[0])
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
555 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
556 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
557
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
558 def Test_expr6_float()
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
559 if !has('float')
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
560 MissingFeature 'float'
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
561 else
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
562 assert_equal(36.0, 6.0 * 6)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
563 assert_equal(36.0, 6 * 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
564 assert_equal(36.0, 6.0 * 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
565 assert_equal(1.0, g:afloat * g:anint)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
566
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
567 assert_equal(10.0, 60 / 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
568 assert_equal(10.0, 60.0 / 6)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
569 assert_equal(10.0, 60.0 / 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
570 assert_equal(0.01, g:afloat / g:anint)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
571
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
572 assert_equal(4.0, 6.0 * 4 / 6)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
573 assert_equal(4.0, 6 * 4.0 / 6)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
574 assert_equal(4.0, 6 * 4 / 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
575 assert_equal(4.0, 6.0 * 4.0 / 6)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
576 assert_equal(4.0, 6 * 4.0 / 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
577 assert_equal(4.0, 6.0 * 4 / 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
578 assert_equal(4.0, 6.0 * 4.0 / 6.0)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
579
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
580 assert_equal(4.0, 6.0 * 4.0 / 6.0)
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
581 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
582 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
583
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
584 func Test_expr6_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
585 let msg = "white space required before and after '*'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
586 call CheckDefFailure("let x = 1*2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
587 call CheckDefFailure("let x = 1 *2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
588 call CheckDefFailure("let x = 1* 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
589
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
590 let msg = "white space required before and after '/'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
591 call CheckDefFailure("let x = 1/2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
592 call CheckDefFailure("let x = 1 /2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
593 call CheckDefFailure("let x = 1/ 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
594
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
595 let msg = "white space required before and after '%'"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
596 call CheckDefFailure("let x = 1%2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
597 call CheckDefFailure("let x = 1 %2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
598 call CheckDefFailure("let x = 1% 2", msg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
599
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
600 call CheckDefFailure("let x = '1' * '2'", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
601 call CheckDefFailure("let x = '1' / '2'", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
602 call CheckDefFailure("let x = '1' % '2'", 'E1035:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
603
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
604 call CheckDefFailure("let x = 0z01 * 0z12", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
605 call CheckDefFailure("let x = 0z01 / 0z12", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
606 call CheckDefFailure("let x = 0z01 % 0z12", 'E1035:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
607
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
608 call CheckDefFailure("let x = [1] * [2]", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
609 call CheckDefFailure("let x = [1] / [2]", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
610 call CheckDefFailure("let x = [1] % [2]", 'E1035:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
611
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
612 call CheckDefFailure("let x = #{one: 1} * #{two: 2}", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
613 call CheckDefFailure("let x = #{one: 1} / #{two: 2}", 'E1036:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
614 call CheckDefFailure("let x = #{one: 1} % #{two: 2}", 'E1035:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
615
19423
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
616 call CheckDefFailure("let x = 0xff[1]", 'E714:')
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
617 if has('float')
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
618 call CheckDefFailure("let x = 0.7[1]", 'E714:')
f3e8e74cb747 patch 8.2.0269: Vim9: operator after list index does not work
Bram Moolenaar <Bram@vim.org>
parents: 19259
diff changeset
619 endif
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
620 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
621
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
622 func Test_expr6_float_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
623 CheckFeature float
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
624 call CheckDefFailure("let x = 1.0 % 2", 'E1035:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
625 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
626
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
627 " define here to use old style parsing
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
628 if has('float')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
629 let g:float_zero = 0.0
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
630 let g:float_neg = -9.8
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
631 let g:float_big = 9.9e99
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
632 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
633 let g:blob_empty = 0z
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
634 let g:blob_one = 0z01
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
635 let g:blob_long = 0z0102.0304
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
636
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
637 let g:string_empty = ''
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
638 let g:string_short = 'x'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
639 let g:string_long = 'abcdefghijklm'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
640 let g:string_special = "ab\ncd\ref\ekk"
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
641
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
642 let g:special_true = v:true
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
643 let g:special_false = v:false
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
644 let g:special_null = v:null
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
645 let g:special_none = v:none
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
646
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
647 let g:list_empty = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
648 let g:list_mixed = [1, 'b', v:false]
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
649
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
650 let g:dict_empty = {}
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
651 let g:dict_one = #{one: 1}
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
652
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
653 let $TESTVAR = 'testvar'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
654
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
655 " test low level expression
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
656 def Test_expr7_number()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
657 " number constant
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
658 assert_equal(0, 0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
659 assert_equal(654, 0654)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
660
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
661 assert_equal(6, 0x6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
662 assert_equal(15, 0xf)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
663 assert_equal(255, 0xff)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
664 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
665
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
666 def Test_expr7_float()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
667 " float constant
19259
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
668 if !has('float')
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
669 MissingFeature 'float'
77cce0439714 patch 8.2.0188: Check commands don't work well with Vim9 script
Bram Moolenaar <Bram@vim.org>
parents: 19249
diff changeset
670 else
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
671 assert_equal(g:float_zero, .0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
672 assert_equal(g:float_zero, 0.0)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
673 assert_equal(g:float_neg, -9.8)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
674 assert_equal(g:float_big, 9.9e99)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
675 endif
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
676 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
677
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
678 def Test_expr7_blob()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
679 " blob constant
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
680 assert_equal(g:blob_empty, 0z)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
681 assert_equal(g:blob_one, 0z01)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
682 assert_equal(g:blob_long, 0z0102.0304)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
683 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
684
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
685 def Test_expr7_string()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
686 " string constant
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
687 assert_equal(g:string_empty, '')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
688 assert_equal(g:string_empty, "")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
689 assert_equal(g:string_short, 'x')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
690 assert_equal(g:string_short, "x")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
691 assert_equal(g:string_long, 'abcdefghijklm')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
692 assert_equal(g:string_long, "abcdefghijklm")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
693 assert_equal(g:string_special, "ab\ncd\ref\ekk")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
694 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
695
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
696 def Test_expr7_special()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
697 " special constant
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
698 assert_equal(g:special_true, true)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
699 assert_equal(g:special_false, false)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
700 assert_equal(g:special_null, v:null)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
701 assert_equal(g:special_none, v:none)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
702 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
703
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
704 def Test_expr7_list()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
705 " list
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
706 assert_equal(g:list_empty, [])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
707 assert_equal(g:list_empty, [ ])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
708 assert_equal(g:list_mixed, [1, 'b', false])
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
709 assert_equal('b', g:list_mixed[1])
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
710
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
711 call CheckDefExecFailure("let x = g:anint[3]", 'E714:')
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
712 call CheckDefFailure("let x = g:list_mixed[xxx]", 'E1001:')
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
713 call CheckDefExecFailure("let x = g:list_mixed['xx']", 'E39:')
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
714 call CheckDefFailure("let x = g:list_mixed[0", 'E111:')
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
715 call CheckDefExecFailure("let x = g:list_empty[3]", 'E684:')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
716 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
717
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
718 def Test_expr7_lambda()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
719 " lambda
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
720 let La = { -> 'result'}
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
721 assert_equal('result', La())
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
722 assert_equal([1, 3, 5], [1, 2, 3]->map({key, val -> key + val}))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
723 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
724
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
725 def Test_expr7_dict()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
726 " dictionary
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
727 assert_equal(g:dict_empty, {})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
728 assert_equal(g:dict_empty, { })
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
729 assert_equal(g:dict_one, {'one': 1})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
730 let key = 'one'
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
731 let val = 1
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
732 assert_equal(g:dict_one, {key: val})
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
733
19842
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
734 call CheckDefFailure("let x = #{8: 8}", 'E1014:')
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
735 call CheckDefFailure("let x = #{xxx}", 'E720:')
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
736 call CheckDefFailure("let x = #{xxx: 1", 'E722:')
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
737 call CheckDefFailure("let x = #{xxx: 1,", 'E723:')
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
738 call CheckDefFailure("let x = {'a': xxx}", 'E1001:')
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
739 call CheckDefFailure("let x = {xxx: 8}", 'E1001:')
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
740 call CheckDefFailure("let x = #{a: 1, a: 2}", 'E721:')
19854
eddc81783052 patch 8.2.0483: Vim9: "let x = x + 1" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 19848
diff changeset
741 call CheckDefFailure("let x += 1", 'E1020:')
eddc81783052 patch 8.2.0483: Vim9: "let x = x + 1" does not give an error
Bram Moolenaar <Bram@vim.org>
parents: 19848
diff changeset
742 call CheckDefFailure("let x = x + 1", 'E1001:')
19461
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
743 call CheckDefExecFailure("let x = g:anint.member", 'E715:')
08ef11a81daa patch 8.2.0288: Vim9: some float and blob operators not tested
Bram Moolenaar <Bram@vim.org>
parents: 19451
diff changeset
744 call CheckDefExecFailure("let x = g:dict_empty.member", 'E716:')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
745 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
746
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
747 def Test_expr_member()
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
748 assert_equal(1, g:dict_one.one)
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
749
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
750 call CheckDefFailure("let x = g:dict_one.#$!", 'E1002:')
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
751 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
752
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
753 def Test_expr7_option()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
754 " option
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
755 set ts=11
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
756 assert_equal(11, &ts)
19449
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19437
diff changeset
757 &ts = 9
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19437
diff changeset
758 assert_equal(9, &ts)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
759 set ts=8
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
760 set grepprg=some\ text
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
761 assert_equal('some text', &grepprg)
19219
89931701e033 patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents: 19217
diff changeset
762 &grepprg = test_null_string()
89931701e033 patch 8.2.0168: Coverity warning for assigning NULL to an option
Bram Moolenaar <Bram@vim.org>
parents: 19217
diff changeset
763 assert_equal('', &grepprg)
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
764 set grepprg&
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
765 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
766
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
767 def Test_expr7_environment()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
768 " environment variable
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
769 assert_equal('testvar', $TESTVAR)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
770 assert_equal('', $ASDF_ASD_XXX)
19842
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
771
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
772 call CheckDefFailure("let x = $$$", 'E1002:')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
773 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
774
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
775 def Test_expr7_register()
19449
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19437
diff changeset
776 @a = 'register a'
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
777 assert_equal('register a', @a)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
778 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
779
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
780 def Test_expr7_parens()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
781 " (expr)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
782 assert_equal(4, (6 * 4) / 6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
783 assert_equal(0, 6 * ( 4 / 6 ))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
784
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
785 assert_equal(6, +6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
786 assert_equal(-6, -6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
787 assert_equal(6, --6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
788 assert_equal(6, -+-6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
789 assert_equal(-6, ---6)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
790 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
791
19848
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
792 def Test_expr7_negate()
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
793 assert_equal(-99, -99)
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
794 assert_equal(99, --99)
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
795 let nr = 88
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
796 assert_equal(-88, -nr)
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
797 assert_equal(88, --nr)
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
798 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
799
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
800 def Echo(arg): string
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
801 return arg
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
802 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
803
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
804 def s:EchoArg(arg): string
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
805 return arg
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
806 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
807
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
808 def Test_expr7_call()
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
809 assert_equal('yes', 'yes'->Echo())
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
810 assert_equal('yes', 'yes'->s:EchoArg())
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
811
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
812 call CheckDefFailure("let x = 'yes'->Echo", 'E107:')
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
813 enddef
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
814
36d629aa3d6e patch 8.2.0480: Vim9: some code is not tested
Bram Moolenaar <Bram@vim.org>
parents: 19842
diff changeset
815
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
816 def Test_expr7_not()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
817 assert_equal(true, !'')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
818 assert_equal(true, ![])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
819 assert_equal(false, !'asdf')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
820 assert_equal(false, ![2])
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
821 assert_equal(true, !!'asdf')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
822 assert_equal(true, !![2])
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
823
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
824 assert_equal(true, !test_null_partial())
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
825 assert_equal(false, !{-> 'yes'})
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
826
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
827 assert_equal(true, !test_null_dict())
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
828 assert_equal(true, !{})
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
829 assert_equal(false, !{'yes': 'no'})
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
830
19485
a09636ecee3c patch 8.2.0300: Vim9: expression test fails without channel support
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
831 if has('channel')
a09636ecee3c patch 8.2.0300: Vim9: expression test fails without channel support
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
832 assert_equal(true, !test_null_job())
a09636ecee3c patch 8.2.0300: Vim9: expression test fails without channel support
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
833 assert_equal(true, !test_null_channel())
a09636ecee3c patch 8.2.0300: Vim9: expression test fails without channel support
Bram Moolenaar <Bram@vim.org>
parents: 19483
diff changeset
834 endif
19483
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
835
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
836 assert_equal(true, !test_null_blob())
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
837 assert_equal(true, !0z)
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
838 assert_equal(false, !0z01)
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
839
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
840 assert_equal(true, !test_void())
0d3dcb4476ba patch 8.2.0299: Vim9: ISN_STORE with argument not tested
Bram Moolenaar <Bram@vim.org>
parents: 19469
diff changeset
841 assert_equal(true, !test_unknown())
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
842 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
843
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
844 func Test_expr7_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
845 call CheckDefFailure("let x = (12", "E110:")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
846
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
847 call CheckDefFailure("let x = -'xx'", "E1030:")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
848 call CheckDefFailure("let x = +'xx'", "E1030:")
19842
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
849 call CheckDefFailure("let x = -0z12", "E974:")
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
850 call CheckDefExecFailure("let x = -[8]", "E39:")
e4ade28bfaf7 patch 8.2.0477: Vim9: error messages not tested
Bram Moolenaar <Bram@vim.org>
parents: 19826
diff changeset
851 call CheckDefExecFailure("let x = -{'a': 1}", "E39:")
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
852
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
853 call CheckDefFailure("let x = @", "E1002:")
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
854 call CheckDefFailure("let x = @<", "E354:")
19217
1235c26d9f04 patch 8.2.0167: Coverity warning for ignoring return value
Bram Moolenaar <Bram@vim.org>
parents: 19181
diff changeset
855
19826
293a22b677a8 patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
856 call CheckDefFailure("let x = [1, 2", "E697:")
293a22b677a8 patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
857 call CheckDefFailure("let x = [notfound]", "E1001:")
293a22b677a8 patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
858
293a22b677a8 patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
859 call CheckDefFailure("let x = { -> 123) }", "E451:")
293a22b677a8 patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
860 call CheckDefFailure("let x = 123->{x -> x + 5) }", "E451:")
293a22b677a8 patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
861
19449
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19437
diff changeset
862 call CheckDefFailure("let x = &notexist", 'E113:')
f8408ba21982 patch 8.2.0282: Vim9: setting number option not tested
Bram Moolenaar <Bram@vim.org>
parents: 19437
diff changeset
863 call CheckDefExecFailure("&grepprg = [343]", 'E1051:')
19451
b26e96f7c12f patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents: 19449
diff changeset
864
b26e96f7c12f patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents: 19449
diff changeset
865 call CheckDefExecFailure("echo s:doesnt_exist", 'E121:')
b26e96f7c12f patch 8.2.0283: Vim9: failing to load script var not tested
Bram Moolenaar <Bram@vim.org>
parents: 19449
diff changeset
866 call CheckDefExecFailure("echo g:doesnt_exist", 'E121:')
19469
55656a51d2af patch 8.2.0292: Vim9: CHECKNR and CHECKTYPE instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19461
diff changeset
867
19822
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
868 call CheckDefFailure("echo a:somevar", 'E1075:')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
869 call CheckDefFailure("echo l:somevar", 'E1075:')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
870 call CheckDefFailure("echo x:somevar", 'E1075:')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
871
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
872 " TODO
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
873 call CheckDefFailure("echo b:somevar", 'not supported yet')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
874 call CheckDefFailure("echo w:somevar", 'not supported yet')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
875 call CheckDefFailure("echo t:somevar", 'not supported yet')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
876
19469
55656a51d2af patch 8.2.0292: Vim9: CHECKNR and CHECKTYPE instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19461
diff changeset
877 call CheckDefExecFailure("let x = +g:astring", 'E1030:')
55656a51d2af patch 8.2.0292: Vim9: CHECKNR and CHECKTYPE instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19461
diff changeset
878 call CheckDefExecFailure("let x = +g:ablob", 'E974:')
55656a51d2af patch 8.2.0292: Vim9: CHECKNR and CHECKTYPE instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19461
diff changeset
879 call CheckDefExecFailure("let x = +g:alist", 'E745:')
55656a51d2af patch 8.2.0292: Vim9: CHECKNR and CHECKTYPE instructions not tested
Bram Moolenaar <Bram@vim.org>
parents: 19461
diff changeset
880 call CheckDefExecFailure("let x = +g:adict", 'E728:')
19558
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
881
8eeec8886c02 patch 8.2.0336: Vim9: insufficient test coverage for compiling
Bram Moolenaar <Bram@vim.org>
parents: 19521
diff changeset
882 call CheckDefFailureMult(["let x = ''", "let y = x.memb"], 'E715:')
19822
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
883
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
884 call CheckDefExecFailure("[1, 2->len()", 'E492:')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
885 call CheckDefExecFailure("#{a: 1->len()", 'E488:')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
886 call CheckDefExecFailure("{'a': 1->len()", 'E492:')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
887 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
888
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
889 let g:Funcrefs = [function('add')]
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
890
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
891 func CallMe(arg)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
892 return a:arg
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
893 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
894
19437
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
895 func CallMe2(one, two)
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
896 return a:one .. a:two
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
897 endfunc
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
898
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
899 def Test_expr7_trailing()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
900 " user function call
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
901 assert_equal(123, CallMe(123))
19437
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
902 assert_equal(123, CallMe( 123))
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
903 assert_equal(123, CallMe(123 ))
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
904 assert_equal('yesno', CallMe2('yes', 'no'))
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
905 assert_equal('yesno', CallMe2( 'yes', 'no' ))
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
906 assert_equal('nothing', CallMe('nothing'))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
907
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
908 " partial call
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
909 let Part = function('CallMe')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
910 assert_equal('yes', Part('yes'))
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
911
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
912 " funcref call, using list index
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
913 let l = []
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
914 g:Funcrefs[0](l, 2)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
915 assert_equal([2], l)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
916
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
917 " method call
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
918 l = [2, 5, 6]
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
919 l->map({k, v -> k + v})
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
920 assert_equal([2, 6, 8], l)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
921
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
922 " lambda method call
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
923 l = [2, 5]
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
924 l->{l -> add(l, 8)}()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
925 assert_equal([2, 5, 8], l)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
926
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
927 " dict member
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
928 let d = #{key: 123}
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
929 assert_equal(123, d.key)
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
930 enddef
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
931
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
932 func Test_expr7_trailing_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
933 call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)}'], 'E107')
19826
293a22b677a8 patch 8.2.0469: Vim9: no error for missing ] after list
Bram Moolenaar <Bram@vim.org>
parents: 19822
diff changeset
934 call CheckDefFailureList(['let l = [2]', 'l->{l -> add(l, 8)} ()'], 'E274')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
935 endfunc
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
936
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
937 func Test_expr_fails()
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
938 call CheckDefFailure("let x = '1'is2", 'E488:')
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
939 call CheckDefFailure("let x = '1'isnot2", 'E488:')
19437
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
940
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
941 call CheckDefExecFailure("CallMe ('yes')", 'E492:')
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
942 call CheckDefFailure("CallMe2('yes','no')", 'E1069:')
5d34ae66118e patch 8.2.0276: Vim9: not allowing space before ")" in function call
Bram Moolenaar <Bram@vim.org>
parents: 19423
diff changeset
943 call CheckDefFailure("CallMe2('yes' , 'no')", 'E1068:')
19521
860b39ed0e0b patch 8.2.0318: Vim9: types not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19485
diff changeset
944
860b39ed0e0b patch 8.2.0318: Vim9: types not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19485
diff changeset
945 call CheckDefFailure("v:nosuch += 3", 'E1001:')
860b39ed0e0b patch 8.2.0318: Vim9: types not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19485
diff changeset
946 call CheckDefFailure("let v:version = 3", 'E1064:')
860b39ed0e0b patch 8.2.0318: Vim9: types not sufficiently tested
Bram Moolenaar <Bram@vim.org>
parents: 19485
diff changeset
947 call CheckDefFailure("let asdf = v:nosuch", 'E1001:')
19822
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
948
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
949 call CheckDefFailure("echo len('asdf'", 'E110:')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
950 call CheckDefFailure("echo Func0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789()", 'E1011:')
fc3cdc819d80 patch 8.2.0467: Vim9: some errors are not tested
Bram Moolenaar <Bram@vim.org>
parents: 19583
diff changeset
951 call CheckDefFailure("echo doesnotexist()", 'E117:')
19181
94eda51ba9ba patch 8.2.0149: maintaining a Vim9 branch separately is more work
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
952 endfunc