Mercurial > vim
comparison src/testdir/test_vim9_script.vim @ 24025:edcb6cf55a26 v8.2.2554
patch 8.2.2554: Vim9: exporting a final is not tested
Commit: https://github.com/vim/vim/commit/0f2a5cc68b676b56694c27034690a7b9ef049feb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 27 22:33:21 2021 +0100
patch 8.2.2554: Vim9: exporting a final is not tested
Problem: Vim9: exporting a final is not tested.
Solution: Add a test.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Feb 2021 22:45:03 +0100 |
parents | 5dbed4837ea3 |
children | 8298c0798040 |
comparison
equal
deleted
inserted
replaced
24024:ef454a7f485d | 24025:edcb6cf55a26 |
---|---|
916 export var exported = 9876 | 916 export var exported = 9876 |
917 export var exp_name = 'John' | 917 export var exp_name = 'John' |
918 export def Exported(): string | 918 export def Exported(): string |
919 return 'Exported' | 919 return 'Exported' |
920 enddef | 920 enddef |
921 export final theList = [1] | |
921 END | 922 END |
922 | 923 |
923 def Undo_export_script_lines() | 924 def Undo_export_script_lines() |
924 unlet g:result | 925 unlet g:result |
925 unlet g:localname | 926 unlet g:localname |
943 import {exp_name} from './Xexport.vim' | 944 import {exp_name} from './Xexport.vim' |
944 g:imported_name = exp_name | 945 g:imported_name = exp_name |
945 exp_name ..= ' Doe' | 946 exp_name ..= ' Doe' |
946 g:imported_name_appended = exp_name | 947 g:imported_name_appended = exp_name |
947 g:imported_later = exported | 948 g:imported_later = exported |
949 | |
950 import theList from './Xexport.vim' | |
951 theList->add(2) | |
952 assert_equal([1, 2], theList) | |
948 END | 953 END |
949 | 954 |
950 writefile(import_script_lines, 'Ximport.vim') | 955 writefile(import_script_lines, 'Ximport.vim') |
951 writefile(s:export_script_lines, 'Xexport.vim') | 956 writefile(s:export_script_lines, 'Xexport.vim') |
952 | 957 |
1140 CONST = 987 | 1145 CONST = 987 |
1141 enddef | 1146 enddef |
1142 defcompile | 1147 defcompile |
1143 END | 1148 END |
1144 writefile(import_assign_to_const, 'Ximport.vim') | 1149 writefile(import_assign_to_const, 'Ximport.vim') |
1150 assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') | |
1151 | |
1152 # try changing an imported final | |
1153 var import_assign_to_final =<< trim END | |
1154 vim9script | |
1155 import theList from './Xexport.vim' | |
1156 def Assign() | |
1157 theList = [2] | |
1158 enddef | |
1159 defcompile | |
1160 END | |
1161 writefile(import_assign_to_final, 'Ximport.vim') | |
1145 assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') | 1162 assert_fails('source Ximport.vim', 'E46:', '', 1, '_Assign') |
1146 | 1163 |
1147 # import a very long name, requires making a copy | 1164 # import a very long name, requires making a copy |
1148 var import_long_name_lines =<< trim END | 1165 var import_long_name_lines =<< trim END |
1149 vim9script | 1166 vim9script |