Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 19904:bd4f91762d0f v8.2.0508
patch 8.2.0508: Vim9: func and partial types not done yet
Commit: https://github.com/vim/vim/commit/d77a8525d5438cae49f670eb473ef60d87ca5f54
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 3 21:59:57 2020 +0200
patch 8.2.0508: Vim9: func and partial types not done yet
Problem: Vim9: func and partial types not done yet
Solution: Fill in details about func declaration, drop a separate partial
declaration.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 03 Apr 2020 22:15:03 +0200 |
parents | ea4f8e789627 |
children | d4fa9db88d16 |
comparison
equal
deleted
inserted
replaced
19903:dab021621df2 | 19904:bd4f91762d0f |
---|---|
66 if has('float') | 66 if has('float') |
67 let float1: float = 3.4 | 67 let float1: float = 3.4 |
68 endif | 68 endif |
69 let funky1: func | 69 let funky1: func |
70 let funky2: func = function('len') | 70 let funky2: func = function('len') |
71 let party1: partial | 71 let party2: func = funcref('Test_syntax') |
72 let party2: partial = funcref('Test_syntax') | |
73 | 72 |
74 " type becomes list<any> | 73 " type becomes list<any> |
75 let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] | 74 let somelist = rand() > 0 ? [1, 2, 3] : ['a', 'b', 'c'] |
76 " type becomes dict<any> | 75 " type becomes dict<any> |
77 let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} | 76 let somedict = rand() > 0 ? #{a: 1, b: 2} : #{a: 'a', b: 'b'} |
155 assert_equal(0z, theblob) | 154 assert_equal(0z, theblob) |
156 | 155 |
157 let thefunc: func | 156 let thefunc: func |
158 assert_equal(test_null_function(), thefunc) | 157 assert_equal(test_null_function(), thefunc) |
159 | 158 |
160 let thepartial: partial | |
161 assert_equal(test_null_partial(), thepartial) | |
162 | |
163 let thelist: list<any> | 159 let thelist: list<any> |
164 assert_equal([], thelist) | 160 assert_equal([], thelist) |
165 | 161 |
166 let thedict: dict<any> | 162 let thedict: dict<any> |
167 assert_equal({}, thedict) | 163 assert_equal({}, thedict) |
211 call CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>') | 207 call CheckDefFailure(['let var: dict<number> = #{key: "xx"}'], 'expected dict<number> but got dict<string>') |
212 | 208 |
213 call CheckDefFailure(['let var = feedkeys("0")'], 'E1031:') | 209 call CheckDefFailure(['let var = feedkeys("0")'], 'E1031:') |
214 call CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void') | 210 call CheckDefFailure(['let var: number = feedkeys("0")'], 'expected number but got void') |
215 | 211 |
216 call CheckDefFailure(['let var: dict <number>'], 'E1007:') | 212 call CheckDefFailure(['let var: dict <number>'], 'E1068:') |
217 call CheckDefFailure(['let var: dict<number'], 'E1009:') | 213 call CheckDefFailure(['let var: dict<number'], 'E1009:') |
218 endfunc | 214 endfunc |
219 | 215 |
220 func Test_wrong_type() | 216 func Test_wrong_type() |
221 call CheckDefFailure(['let var: list<nothing>'], 'E1010:') | 217 call CheckDefFailure(['let var: list<nothing>'], 'E1010:') |