summaryrefslogtreecommitdiffstats
path: root/src/testdir
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:10:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 02:10:58 +0000
commitbee19c22d569e54513a9c591441c7f411811dc81 (patch)
treeb990d2df9fddb8194bfe49e9205005a0d952bc1f /src/testdir
parentAdding upstream version 2:9.1.0199. (diff)
downloadvim-bee19c22d569e54513a9c591441c7f411811dc81.tar.xz
vim-bee19c22d569e54513a9c591441c7f411811dc81.zip
Adding upstream version 2:9.1.0374.upstream/2%9.1.0374
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/testdir')
-rw-r--r--src/testdir/Make_all.mak5
-rw-r--r--src/testdir/Makefile2
-rw-r--r--src/testdir/dumps/Test_ambiwidth_hl_dump_1.dump6
-rw-r--r--src/testdir/dumps/Test_ambiwidth_hl_dump_2.dump6
-rw-r--r--src/testdir/dumps/Test_display_visual_block_scroll.dump10
-rw-r--r--src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1.dump16
-rw-r--r--src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2.dump16
-rw-r--r--src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3.dump16
-rw-r--r--src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4.dump16
-rw-r--r--src/testdir/dumps/Test_props_with_text_truncated_just_before_after_1.dump8
-rw-r--r--src/testdir/dumps/Test_props_with_text_truncated_just_before_after_2.dump8
-rw-r--r--src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_1.dump6
-rw-r--r--src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_2.dump6
-rw-r--r--src/testdir/dumps/Test_smooth_long_6.dump2
-rw-r--r--src/testdir/dumps/Test_smooth_long_7.dump2
-rw-r--r--src/testdir/test_autocmd.vim351
-rw-r--r--src/testdir/test_buffer.vim23
-rw-r--r--src/testdir/test_cmdline.vim23
-rw-r--r--src/testdir/test_cmdmods.vim6
-rw-r--r--src/testdir/test_codestyle.vim8
-rw-r--r--src/testdir/test_compiler.vim4
-rw-r--r--src/testdir/test_conceal.vim1
-rw-r--r--src/testdir/test_diffmode.vim62
-rw-r--r--src/testdir/test_digraph.vim4
-rw-r--r--src/testdir/test_edit.vim156
-rw-r--r--src/testdir/test_expr.vim16
-rw-r--r--src/testdir/test_filechanged.vim34
-rw-r--r--src/testdir/test_filetype.vim106
-rw-r--r--src/testdir/test_functions.vim37
-rw-r--r--src/testdir/test_highlight.vim9
-rw-r--r--src/testdir/test_history.vim2
-rw-r--r--src/testdir/test_ins_complete.vim24
-rw-r--r--src/testdir/test_let.vim132
-rw-r--r--src/testdir/test_listdict.vim6
-rw-r--r--src/testdir/test_mapping.vim67
-rw-r--r--src/testdir/test_match.vim2
-rw-r--r--src/testdir/test_mksession.vim4
-rw-r--r--src/testdir/test_normal.vim93
-rw-r--r--src/testdir/test_put.vim17
-rw-r--r--src/testdir/test_recover.vim2
-rw-r--r--src/testdir/test_regexp_latin.vim14
-rw-r--r--src/testdir/test_regexp_utf8.vim2
-rw-r--r--src/testdir/test_registers.vim69
-rw-r--r--src/testdir/test_remote.vim45
-rw-r--r--src/testdir/test_scroll_opt.vim116
-rw-r--r--src/testdir/test_sound.vim2
-rw-r--r--src/testdir/test_tabpage.vim8
-rw-r--r--src/testdir/test_taglist.vim5
-rw-r--r--src/testdir/test_terminal3.vim20
-rw-r--r--src/testdir/test_textformat.vim9
-rw-r--r--src/testdir/test_textprop.vim79
-rw-r--r--src/testdir/test_utf8.vim121
-rw-r--r--src/testdir/test_vim9_assign.vim106
-rw-r--r--src/testdir/test_vim9_builtin.vim2232
-rw-r--r--src/testdir/test_vim9_class.vim236
-rw-r--r--src/testdir/test_vim9_disassemble.vim30
-rw-r--r--src/testdir/test_vim9_enum.vim1537
-rw-r--r--src/testdir/test_vim9_func.vim31
-rw-r--r--src/testdir/test_vim9_import.vim243
-rw-r--r--src/testdir/test_vim9_script.vim130
-rw-r--r--src/testdir/test_visual.vim2
-rw-r--r--src/testdir/test_winfixbuf.vim415
-rw-r--r--src/testdir/test_xdg.vim295
-rw-r--r--src/testdir/vim9.vim208
64 files changed, 5683 insertions, 1586 deletions
diff --git a/src/testdir/Make_all.mak b/src/testdir/Make_all.mak
index c4403e6..b41f5f4 100644
--- a/src/testdir/Make_all.mak
+++ b/src/testdir/Make_all.mak
@@ -40,6 +40,7 @@ TEST_VIM9 = \
test_vim9_class \
test_vim9_cmd \
test_vim9_disassemble \
+ test_vim9_enum \
test_vim9_expr \
test_vim9_fails \
test_vim9_func \
@@ -53,6 +54,7 @@ TEST_VIM9_RES = \
test_vim9_class.res \
test_vim9_cmd.res \
test_vim9_disassemble.res \
+ test_vim9_enum.res \
test_vim9_expr.res \
test_vim9_fails.res \
test_vim9_func.res \
@@ -329,6 +331,7 @@ NEW_TESTS = \
test_wnext \
test_wordcount \
test_writefile \
+ test_xdg \
test_xxd \
test_alot_latin \
test_alot_utf8 \
@@ -459,6 +462,7 @@ NEW_TESTS_RES = \
test_matchadd_conceal.res \
test_matchadd_conceal_utf8.res \
test_matchfuzzy.res \
+ test_matchparen.res \
test_memory_usage.res \
test_menu.res \
test_messages.res \
@@ -561,6 +565,7 @@ NEW_TESTS_RES = \
test_winfixbuf.res \
test_wordcount.res \
test_writefile.res \
+ test_xdg.res \
test_xxd.res \
test_alot_latin.res \
test_alot_utf8.res \
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
index fd2e56c..4e476f9 100644
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -89,7 +89,7 @@ RUN_VIM = VIMRUNTIME=$(SCRIPTSOURCE) $(VALGRIND) $(VIMPROG) -f $(GUI_FLAG) -u un
# Delete files that may interfere with running tests. This includes some files
# that may result from working on the tests, not only from running them.
clean:
- -rm -rf *.out *.failed *.res *.rej *.orig XfakeHOME Xdir1 Xfind
+ -rm -rf *.out *.failed *.res *.rej *.orig XfakeHOME Xdir1 Xfind failed
-rm -f opt_test.vim test_result.log $(CLEANUP_FILES)
-rm -rf $(RM_ON_RUN) $(RM_ON_START)
-rm -f valgrind.*
diff --git a/src/testdir/dumps/Test_ambiwidth_hl_dump_1.dump b/src/testdir/dumps/Test_ambiwidth_hl_dump_1.dump
new file mode 100644
index 0000000..383a6f4
--- /dev/null
+++ b/src/testdir/dumps/Test_ambiwidth_hl_dump_1.dump
@@ -0,0 +1,6 @@
+>℃+8&#ffffff0@49
+@10|$+8#4040ff13&| +8#0000000&@38
+|℃+0&&@49
+@10|$+0#4040ff13&| +0#0000000&@38
+|~+0#4040ff13&| @48
+| +0#0000000&@31|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_ambiwidth_hl_dump_2.dump b/src/testdir/dumps/Test_ambiwidth_hl_dump_2.dump
new file mode 100644
index 0000000..81aeb7b
--- /dev/null
+++ b/src/testdir/dumps/Test_ambiwidth_hl_dump_2.dump
@@ -0,0 +1,6 @@
+>℃+8&#ffffff0| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃|
+|℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃|
+|℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |$+8#4040ff13&| +8#0000000&@28
+|℃+0&&| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃|
+|℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| |℃| @1|@+0#4040ff13&@2
+| +0#0000000&@31|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_display_visual_block_scroll.dump b/src/testdir/dumps/Test_display_visual_block_scroll.dump
index afb52fb..36eae0c 100644
--- a/src/testdir/dumps/Test_display_visual_block_scroll.dump
+++ b/src/testdir/dumps/Test_display_visual_block_scroll.dump
@@ -1,7 +1,7 @@
-|{+0&#e0e0e08| | +0&#ffffff0@72
-|}+0&#e0e0e08| | +0&#ffffff0@72
-|{+0&#e0e0e08| | +0&#ffffff0@72
-|f+0&#e0e0e08| | +0&#ffffff0@72
->g| +0&#e0e0e08| +0&#ffffff0@72
+|{+0#0000001#a8a8a8255| | +0#0000000#ffffff0@72
+|}+0#0000001#a8a8a8255| | +0#0000000#ffffff0@72
+|{+0#0000001#a8a8a8255| | +0#0000000#ffffff0@72
+|f+0#0000001#a8a8a8255| | +0#0000000#ffffff0@72
+>g| +0#0000001#a8a8a8255| +0#0000000#ffffff0@72
|}| @73
|-+2&&@1| |V|I|S|U|A|L| |L|I|N|E| |-@1| +0&&@29|7| @8|1@1|,|1| @9|B|o|t|
diff --git a/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1.dump b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1.dump
new file mode 100644
index 0000000..7a0b848
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1.dump
@@ -0,0 +1,16 @@
+| +0#af5f00255#ffffff0@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|1| |F+0#0000000&|i|r>s|t| |l|i|n|e| |f|i|t|s| |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|2| |A+0#0000001#ffff4012|f|t|e|r| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@5
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3| +0#0000000&@35
+| +0#af5f00255&@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|3| |T+0#0000000&|h|i|r|d| |l|i|n|e| |f|i|t|s| |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+@22|1|,|4|-|4|0| @7|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2.dump b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2.dump
new file mode 100644
index 0000000..d463990
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2.dump
@@ -0,0 +1,16 @@
+| +0#af5f00255#ffffff0@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|1| |F+0#0000000&|i|r|s|t| |l|i|n|e| |f|i|t|s| |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|2| >A+0#0000001#ffff4012|f|t|e|r| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@5
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3| +0#0000000&@35
+| +0#af5f00255&@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|3| |T+0#0000000&|h|i|r|d| |l|i|n|e| |f|i|t|s| |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+@22|2|,|0|-|3|7| @7|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3.dump b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3.dump
new file mode 100644
index 0000000..85a469d
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3.dump
@@ -0,0 +1,16 @@
+| +0#af5f00255#ffffff0@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|1| |F+0#0000000&|i|r|s|t| |l|i|n|e| |f|i|t|s| |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|2| |A+0#0000001#ffff4012|f|t|e|r| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@5
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3| +0#0000000&@35
+| +0#af5f00255&@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|3| |T+0#0000000&|h|i>r|d| |l|i|n|e| |f|i|t|s| |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+@22|3|,|4|-|4|0| @7|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4.dump b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4.dump
new file mode 100644
index 0000000..2c03fdf
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4.dump
@@ -0,0 +1,16 @@
+| +0#af5f00255#ffffff0@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|1| |F+0#0000000&|i|r|s|t| |l|i|n|e| |f|i|t|s> |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|2| |A+0#0000001#ffff4012|f|t|e|r| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@5
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3| +0#0000000&@35
+| +0#af5f00255&@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+| +0#af5f00255&@3|A+0#0000001#ffff4012|b|o|v|e| +0#0000000#ffffff0@30
+| +0#af5f00255&@1|3| |T+0#0000000&|h|i|r|d| |l|i|n|e| |f|i|t|s| |o|n| |s|c|r|e@1|n| |l|i|n|e|.|A+0#0000001#ffff4012|f|t|e|r
+| +0#af5f00255#ffffff0@3| +0#0000001#ffff4012|t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.| +0#0000000#ffffff0@10
+| +0#af5f00255&@3| +0#0000000&@5|R+0#0000001#ffff4012|i|g|h|t| |t|e|x|t| |w|r|a|p|s| |t|o| |n|e|x|t| |l|i|n|e|.
+| +0#af5f00255#ffffff0@3|B+0#0000001#ffff4012|e|l|o|w| +0#0000000#ffffff0@30
+@22|1|,|1|6|-|5|2| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_1.dump b/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_1.dump
new file mode 100644
index 0000000..f46f47e
--- /dev/null
+++ b/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_1.dump
@@ -0,0 +1,8 @@
+|h+0&#ffffff0|e|r|e| |i|s| |t|e|x|t| |l|o|n|g| |e|n|o|u|g|h| |t|o| |f|i|l@1| |t|h|e| |r|o|>+0#4040ff13&
+|s+0#0000000&|e|c|o|n|d| |l|i|n>e| @28
+|~+0#4040ff13&| @38
+|~| @38
+|~| @38
+|~| @38
+|~| @38
+| +0#0000000&@21|2|,|1@1| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_2.dump b/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_2.dump
new file mode 100644
index 0000000..3434669
--- /dev/null
+++ b/src/testdir/dumps/Test_props_with_text_truncated_just_before_after_2.dump
@@ -0,0 +1,8 @@
+|h+0&#ffffff0|e|r|e| |i|s| |t|e|x|t| |l|o|n|g| |e|n|o|u|g|h| |t|o| |f|i|l@1| |t|h|e| |r|o|>+0#4040ff13&
+|b+0#ffffff16#ff404010|e|l|o|w| |t|e|x|t| +0#0000000#ffffff0@29
+|s|e|c|o|n|d| |l|i|n>e| @28
+|~+0#4040ff13&| @38
+|~| @38
+|~| @38
+|~| @38
+| +0#0000000&@21|2|,|1@1| @9|A|l@1|
diff --git a/src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_1.dump b/src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_1.dump
new file mode 100644
index 0000000..73f4418
--- /dev/null
+++ b/src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_1.dump
@@ -0,0 +1,6 @@
+>➜+0&#ffffff0@49
+@10| @39
+|➜@49
+@10| @39
+|~+0#4040ff13&| @48
+| +0#0000000&@31|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_2.dump b/src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_2.dump
new file mode 100644
index 0000000..2b575f6
--- /dev/null
+++ b/src/testdir/dumps/Test_setcellwidths_with_non_ambiwidth_character_dump_2.dump
@@ -0,0 +1,6 @@
+>➜+0&#ffffff0| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜|
+|➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜|
+|➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| @30
+|➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜| |➜|
+|@+0#4040ff13&@2| @46
+| +0#0000000&@31|1|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_smooth_long_6.dump b/src/testdir/dumps/Test_smooth_long_6.dump
index ba48c28..507aa46 100644
--- a/src/testdir/dumps/Test_smooth_long_6.dump
+++ b/src/testdir/dumps/Test_smooth_long_6.dump
@@ -3,4 +3,4 @@
|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o
|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e
|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w
-| @21|3|,|9|0| @9|6@1|%|
+|:|s|e|t| |s|c|r|o|l@1|o| @9|3|,|9|0| @9|6@1|%|
diff --git a/src/testdir/dumps/Test_smooth_long_7.dump b/src/testdir/dumps/Test_smooth_long_7.dump
index 222e001..225207f 100644
--- a/src/testdir/dumps/Test_smooth_long_7.dump
+++ b/src/testdir/dumps/Test_smooth_long_7.dump
@@ -3,4 +3,4 @@
|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o
|f| |t|e|x|t| |w|i>t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e
|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w
-| @21|3|,|1|7|0| @8|6@1|%|
+|:|s|e|t| |s|c|r|o|l@1|o| @9|3|,|1|7|0| @8|6@1|%|
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 564d568..6745ecb 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -3702,73 +3702,6 @@ func Test_autocmd_with_block()
augroup END
endfunc
-" Test TextChangedI and TextChanged
-func Test_Changed_ChangedI()
- new
- call test_override("char_avail", 1)
- let [g:autocmd_i, g:autocmd_n] = ['','']
-
- func! TextChangedAutocmdI(char)
- let g:autocmd_{tolower(a:char)} = a:char .. b:changedtick
- endfunc
-
- augroup Test_TextChanged
- au!
- au TextChanged <buffer> :call TextChangedAutocmdI('N')
- au TextChangedI <buffer> :call TextChangedAutocmdI('I')
- augroup END
-
- call feedkeys("ifoo\<esc>", 'tnix')
- " TODO: Test test does not seem to trigger TextChanged autocommand, this
- " requires running Vim in a terminal window.
- " call assert_equal('N3', g:autocmd_n)
- call assert_equal('I3', g:autocmd_i)
-
- call feedkeys("yyp", 'tnix')
- " TODO: Test test does not seem to trigger TextChanged autocommand.
- " call assert_equal('N4', g:autocmd_n)
- call assert_equal('I3', g:autocmd_i)
-
- " TextChangedI should only trigger if change was done in Insert mode
- let g:autocmd_i = ''
- call feedkeys("yypi\<esc>", 'tnix')
- call assert_equal('', g:autocmd_i)
-
- " TextChanged should only trigger if change was done in Normal mode
- let g:autocmd_n = ''
- call feedkeys("ibar\<esc>", 'tnix')
- call assert_equal('', g:autocmd_n)
-
- " If change is a mix of Normal and Insert modes, TextChangedI should trigger
- func s:validate_mixed_textchangedi(keys)
- call feedkeys("ifoo\<esc>", 'tnix')
- let g:autocmd_i = ''
- let g:autocmd_n = ''
- call feedkeys(a:keys, 'tnix')
- call assert_notequal('', g:autocmd_i)
- call assert_equal('', g:autocmd_n)
- endfunc
-
- call s:validate_mixed_textchangedi("o\<esc>")
- call s:validate_mixed_textchangedi("O\<esc>")
- call s:validate_mixed_textchangedi("ciw\<esc>")
- call s:validate_mixed_textchangedi("cc\<esc>")
- call s:validate_mixed_textchangedi("C\<esc>")
- call s:validate_mixed_textchangedi("s\<esc>")
- call s:validate_mixed_textchangedi("S\<esc>")
-
-
- " CleanUp
- call test_override("char_avail", 0)
- au! TextChanged <buffer>
- au! TextChangedI <buffer>
- augroup! Test_TextChanged
- delfu TextChangedAutocmdI
- unlet! g:autocmd_i g:autocmd_n
-
- bw!
-endfunc
-
func Test_closing_autocmd_window()
let lines =<< trim END
edit Xa.txt
@@ -3794,6 +3727,49 @@ func Test_switch_window_in_autocmd_window()
call assert_false(bufexists('Xb.txt'))
endfunc
+" Test that using the autocommand window doesn't change current directory.
+func Test_autocmd_window_cwd()
+ let saveddir = getcwd()
+ call mkdir('Xcwd/a/b/c/d', 'pR')
+
+ new Xa.txt
+ tabnew
+ new Xb.txt
+
+ tabprev
+ cd Xcwd
+ call assert_match('/Xcwd$', getcwd())
+ call assert_match('\[global\] .*/Xcwd$', trim(execute('verbose pwd')))
+
+ autocmd BufEnter Xb.txt lcd ./a/b/c/d
+ doautoall BufEnter
+ au! BufEnter
+ call assert_match('/Xcwd$', getcwd())
+ call assert_match('\[global\] .*/Xcwd$', trim(execute('verbose pwd')))
+
+ tabnext
+ cd ./a
+ tcd ./b
+ lcd ./c
+ call assert_match('/Xcwd/a/b/c$', getcwd())
+ call assert_match('\[window\] .*/Xcwd/a/b/c$', trim(execute('verbose pwd')))
+
+ autocmd BufEnter Xa.txt call assert_match('Xcwd/a/b/c$', getcwd())
+ doautoall BufEnter
+ au! BufEnter
+ call assert_match('/Xcwd/a/b/c$', getcwd())
+ call assert_match('\[window\] .*/Xcwd/a/b/c$', trim(execute('verbose pwd')))
+ bwipe!
+ call assert_match('/Xcwd/a/b$', getcwd())
+ call assert_match('\[tabpage\] .*/Xcwd/a/b$', trim(execute('verbose pwd')))
+ bwipe!
+ call assert_match('/Xcwd/a$', getcwd())
+ call assert_match('\[global\] .*/Xcwd/a$', trim(execute('verbose pwd')))
+ bwipe!
+
+ call chdir(saveddir)
+endfunc
+
func Test_bufwipeout_changes_window()
" This should not crash, but we don't have any expectations about what
" happens, changing window in BufWipeout has unpredictable results.
@@ -4474,4 +4450,245 @@ func Test_autocmd_creates_new_buffer_on_bufleave()
bw c.txt
endfunc
+" Ensure `expected` was just recently written as a Vim session
+func s:assert_session_path(expected)
+ call assert_equal(a:expected, v:this_session)
+endfunc
+
+" Check for `expected` after a session is written to-disk.
+func s:watch_for_session_path(expected)
+ execute 'autocmd SessionWritePost * ++once execute "call s:assert_session_path(\"'
+ \ . a:expected
+ \ . '\")"'
+endfunc
+
+" Ensure v:this_session gets the full session path, if explicitly stated
+func Test_explicit_session_absolute_path()
+ %bwipeout!
+
+ let directory = getcwd()
+
+ let v:this_session = ""
+ let name = "some_file.vim"
+ let expected = fnamemodify(name, ":p")
+ call s:watch_for_session_path(expected)
+ execute "mksession! " .. expected
+
+ call delete(expected)
+endfunc
+
+" Ensure v:this_session gets the full session path, if explicitly stated
+func Test_explicit_session_relative_path()
+ %bwipeout!
+
+ let directory = getcwd()
+
+ let v:this_session = ""
+ let name = "some_file.vim"
+ let expected = fnamemodify(name, ":p")
+ call s:watch_for_session_path(expected)
+ execute "mksession! " .. name
+
+ call delete(expected)
+endfunc
+
+" Ensure v:this_session gets the full session path, if not specified
+func Test_implicit_session()
+ %bwipeout!
+
+ let directory = getcwd()
+
+ let v:this_session = ""
+ let expected = fnamemodify("Session.vim", ":p")
+ call s:watch_for_session_path(expected)
+ mksession!
+
+ call delete(expected)
+endfunc
+
+" Test TextChangedI and TextChanged
+func Test_Changed_ChangedI()
+ " Run this test in a terminal because it requires running the main loop.
+ " Don't use CheckRunVimInTerminal as that will skip the test on Windows.
+ CheckFeature terminal
+ CheckNotGui
+ " Starting a terminal to run Vim is always considered flaky.
+ let g:test_is_flaky = 1
+
+ call writefile(['one', 'two', 'three'], 'XTextChangedI2', 'D')
+ let before =<< trim END
+ set ttimeout ttimeoutlen=10
+ let [g:autocmd_n, g:autocmd_i] = ['','']
+
+ func TextChangedAutocmd(char)
+ let g:autocmd_{tolower(a:char)} = a:char .. b:changedtick
+ call writefile([$'{g:autocmd_n},{g:autocmd_i}'], 'XTextChangedI3')
+ endfunc
+
+ au TextChanged <buffer> :call TextChangedAutocmd('N')
+ au TextChangedI <buffer> :call TextChangedAutocmd('I')
+
+ nnoremap <CR> o<Esc>
+ autocmd SafeState * ++once call writefile([''], 'XTextChangedI3')
+ END
+
+ call writefile(before, 'Xinit', 'D')
+ let buf = term_start(
+ \ GetVimCommandCleanTerm() .. '-n -S Xinit XTextChangedI2',
+ \ {'term_rows': 10})
+ call assert_equal('running', term_getstatus(buf))
+ call WaitForAssert({-> assert_true(filereadable('XTextChangedI3'))})
+ defer delete('XTextChangedI3')
+ call WaitForAssert({-> assert_equal([''], readfile('XTextChangedI3'))})
+
+ " TextChanged should trigger if a mapping enters and leaves Insert mode.
+ call term_sendkeys(buf, "\<CR>")
+ call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))})
+
+ call term_sendkeys(buf, "i")
+ call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
+ call WaitForAssert({-> assert_equal('N4,', readfile('XTextChangedI3')->join("\n"))})
+ " TextChangedI should trigger if change is done in Insert mode.
+ call term_sendkeys(buf, "f")
+ call WaitForAssert({-> assert_equal('N4,I5', readfile('XTextChangedI3')->join("\n"))})
+ call term_sendkeys(buf, "o")
+ call WaitForAssert({-> assert_equal('N4,I6', readfile('XTextChangedI3')->join("\n"))})
+ call term_sendkeys(buf, "o")
+ call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))})
+ " TextChanged shouldn't trigger when leaving Insert mode and TextChangedI
+ " has been triggered.
+ call term_sendkeys(buf, "\<Esc>")
+ call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
+ call WaitForAssert({-> assert_equal('N4,I7', readfile('XTextChangedI3')->join("\n"))})
+
+ " TextChanged should trigger if change is done in Normal mode.
+ call term_sendkeys(buf, "yyp")
+ call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
+
+ " TextChangedI shouldn't trigger if change isn't done in Insert mode.
+ call term_sendkeys(buf, "i")
+ call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
+ call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
+ call term_sendkeys(buf, "\<Esc>")
+ call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
+ call WaitForAssert({-> assert_equal('N8,I7', readfile('XTextChangedI3')->join("\n"))})
+
+ " TextChangedI should trigger if change is a mix of Normal and Insert modes.
+ func! s:validate_mixed_textchangedi(buf, keys)
+ let buf = a:buf
+ call term_sendkeys(buf, "ifoo")
+ call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
+ call term_sendkeys(buf, "\<Esc>")
+ call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
+ call term_sendkeys(buf, ":let [g:autocmd_n, g:autocmd_i] = ['', '']\<CR>")
+ call writefile([], 'XTextChangedI3')
+ call term_sendkeys(buf, a:keys)
+ call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 10))})
+ call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))})
+ call term_sendkeys(buf, "\<Esc>")
+ call WaitForAssert({-> assert_notmatch('^-- INSERT --', term_getline(buf, 10))})
+ call WaitForAssert({-> assert_match('^,I\d\+', readfile('XTextChangedI3')->join("\n"))})
+ endfunc
+
+ call s:validate_mixed_textchangedi(buf, "o")
+ call s:validate_mixed_textchangedi(buf, "O")
+ call s:validate_mixed_textchangedi(buf, "ciw")
+ call s:validate_mixed_textchangedi(buf, "cc")
+ call s:validate_mixed_textchangedi(buf, "C")
+ call s:validate_mixed_textchangedi(buf, "s")
+ call s:validate_mixed_textchangedi(buf, "S")
+
+ " clean up
+ bwipe!
+endfunc
+
+" Test that filetype detection still works when SwapExists autocommand sets
+" filetype in another buffer.
+func Test_SwapExists_set_other_buf_filetype()
+ let lines =<< trim END
+ set nocompatible directory=.
+ filetype on
+
+ let g:buf = bufnr()
+ new
+
+ func SwapExists()
+ let v:swapchoice = 'o'
+ call setbufvar(g:buf, '&filetype', 'text')
+ endfunc
+
+ func SafeState()
+ edit <script>
+ redir! > XftSwapExists.out
+ set readonly? filetype?
+ redir END
+ qall!
+ endfunc
+
+ autocmd SwapExists * ++nested call SwapExists()
+ autocmd SafeState * ++nested ++once call SafeState()
+ END
+ call writefile(lines, 'XftSwapExists.vim', 'D')
+
+ new XftSwapExists.vim
+ if RunVim('', '', ' -S XftSwapExists.vim')
+ call assert_equal(
+ \ ['', ' readonly', ' filetype=vim'],
+ \ readfile('XftSwapExists.out'))
+ call delete('XftSwapExists.out')
+ endif
+
+ bwipe!
+endfunc
+
+" Test that file is not marked as modified when SwapExists autocommand sets
+" 'modified' in another buffer.
+func Test_SwapExists_set_other_buf_modified()
+ let lines =<< trim END
+ set nocompatible directory=.
+
+ let g:buf = bufnr()
+ new
+
+ func SwapExists()
+ let v:swapchoice = 'o'
+ call setbufvar(g:buf, '&modified', 1)
+ endfunc
+
+ func SafeState()
+ edit <script>
+ redir! > XmodSwapExists.out
+ set readonly? modified?
+ redir END
+ qall!
+ endfunc
+
+ autocmd SwapExists * ++nested call SwapExists()
+ autocmd SafeState * ++nested ++once call SafeState()
+ END
+ call writefile(lines, 'XmodSwapExists.vim', 'D')
+
+ new XmodSwapExists.vim
+ if RunVim('', '', ' -S XmodSwapExists.vim')
+ call assert_equal(
+ \ ['', ' readonly', 'nomodified'],
+ \ readfile('XmodSwapExists.out'))
+ call delete('XmodSwapExists.out')
+ endif
+
+ bwipe!
+endfunc
+
+func Test_BufEnter_botline()
+ set hidden
+ call writefile(range(10), 'Xxx1', 'D')
+ call writefile(range(20), 'Xxx2', 'D')
+ edit Xxx1
+ edit Xxx2
+ au BufEnter Xxx1 call assert_true(line('w$') > 1)
+ edit Xxx1
+ au! BufEnter Xxx1
+ set hidden&vim
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_buffer.vim b/src/testdir/test_buffer.vim
index bc29c21..de088bd 100644
--- a/src/testdir/test_buffer.vim
+++ b/src/testdir/test_buffer.vim
@@ -133,7 +133,7 @@ func Test_bdelete_cmd()
call assert_fails('1,1bdelete 1 2', 'E488:')
call assert_fails('bdelete \)', 'E55:')
- " Deleting a unlisted and unloaded buffer
+ " Deleting an unlisted and unloaded buffer
edit Xbdelfile1
let bnr = bufnr()
set nobuflisted
@@ -252,21 +252,30 @@ func Test_goto_buf_with_confirm()
CheckUnix
CheckNotGui
CheckFeature dialog_con
+ " When dialog_con_gui is defined, Vim is compiled with GUI support
+ " and FEAT_BROWSE will be defined, which causes :confirm :b to
+ " call do_browse(), which will try to use a GUI file browser,
+ " which aborts if a GUI is not available.
+ CheckNotFeature dialog_con_gui
new XgotoConf
enew
call setline(1, 'test')
call assert_fails('b XgotoConf', 'E37:')
call feedkeys('c', 'L')
call assert_fails('confirm b XgotoConf', 'E37:')
- call assert_equal(1, &modified)
- call assert_equal('', @%)
+ call assert_true(&modified)
+ call assert_true(empty(bufname('%')))
call feedkeys('y', 'L')
- call assert_fails('confirm b XgotoConf', ['', 'E37:'])
- call assert_equal(1, &modified)
- call assert_equal('', @%)
+ confirm b XgotoConf
+ call assert_equal('XgotoConf', bufname('%'))
+ call assert_equal(['test'], readfile('Untitled'))
+ e Untitled
+ call setline(2, 'test2')
call feedkeys('n', 'L')
confirm b XgotoConf
- call assert_equal('XgotoConf', @%)
+ call assert_equal('XgotoConf', bufname('%'))
+ call assert_equal(['test'], readfile('Untitled'))
+ call delete('Untitled')
close!
endfunc
diff --git a/src/testdir/test_cmdline.vim b/src/testdir/test_cmdline.vim
index 7c86bcd..ed8f89d 100644
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -3733,9 +3733,9 @@ func Test_custom_completion()
call assert_fails("call getcompletion('', 'custom')", 'E475:')
call assert_fails("call getcompletion('', 'customlist')", 'E475:')
- call assert_equal(getcompletion('', 'custom,CustomComplete1'), ['a', 'b', 'c'])
- call assert_equal(getcompletion('', 'customlist,CustomComplete2'), ['a', 'b'])
- call assert_equal(getcompletion('b', 'customlist,CustomComplete2'), ['b'])
+ call assert_equal(['a', 'b', 'c'], getcompletion('', 'custom,CustomComplete1'))
+ call assert_equal(['a', 'b'], getcompletion('', 'customlist,CustomComplete2'))
+ call assert_equal(['b'], getcompletion('b', 'customlist,CustomComplete2'))
delcom Test1
delcom Test2
@@ -3792,4 +3792,21 @@ func Test_buffer_completion()
call assert_equal("\"b Xbuf_complete/Foobar.c Xbuf_complete/MyFoobar.c AFoobar.h", @:)
endfunc
+" :set t_??
+func Test_term_option()
+ set wildoptions&
+ let _cpo = &cpo
+ set cpo-=C
+ " There may be more, test only until t_xo
+ let expected='"set t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD t_cd t_ce t_Ce t_CF t_cl t_cm'
+ \ .. ' t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds t_Ds t_EC t_EI t_fs t_fd t_fe'
+ \ .. ' t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RF t_RB t_RC'
+ \ .. ' t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf t_SH t_SI t_Si t_so t_SR t_sr'
+ \ .. ' t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue t_us t_Us t_ut t_vb t_ve t_vi'
+ \ .. ' t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f t_8b t_8u t_xo .*'
+ call feedkeys(":set t_\<C-A>\<C-B>\"\<CR>", 'tx')
+ call assert_match(expected, @:)
+ let &cpo = _cpo
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_cmdmods.vim b/src/testdir/test_cmdmods.vim
index 323a78e..66ff6a1 100644
--- a/src/testdir/test_cmdmods.vim
+++ b/src/testdir/test_cmdmods.vim
@@ -8,10 +8,10 @@ def Test_cmdmods_array()
# :hide is both a command and a modifier
cmds->extend(['hide'])
- # Get the entries of cmdmods[] in ex_docmd.c
+ # Get the entries of cmdmod_info_tab[] in ex_docmd.c
edit ../ex_docmd.c
- var top = search('^} cmdmods[') + 1
- var bot = search('^};') - 1
+ var top = search('^static cmdmod_info_T cmdmod_info_tab[') + 1
+ var bot = search('^};.*\/\/ cmdmod_info_tab') - 1
lines = getline(top, bot)
var mods = lines->map((_, v) => substitute(v, '.*"\(\k*\)".*', '\1', ''))
diff --git a/src/testdir/test_codestyle.vim b/src/testdir/test_codestyle.vim
index 359410d..a455264 100644
--- a/src/testdir/test_codestyle.vim
+++ b/src/testdir/test_codestyle.vim
@@ -7,13 +7,17 @@ def s:ReportError(fname: string, lnum: number, msg: string)
enddef
def s:PerformCheck(fname: string, pattern: string, msg: string, skip: string)
+ var prev_lnum = 1
var lnum = 1
while (lnum > 0)
cursor(lnum, 1)
lnum = search(pattern, 'W', 0, 0, skip)
- ReportError(fname, lnum, msg)
+ if (prev_lnum == lnum)
+ break
+ endif
+ prev_lnum = lnum
if (lnum > 0)
- lnum += 1
+ ReportError(fname, lnum, msg)
endif
endwhile
enddef
diff --git a/src/testdir/test_compiler.vim b/src/testdir/test_compiler.vim
index 4b710df..b7315e1 100644
--- a/src/testdir/test_compiler.vim
+++ b/src/testdir/test_compiler.vim
@@ -71,10 +71,10 @@ func Test_compiler_completion()
call assert_match('^"compiler ' .. clist .. '$', @:)
call feedkeys(":compiler p\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('"compiler pbx perl\( p[a-z]\+\)\+ pylint pyunit', @:)
+ call assert_match('"compiler pandoc pbx perl\( p[a-z_]\+\)\+ pylint pyunit', @:)
call feedkeys(":compiler! p\<C-A>\<C-B>\"\<CR>", 'tx')
- call assert_match('"compiler! pbx perl\( p[a-z]\+\)\+ pylint pyunit', @:)
+ call assert_match('"compiler! pandoc pbx perl\( p[a-z_]\+\)\+ pylint pyunit', @:)
endfunc
func Test_compiler_error()
diff --git a/src/testdir/test_conceal.vim b/src/testdir/test_conceal.vim
index 355817d..2ce7384 100644
--- a/src/testdir/test_conceal.vim
+++ b/src/testdir/test_conceal.vim
@@ -199,6 +199,7 @@ endfunc
" Same as Test_conceal_wrapped_cursorline_wincolor(), but with 'rightleft'.
func Test_conceal_wrapped_cursorline_wincolor_rightleft()
+ CheckFeature rightleft
CheckScreendump
let code =<< trim [CODE]
diff --git a/src/testdir/test_diffmode.vim b/src/testdir/test_diffmode.vim
index 7602bd3..098d5d0 100644
--- a/src/testdir/test_diffmode.vim
+++ b/src/testdir/test_diffmode.vim
@@ -1647,36 +1647,39 @@ endfunc
func Test_diff_scroll_many_filler()
20new
vnew
- call setline(1, ['^^^', '^^^', '$$$', '$$$'])
+ call setline(1, range(1, 40))
diffthis
setlocal scrolloff=0
wincmd p
- call setline(1, ['^^^', '^^^'] + repeat(['###'], 41) + ['$$$', '$$$'])
+ call setline(1, range(1, 20)->reverse() + ['###']->repeat(41) + range(21, 40)->reverse())
diffthis
setlocal scrolloff=0
wincmd p
redraw
" Note: need a redraw after each scroll, otherwise the test always passes.
- normal! G
- redraw
- call assert_equal(3, winsaveview().topline)
- call assert_equal(18, winsaveview().topfill)
- exe "normal! \<C-B>"
- redraw
- call assert_equal(3, winsaveview().topline)
- call assert_equal(19, winsaveview().topfill)
- exe "normal! \<C-B>"
- redraw
- call assert_equal(2, winsaveview().topline)
- call assert_equal(0, winsaveview().topfill)
- exe "normal! \<C-B>"
- redraw
- call assert_equal(1, winsaveview().topline)
- call assert_equal(0, winsaveview().topfill)
+ for _ in range(2)
+ normal! G
+ redraw
+ call assert_equal(40, winsaveview().topline)
+ call assert_equal(19, winsaveview().topfill)
+ exe "normal! \<C-B>"
+ redraw
+ call assert_equal(22, winsaveview().topline)
+ call assert_equal(0, winsaveview().topfill)
+ exe "normal! \<C-B>"
+ redraw
+ call assert_equal(4, winsaveview().topline)
+ call assert_equal(0, winsaveview().topfill)
+ exe "normal! \<C-B>"
+ redraw
+ call assert_equal(1, winsaveview().topline)
+ call assert_equal(0, winsaveview().topfill)
+ set smoothscroll
+ endfor
- bwipe!
- bwipe!
+ set smoothscroll&
+ %bwipe!
endfunc
" This was trying to update diffs for a buffer being closed
@@ -2020,4 +2023,23 @@ func Test_diff_toggle_wrap_skipcol_leftcol()
bwipe!
endfunc
+" Ctrl-D reveals filler lines below the last line in the buffer.
+func Test_diff_eob_halfpage()
+ new
+ call setline(1, ['']->repeat(10) + ['a'])
+ diffthis
+ new
+ call setline(1, ['']->repeat(3) + ['a', 'b'])
+ diffthis
+ resize 5
+ wincmd j
+ resize 5
+ norm G
+ call assert_equal(7, line('w0'))
+ exe "norm! \<C-D>"
+ call assert_equal(8, line('w0'))
+
+ %bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_digraph.vim b/src/testdir/test_digraph.vim
index 4aed403..3312faf 100644
--- a/src/testdir/test_digraph.vim
+++ b/src/testdir/test_digraph.vim
@@ -595,13 +595,13 @@ func Test_digraph_getlist_function()
call digraph_setlist([['aa', 'き'], ['bb', 'く']])
for pair in digraph_getlist(1)
- call assert_equal(digraph_get(pair[0]), pair[1])
+ call assert_equal(pair[1], digraph_get(pair[0]))
endfor
" We don't know how many digraphs are registered before, so check the number
" of digraphs returned.
call assert_equal(digraph_getlist()->len(), digraph_getlist(0)->len())
- call assert_notequal((digraph_getlist()->len()), digraph_getlist(1)->len())
+ call assert_notequal(digraph_getlist()->len(), digraph_getlist(1)->len())
call assert_fails('call digraph_getlist(0z12)', 'E974: Using a Blob as a Number')
endfunc
diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim
index 36e0525..789e44c 100644
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -6,8 +6,6 @@ endif
source check.vim
source screendump.vim
-
-" Needed for testing basic rightleft: Test_edit_rightleft
source view_util.vim
" Needs to come first until the bug in getchar() is
@@ -1302,9 +1300,9 @@ func Test_edit_PAGEUP_PAGEDOWN()
call feedkeys("A\<PageUp>\<esc>", 'tnix')
call assert_equal([0, 13, 1, 0], getpos('.'))
call feedkeys("A\<PageUp>\<esc>", 'tnix')
- call assert_equal([0, 5, 1, 0], getpos('.'))
+ call assert_equal([0, 10, 1, 0], getpos('.'))
call feedkeys("A\<PageUp>\<esc>", 'tnix')
- call assert_equal([0, 5, 11, 0], getpos('.'))
+ call assert_equal([0, 10, 11, 0], getpos('.'))
" <S-Up> is the same as <PageUp>
" <S-Down> is the same as <PageDown>
call cursor(1, 1)
@@ -1325,9 +1323,9 @@ func Test_edit_PAGEUP_PAGEDOWN()
call feedkeys("A\<S-Up>\<esc>", 'tnix')
call assert_equal([0, 13, 1, 0], getpos('.'))
call feedkeys("A\<S-Up>\<esc>", 'tnix')
- call assert_equal([0, 5, 1, 0], getpos('.'))
+ call assert_equal([0, 10, 1, 0], getpos('.'))
call feedkeys("A\<S-Up>\<esc>", 'tnix')
- call assert_equal([0, 5, 11, 0], getpos('.'))
+ call assert_equal([0, 10, 11, 0], getpos('.'))
set nostartofline
call cursor(30, 11)
norm! zt
@@ -1338,9 +1336,9 @@ func Test_edit_PAGEUP_PAGEDOWN()
call feedkeys("A\<PageUp>\<esc>", 'tnix')
call assert_equal([0, 13, 11, 0], getpos('.'))
call feedkeys("A\<PageUp>\<esc>", 'tnix')
- call assert_equal([0, 5, 11, 0], getpos('.'))
+ call assert_equal([0, 10, 11, 0], getpos('.'))
call feedkeys("A\<PageUp>\<esc>", 'tnix')
- call assert_equal([0, 5, 11, 0], getpos('.'))
+ call assert_equal([0, 10, 11, 0], getpos('.'))
call cursor(1, 1)
call feedkeys("A\<PageDown>\<esc>", 'tnix')
call assert_equal([0, 9, 11, 0], getpos('.'))
@@ -1363,9 +1361,9 @@ func Test_edit_PAGEUP_PAGEDOWN()
call feedkeys("A\<S-Up>\<esc>", 'tnix')
call assert_equal([0, 13, 11, 0], getpos('.'))
call feedkeys("A\<S-Up>\<esc>", 'tnix')
- call assert_equal([0, 5, 11, 0], getpos('.'))
+ call assert_equal([0, 10, 11, 0], getpos('.'))
call feedkeys("A\<S-Up>\<esc>", 'tnix')
- call assert_equal([0, 5, 11, 0], getpos('.'))
+ call assert_equal([0, 10, 11, 0], getpos('.'))
call cursor(1, 1)
call feedkeys("A\<S-Down>\<esc>", 'tnix')
call assert_equal([0, 9, 11, 0], getpos('.'))
@@ -1964,8 +1962,8 @@ func Test_edit_ctrl_r_failed()
let buf = RunVimInTerminal('', #{rows: 6, cols: 60})
- " trying to insert a dictionary produces an error
- call term_sendkeys(buf, "i\<C-R>={}\<CR>")
+ " trying to insert a blob produces an error
+ call term_sendkeys(buf, "i\<C-R>=0z\<CR>")
" ending Insert mode should put the cursor back on the ':'
call term_sendkeys(buf, ":\<Esc>")
@@ -2046,7 +2044,10 @@ func Test_edit_revins()
call setline(1, 'one two three')
exe "normal! wi\nfour"
call assert_equal(['one two three', 'ruof'], getline(1, '$'))
- set revins&
+ set backspace=indent,eol,start
+ exe "normal! ggA\<BS>:"
+ call assert_equal(['one two three:ruof'], getline(1, '$'))
+ set revins& backspace&
bw!
endfunc
@@ -2158,4 +2159,133 @@ func Test_edit_Ctrl_RSB()
bwipe!
endfunc
+func s:check_backspace(expected)
+ let g:actual = []
+ inoremap <buffer> <F2> <Cmd>let g:actual += [getline('.')]<CR>
+ set backspace=indent,eol,start
+
+ exe "normal i" .. repeat("\<BS>\<F2>", len(a:expected))
+ call assert_equal(a:expected, g:actual)
+
+ set backspace&
+ iunmap <buffer> <F2>
+ unlet g:actual
+endfunc
+
+" Test that backspace works with 'smarttab' and mixed Tabs and spaces.
+func Test_edit_backspace_smarttab_mixed()
+ set smarttab
+ call NewWindow(1, 30)
+ setlocal tabstop=4 shiftwidth=4
+
+ call setline(1, "\t \t \t a")
+ normal! $
+ call s:check_backspace([
+ \ "\t \t \ta",
+ \ "\t \t a",
+ \ "\t \t a",
+ \ "\t \ta",
+ \ "\t a",
+ \ "\ta",
+ \ "a",
+ \ ])
+
+ call CloseWindow()
+ set smarttab&
+endfunc
+
+" Test that backspace works with 'smarttab' and 'varsofttabstop'.
+func Test_edit_backspace_smarttab_varsofttabstop()
+ CheckFeature vartabs
+
+ set smarttab
+ call NewWindow(1, 30)
+ setlocal tabstop=8 varsofttabstop=6,2,5,3
+
+ call setline(1, "a\t \t a")
+ normal! $
+ call s:check_backspace([
+ \ "a\t \ta",
+ \ "a\t a",
+ \ "a\ta",
+ \ "a a",
+ \ "aa",
+ \ "a",
+ \ ])
+
+ call CloseWindow()
+ set smarttab&
+endfunc
+
+" Test that backspace works with 'smarttab' when a Tab is shown as "^I".
+func Test_edit_backspace_smarttab_list()
+ set smarttab
+ call NewWindow(1, 30)
+ setlocal tabstop=4 shiftwidth=4 list listchars=
+
+ call setline(1, "\t \t \t a")
+ normal! $
+ call s:check_backspace([
+ \ "\t \t a",
+ \ "\t \t a",
+ \ "\t \ta",
+ \ "\t a",
+ \ "a",
+ \ ])
+
+ call CloseWindow()
+ set smarttab&
+endfunc
+
+" Test that backspace works with 'smarttab' and 'breakindent'.
+func Test_edit_backspace_smarttab_breakindent()
+ CheckFeature linebreak
+
+ set smarttab
+ call NewWindow(3, 17)
+ setlocal tabstop=4 shiftwidth=4 breakindent breakindentopt=min:5
+
+ call setline(1, "\t \t \t a")
+ normal! $
+ call s:check_backspace([
+ \ "\t \t \ta",
+ \ "\t \t a",
+ \ "\t \t a",
+ \ "\t \ta",
+ \ "\t a",
+ \ "\ta",
+ \ "a",
+ \ ])
+
+ call CloseWindow()
+ set smarttab&
+endfunc
+
+" Test that backspace works with 'smarttab' and virtual text.
+func Test_edit_backspace_smarttab_virtual_text()
+ CheckFeature textprop
+
+ set smarttab
+ call NewWindow(1, 50)
+ setlocal tabstop=4 shiftwidth=4
+
+ call setline(1, "\t \t \t a")
+ call prop_type_add('theprop', {})
+ call prop_add(1, 3, {'type': 'theprop', 'text': 'text'})
+ normal! $
+ call s:check_backspace([
+ \ "\t \t \ta",
+ \ "\t \t a",
+ \ "\t \t a",
+ \ "\t \ta",
+ \ "\t a",
+ \ "\ta",
+ \ "a",
+ \ ])
+
+ call CloseWindow()
+ call prop_type_delete('theprop')
+ set smarttab&
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim
index c1869c1..6acfe00 100644
--- a/src/testdir/test_expr.vim
+++ b/src/testdir/test_expr.vim
@@ -950,6 +950,22 @@ func Test_string_interp()
endif
call assert_equal(0, tmp)
+ #" Dict interpolation
+ VAR d = {'a': 10, 'b': [1, 2]}
+ call assert_equal("{'a': 10, 'b': [1, 2]}", $'{d}')
+ VAR emptydict = {}
+ call assert_equal("a{}b", $'a{emptydict}b')
+ VAR nulldict = test_null_dict()
+ call assert_equal("a{}b", $'a{nulldict}b')
+
+ #" List interpolation
+ VAR l = ['a', 'b', 'c']
+ call assert_equal("['a', 'b', 'c']", $'{l}')
+ VAR emptylist = []
+ call assert_equal("a[]b", $'a{emptylist}b')
+ VAR nulllist = test_null_list()
+ call assert_equal("a[]b", $'a{nulllist}b')
+
#" Stray closing brace.
call assert_fails('echo $"moo}"', 'E1278:')
#" Undefined variable in expansion.
diff --git a/src/testdir/test_filechanged.vim b/src/testdir/test_filechanged.vim
index c3a5664..12ac4cc 100644
--- a/src/testdir/test_filechanged.vim
+++ b/src/testdir/test_filechanged.vim
@@ -11,8 +11,12 @@ func Test_FileChangedShell_reload()
new Xchanged_r
call setline(1, 'reload this')
write
- " Need to wait until the timestamp would change by at least a second.
- sleep 2
+ " Need to wait until the timestamp would change.
+ if has('nanotime')
+ sleep 10m
+ else
+ sleep 2
+ endif
silent !echo 'extra line' >>Xchanged_r
checktime
call assert_equal('changed', g:reason)
@@ -50,7 +54,11 @@ func Test_FileChangedShell_reload()
call assert_equal('new line', getline(1))
" Only time changed
- sleep 2
+ if has('nanotime')
+ sleep 10m
+ else
+ sleep 2
+ endif
silent !touch Xchanged_r
let g:reason = ''
checktime
@@ -65,7 +73,11 @@ func Test_FileChangedShell_reload()
call setline(2, 'before write')
write
call setline(2, 'after write')
- sleep 2
+ if has('nanotime')
+ sleep 10m
+ else
+ sleep 2
+ endif
silent !echo 'different line' >>Xchanged_r
let g:reason = ''
checktime
@@ -192,8 +204,12 @@ func Test_file_changed_dialog()
new Xchanged_d
call setline(1, 'reload this')
write
- " Need to wait until the timestamp would change by at least a second.
- sleep 2
+ " Need to wait until the timestamp would change.
+ if has('nanotime')
+ sleep 10m
+ else
+ sleep 2
+ endif
silent !echo 'extra line' >>Xchanged_d
call feedkeys('L', 'L')
checktime
@@ -228,7 +244,11 @@ func Test_file_changed_dialog()
call assert_equal('new line', getline(1))
" Only time changed, no prompt
- sleep 2
+ if has('nanotime')
+ sleep 10m
+ else
+ sleep 2
+ endif
silent !touch Xchanged_d
let v:warningmsg = ''
checktime Xchanged_d
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index d77e5e0..f8fe9ec 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -126,6 +126,7 @@ def s:GetFilenameChecks(): dict<list<string>>
blade: ['file.blade.php'],
blank: ['file.bl'],
blueprint: ['file.blp'],
+ bp: ['Android.bp'],
bsdl: ['file.bsd', 'file.bsdl'],
bst: ['file.bst'],
bzl: ['file.bazel', 'file.bzl', 'WORKSPACE', 'WORKSPACE.bzlmod'],
@@ -144,6 +145,7 @@ def s:GetFilenameChecks(): dict<list<string>>
cf: ['file.cfm', 'file.cfi', 'file.cfc'],
cfengine: ['cfengine.conf'],
cfg: ['file.hgrc', 'filehgrc', 'hgrc', 'some-hgrc'],
+ cgdbrc: ['cgdbrc'],
ch: ['file.chf'],
chaiscript: ['file.chai'],
chaskell: ['file.chs'],
@@ -153,16 +155,17 @@ def s:GetFilenameChecks(): dict<list<string>>
chuck: ['file.ck'],
cl: ['file.eni'],
clean: ['file.dcl', 'file.icl'],
- clojure: ['file.clj', 'file.cljs', 'file.cljx', 'file.cljc'],
+ clojure: ['file.clj', 'file.cljs', 'file.cljx', 'file.cljc', 'init.trans', 'any/etc/translate-shell', '.trans'],
cmake: ['CMakeLists.txt', 'file.cmake', 'file.cmake.in'],
+ cmakecache: ['CMakeCache.txt'],
cmod: ['file.cmod'],
cmusrc: ['any/.cmus/autosave', 'any/.cmus/rc', 'any/.cmus/command-history', 'any/.cmus/file.theme', 'any/cmus/rc', 'any/cmus/file.theme', '/.cmus/autosave', '/.cmus/command-history', '/.cmus/file.theme', '/.cmus/rc', '/cmus/file.theme', '/cmus/rc'],
cobol: ['file.cbl', 'file.cob', 'file.lib'],
coco: ['file.atg'],
conaryrecipe: ['file.recipe'],
- conf: ['auto.master', 'file.conf'],
+ conf: ['auto.master', 'file.conf', 'texdoc.cnf', '.x11vncrc', '.chktexrc', '.ripgreprc', 'ripgreprc', 'file.ctags', '.mbsyncrc'],
config: ['configure.in', 'configure.ac', '/etc/hostname.file', 'any/etc/hostname.file'],
- confini: ['/etc/pacman.conf', 'any/etc/pacman.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'],
+ confini: ['pacman.conf', 'paru.conf', 'mpv.conf', 'any/.aws/config', 'any/.aws/credentials', 'file.nmconnection'],
context: ['tex/context/any/file.tex', 'file.mkii', 'file.mkiv', 'file.mkvi', 'file.mkxl', 'file.mklx'],
cook: ['file.cook'],
corn: ['file.corn'],
@@ -210,16 +213,24 @@ def s:GetFilenameChecks(): dict<list<string>>
dnsmasq: ['/etc/dnsmasq.conf', '/etc/dnsmasq.d/file', 'any/etc/dnsmasq.conf', 'any/etc/dnsmasq.d/file'],
dockerfile: ['Containerfile', 'Dockerfile', 'dockerfile', 'file.Dockerfile', 'file.dockerfile', 'Dockerfile.debian', 'Containerfile.something'],
dosbatch: ['file.bat'],
- dosini: ['/etc/yum.conf', 'file.ini', 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file', '/etc/yum.repos.d/file', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap', 'file.vbp', 'ja2.ini', 'JA2.INI'],
+ dosini: ['/etc/yum.conf', '/etc/nfs.conf', '/etc/nfsmount.conf', 'file.ini',
+ 'npmrc', '.npmrc', 'php.ini', 'php.ini-5', 'php.ini-file',
+ '/etc/yum.repos.d/file', 'any/etc/yum.conf', 'any/etc/yum.repos.d/file', 'file.wrap',
+ 'file.vbp', 'ja2.ini', 'JA2.INI', 'mimeapps.list', 'pip.conf', 'setup.cfg', 'pudb.cfg',
+ '.coveragerc', '.pypirc', '.gitlint', '.oelint.cfg', 'pylintrc', '.pylintrc',
+ '/home/user/.config/bpython/config', '/home/user/.config/mypy/config', '.wakatime.cfg', '.replyrc',
+ 'psprint.conf', 'sofficerc', 'any/.config/lxqt/globalkeyshortcuts.conf', 'any/.config/screengrab/screengrab.conf',
+ 'any/.local/share/flatpak/repo/config', '.notmuch-config'],
dot: ['file.dot', 'file.gv'],
dracula: ['file.drac', 'file.drc', 'filelvs', 'filelpe', 'drac.file', 'lpe', 'lvs', 'some-lpe', 'some-lvs'],
dtd: ['file.dtd'],
dtrace: ['/usr/lib/dtrace/io.d'],
- dts: ['file.dts', 'file.dtsi', 'file.dtso', 'file.its'],
+ dts: ['file.dts', 'file.dtsi', 'file.dtso', 'file.its', 'file.keymap'],
dune: ['jbuild', 'dune', 'dune-project', 'dune-workspace'],
dylan: ['file.dylan'],
dylanintr: ['file.intr'],
dylanlid: ['file.lid'],
+ earthfile: ['Earthfile'],
ecd: ['file.ecd'],
edif: ['file.edf', 'file.edif', 'file.edo'],
editorconfig: ['.editorconfig'],
@@ -283,7 +294,7 @@ def s:GetFilenameChecks(): dict<list<string>>
glsl: ['file.glsl'],
gn: ['file.gn', 'file.gni'],
gnash: ['gnashrc', '.gnashrc', 'gnashpluginrc', '.gnashpluginrc'],
- gnuplot: ['file.gpi', '.gnuplot', 'file.gnuplot'],
+ gnuplot: ['file.gpi', '.gnuplot', 'file.gnuplot', '.gnuplot_history'],
go: ['file.go'],
gomod: ['go.mod'],
gosum: ['go.sum', 'go.work.sum'],
@@ -312,7 +323,7 @@ def s:GetFilenameChecks(): dict<list<string>>
hcl: ['file.hcl'],
heex: ['file.heex'],
hercules: ['file.vc', 'file.ev', 'file.sum', 'file.errsum'],
- hex: ['file.hex', 'file.h32'],
+ hex: ['file.hex', 'file.ihex', 'file.ihe', 'file.ihx', 'file.int', 'file.mcs', 'file.h32', 'file.h80', 'file.h86', 'file.a43', 'file.a90'],
hgcommit: ['hg-editor-file.txt'],
hjson: ['file.hjson'],
hlsplaylist: ['file.m3u', 'file.m3u8'],
@@ -342,7 +353,7 @@ def s:GetFilenameChecks(): dict<list<string>>
janet: ['file.janet'],
java: ['file.java', 'file.jav'],
javacc: ['file.jj', 'file.jjt'],
- javascript: ['file.js', 'file.jsm', 'file.javascript', 'file.es', 'file.mjs', 'file.cjs'],
+ javascript: ['file.js', 'file.jsm', 'file.javascript', 'file.es', 'file.mjs', 'file.cjs', '.node_repl_history'],
'javascript.glimmer': ['file.gjs'],
javascriptreact: ['file.jsx'],
jess: ['file.clp'],
@@ -350,9 +361,9 @@ def s:GetFilenameChecks(): dict<list<string>>
jq: ['file.jq'],
jovial: ['file.jov', 'file.j73', 'file.jovial'],
jproperties: ['file.properties', 'file.properties_xx', 'file.properties_xx_xx', 'some.properties_xx_xx_file', 'org.eclipse.xyz.prefs'],
- json: ['file.json', 'file.jsonp', 'file.json-patch', 'file.geojson', 'file.webmanifest', 'Pipfile.lock', 'file.ipynb', '.prettierrc', '.firebaserc', '.stylelintrc', 'file.slnf'],
+ json: ['file.json', 'file.jsonp', 'file.json-patch', 'file.geojson', 'file.webmanifest', 'Pipfile.lock', 'file.ipynb', 'file.jupyterlab-settings', '.prettierrc', '.firebaserc', '.stylelintrc', 'file.slnf', 'file.sublime-project', 'file.sublime-settings', 'file.sublime-workspace', 'file.bd', 'file.bda', 'file.xci', 'flake.lock'],
json5: ['file.json5'],
- jsonc: ['file.jsonc', '.babelrc', '.eslintrc', '.jsfmtrc', '.jshintrc', '.hintrc', '.swrc', 'jsconfig.json', 'tsconfig.json', 'tsconfig.test.json', 'tsconfig-test.json', '.luaurc'],
+ jsonc: ['file.jsonc', '.babelrc', '.eslintrc', '.jsfmtrc', '.jshintrc', '.jscsrc', '.vsconfig', '.hintrc', '.swrc', 'jsconfig.json', 'tsconfig.json', 'tsconfig.test.json', 'tsconfig-test.json', '.luaurc'],
jsonl: ['file.jsonl'],
jsonnet: ['file.jsonnet', 'file.libsonnet'],
jsp: ['file.jsp'],
@@ -368,7 +379,7 @@ def s:GetFilenameChecks(): dict<list<string>>
kwt: ['file.k'],
lace: ['file.ace', 'file.ACE'],
latte: ['file.latte', 'file.lte'],
- ld: ['file.ld'],
+ ld: ['file.ld', 'any/usr/lib/aarch64-xilinx-linux/ldscripts/aarch64elf32b.x'],
ldif: ['file.ldif'],
lean: ['file.lean'],
ledger: ['file.ldg', 'file.ledger', 'file.journal'],
@@ -383,7 +394,7 @@ def s:GetFilenameChecks(): dict<list<string>>
limits: ['/etc/limits', '/etc/anylimits.conf', '/etc/anylimits.d/file.conf', '/etc/limits.conf', '/etc/limits.d/file.conf', '/etc/some-limits.conf', '/etc/some-limits.d/file.conf', 'any/etc/limits', 'any/etc/limits.conf', 'any/etc/limits.d/file.conf', 'any/etc/some-limits.conf', 'any/etc/some-limits.d/file.conf'],
liquidsoap: ['file.liq'],
liquid: ['file.liquid'],
- lisp: ['file.lsp', 'file.lisp', 'file.asd', 'file.el', 'file.cl', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc'],
+ lisp: ['file.lsp', 'file.lisp', 'file.asd', 'file.el', 'file.cl', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc', 'file.stsg', 'any/local/share/supertux2/config'],
lite: ['file.lite', 'file.lt'],
litestep: ['/LiteStep/any/file.rc', 'any/LiteStep/any/file.rc'],
logcheck: ['/etc/logcheck/file.d-some/file', '/etc/logcheck/file.d/file', 'any/etc/logcheck/file.d-some/file', 'any/etc/logcheck/file.d/file'],
@@ -396,13 +407,13 @@ def s:GetFilenameChecks(): dict<list<string>>
lpc: ['file.lpc', 'file.ulpc'],
lsl: ['file.lsl'],
lss: ['file.lss'],
- lua: ['file.lua', 'file.rockspec', 'file.nse', '.luacheckrc', '.busted'],
+ lua: ['file.lua', 'file.tlu', 'file.rockspec', 'file.nse', '.lua_history', '.luacheckrc', '.busted', 'rock_manifest', 'config.ld'],
luau: ['file.luau'],
lynx: ['lynx.cfg'],
lyrics: ['file.lrc'],
m3build: ['m3makefile', 'm3overrides'],
m3quake: ['file.quake', 'cm3.cfg'],
- m4: ['file.at'],
+ m4: ['file.at', '.m4_history'],
mail: ['snd.123', '.letter', '.letter.123', '.followup', '.article', '.article.123', 'pico.123', 'mutt-xx-xxx', 'muttng-xx-xxx', 'ae123.txt', 'file.eml', 'reportbug-file'],
mailaliases: ['/etc/mail/aliases', '/etc/aliases', 'any/etc/aliases', 'any/etc/mail/aliases'],
mailcap: ['.mailcap', 'mailcap'],
@@ -466,6 +477,7 @@ def s:GetFilenameChecks(): dict<list<string>>
msidl: ['file.odl', 'file.mof'],
msql: ['file.msql'],
mojo: ['file.mojo', 'file.🔥'],
+ msmtp: ['.msmtprc'],
mupad: ['file.mu'],
mush: ['file.mush'],
mustache: ['file.mustache'],
@@ -481,7 +493,7 @@ def s:GetFilenameChecks(): dict<list<string>>
'any/.muttng/muttrc', 'any/.muttng/muttrc-file',
'any/etc/Muttrc.d/file', 'muttngrc', 'muttngrc-file', 'muttrc',
'muttrc-file'],
- mysql: ['file.mysql'],
+ mysql: ['file.mysql', '.mysql_history'],
n1ql: ['file.n1ql', 'file.nql'],
named: ['namedfile.conf', 'rndcfile.conf', 'named-file.conf', 'named.conf', 'rndc-file.conf', 'rndc-file.key', 'rndc.conf', 'rndc.key'],
nanorc: ['/etc/nanorc', 'file.nanorc', 'any/etc/nanorc'],
@@ -503,9 +515,10 @@ def s:GetFilenameChecks(): dict<list<string>>
obse: ['file.obl', 'file.obse', 'file.oblivion', 'file.obscript'],
ocaml: ['file.ml', 'file.mli', 'file.mll', 'file.mly', '.ocamlinit', 'file.mlt', 'file.mlp', 'file.mlip', 'file.mli.cppo', 'file.ml.cppo'],
occam: ['file.occ'],
- octave: ['octaverc', '.octaverc', 'octave.conf'],
+ octave: ['octaverc', '.octaverc', 'octave.conf', 'any/.local/share/octave/history'],
odin: ['file.odin'],
omnimark: ['file.xom', 'file.xin'],
+ ondir: ['.ondirrc'],
opam: ['opam', 'file.opam', 'file.opam.template'],
openroad: ['file.or'],
openscad: ['file.scad'],
@@ -516,10 +529,11 @@ def s:GetFilenameChecks(): dict<list<string>>
pacmanlog: ['pacman.log'],
pamconf: ['/etc/pam.conf', '/etc/pam.d/file', 'any/etc/pam.conf', 'any/etc/pam.d/file'],
pamenv: ['/etc/security/pam_env.conf', '/home/user/.pam_environment', '.pam_environment', 'pam_env.conf'],
+ pandoc: ['file.pandoc', 'file.pdk', 'file.pd', 'file.pdc'],
papp: ['file.papp', 'file.pxml', 'file.pxsl'],
pascal: ['file.pas', 'file.dpr', 'file.lpr'],
passwd: ['any/etc/passwd', 'any/etc/passwd-', 'any/etc/passwd.edit', 'any/etc/shadow', 'any/etc/shadow-', 'any/etc/shadow.edit', 'any/var/backups/passwd.bak', 'any/var/backups/shadow.bak', '/etc/passwd', '/etc/passwd-', '/etc/passwd.edit', '/etc/shadow', '/etc/shadow-', '/etc/shadow.edit', '/var/backups/passwd.bak', '/var/backups/shadow.bak'],
- pbtxt: ['file.pbtxt'],
+ pbtxt: ['file.txtpb', 'file.textproto', 'file.textpb', 'file.pbtxt'],
pccts: ['file.g'],
pcmk: ['file.pcmk'],
pdf: ['file.pdf'],
@@ -563,13 +577,13 @@ def s:GetFilenameChecks(): dict<list<string>>
pymanifest: ['MANIFEST.in'],
pyret: ['file.arr'],
pyrex: ['file.pyx', 'file.pxd'],
- python: ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', 'file.ptl', 'file.pyi', 'SConstruct'],
+ python: ['file.py', 'file.pyw', '.pythonstartup', '.pythonrc', '.python_history', '.jline-jython.history', 'file.ptl', 'file.pyi', 'SConstruct'],
ql: ['file.ql', 'file.qll'],
qml: ['file.qml', 'file.qbs'],
qmldir: ['qmldir'],
quake: ['anybaseq2/file.cfg', 'anyid1/file.cfg', 'quake3/file.cfg', 'baseq2/file.cfg', 'id1/file.cfg', 'quake1/file.cfg', 'some-baseq2/file.cfg', 'some-id1/file.cfg', 'some-quake1/file.cfg'],
quarto: ['file.qmd'],
- r: ['file.r', '.Rprofile', 'Rprofile', 'Rprofile.site'],
+ r: ['file.r', '.Rhistory', '.Rprofile', 'Rprofile', 'Rprofile.site'],
racket: ['file.rkt', 'file.rktd', 'file.rktl'],
radiance: ['file.rad', 'file.mat'],
raku: ['file.pm6', 'file.p6', 'file.t6', 'file.pod6', 'file.raku', 'file.rakumod', 'file.rakudoc', 'file.rakutest'],
@@ -581,7 +595,7 @@ def s:GetFilenameChecks(): dict<list<string>>
readline: ['.inputrc', 'inputrc'],
rego: ['file.rego'],
remind: ['.reminders', 'file.remind', 'file.rem', '.reminders-file'],
- requirements: ['file.pip', 'requirements.txt'],
+ requirements: ['file.pip', 'requirements.txt', 'dev-requirements.txt', 'constraints.txt', 'requirements.in', 'requirements/dev.txt', 'requires/dev.txt'],
rescript: ['file.res', 'file.resi'],
resolv: ['resolv.conf'],
reva: ['file.frt'],
@@ -595,6 +609,7 @@ def s:GetFilenameChecks(): dict<list<string>>
rpgle: ['file.rpgle', 'file.rpgleinc'],
robot: ['file.robot', 'file.resource'],
robots: ['robots.txt'],
+ roc: ['file.roc'],
ron: ['file.ron'],
routeros: ['file.rsc'],
rpcgen: ['file.x'],
@@ -602,7 +617,7 @@ def s:GetFilenameChecks(): dict<list<string>>
rrst: ['file.rrst', 'file.srst'],
rst: ['file.rst'],
rtf: ['file.rtf'],
- ruby: ['.irbrc', 'irbrc', 'file.rb', 'file.rbw', 'file.gemspec', 'file.ru', 'Gemfile', 'file.builder', 'file.rxml', 'file.rjs', 'file.rant', 'file.rake', 'rakefile', 'Rakefile', 'rantfile', 'Rantfile', 'rakefile-file', 'Rakefile-file', 'Puppetfile', 'Vagrantfile'],
+ ruby: ['.irbrc', 'irbrc', '.irb_history', 'irb_history', 'file.rb', 'file.rbw', 'file.gemspec', 'file.ru', 'Gemfile', 'file.builder', 'file.rxml', 'file.rjs', 'file.rant', 'file.rake', 'rakefile', 'Rakefile', 'rantfile', 'Rantfile', 'rakefile-file', 'Rakefile-file', 'Puppetfile', 'Vagrantfile'],
rust: ['file.rs'],
samba: ['smb.conf'],
sas: ['file.sas'],
@@ -622,7 +637,10 @@ def s:GetFilenameChecks(): dict<list<string>>
services: ['/etc/services', 'any/etc/services'],
setserial: ['/etc/serial.conf', 'any/etc/serial.conf'],
sexplib: ['file.sexp'],
- sh: ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh', '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats'],
+ sh: ['.bashrc', '.bash_profile', '.bash-profile', '.bash_logout', '.bash-logout', '.bash_aliases', '.bash-aliases', '.bash_history', '.bash-history',
+ '/tmp/bash-fc-3Ozjlw', '/tmp/bash-fc.3Ozjlw', 'PKGBUILD', 'APKBUILD', 'file.bash', '/usr/share/doc/bash-completion/filter.sh',
+ '/etc/udev/cdsymlinks.conf', 'any/etc/udev/cdsymlinks.conf', 'file.bats', '.ash_history', 'any/etc/neofetch/config.conf', '.xprofile',
+ 'user-dirs.defaults', 'user-dirs.dirs', 'makepkg.conf', '.makepkg.conf'],
sieve: ['file.siv', 'file.sieve'],
sil: ['file.sil'],
simula: ['file.sim'],
@@ -653,7 +671,7 @@ def s:GetFilenameChecks(): dict<list<string>>
spice: ['file.sp', 'file.spice'],
spup: ['file.speedup', 'file.spdata', 'file.spd'],
spyce: ['file.spy', 'file.spi'],
- sql: ['file.tyb', 'file.tyc', 'file.pkb', 'file.pks'],
+ sql: ['file.tyb', 'file.tyc', 'file.pkb', 'file.pks', '.sqlite_history'],
sqlj: ['file.sqlj'],
prql: ['file.prql'],
sqr: ['file.sqr', 'file.sqi'],
@@ -725,14 +743,14 @@ def s:GetFilenameChecks(): dict<list<string>>
tal: ['file.tal'],
taskdata: ['pending.data', 'completed.data', 'undo.data'],
taskedit: ['file.task'],
- tcl: ['file.tcl', 'file.tm', 'file.tk', 'file.itcl', 'file.itk', 'file.jacl', '.tclshrc', 'tclsh.rc', '.wishrc'],
+ tcl: ['file.tcl', 'file.tm', 'file.tk', 'file.itcl', 'file.itk', 'file.jacl', '.tclshrc', 'tclsh.rc', '.wishrc', '.tclsh-history', '.xsctcmdhistory', '.xsdbcmdhistory'],
tablegen: ['file.td'],
teal: ['file.tl'],
template: ['file.tmpl'],
teraterm: ['file.ttl'],
terminfo: ['file.ti'],
'terraform-vars': ['file.tfvars'],
- tex: ['file.latex', 'file.sty', 'file.dtx', 'file.ltx', 'file.bbl'],
+ tex: ['file.latex', 'file.sty', 'file.dtx', 'file.ltx', 'file.bbl', 'any/.texlive/texmf-config/tex/latex/file/file.cfg', 'file.pgf', 'file.nlo', 'file.nls', 'file.out', 'file.thm', 'file.eps_tex', 'file.pygtex', 'file.pygstyle', 'file.clo', 'file.aux', 'file.brf', 'file.ind', 'file.lof', 'file.loe', 'file.nav', 'file.vrb', 'file.ins', 'file.tikz', 'file.bbx', 'file.cbx', 'file.beamer'],
texinfo: ['file.texinfo', 'file.texi', 'file.txi'],
texmf: ['texmf.cnf'],
text: ['file.text', 'file.txt', 'README', 'LICENSE', 'COPYING', 'AUTHORS', '/usr/share/doc/bash-completion/AUTHORS', '/etc/apt/apt.conf.d/README', '/etc/Muttrc.d/README'],
@@ -743,7 +761,7 @@ def s:GetFilenameChecks(): dict<list<string>>
tla: ['file.tla'],
tli: ['file.tli'],
tmux: ['tmuxfile.conf', '.tmuxfile.conf', '.tmux-file.conf', '.tmux.conf', 'tmux-file.conf', 'tmux.conf', 'tmux.conf.local'],
- toml: ['file.toml', 'Gopkg.lock', 'Pipfile', '/home/user/.cargo/config'],
+ toml: ['file.toml', 'Gopkg.lock', 'Pipfile', '/home/user/.cargo/config', '.black'],
tpp: ['file.tpp'],
treetop: ['file.treetop'],
trustees: ['trustees.conf'],
@@ -753,9 +771,10 @@ def s:GetFilenameChecks(): dict<list<string>>
tssop: ['file.tssop'],
tsv: ['file.tsv'],
twig: ['file.twig'],
- typescript: ['file.mts', 'file.cts'],
+ typescript: ['file.mts', 'file.cts', '.ts_node_repl_history'],
'typescript.glimmer': ['file.gts'],
typescriptreact: ['file.tsx'],
+ typespec: ['file.tsp'],
ungrammar: ['file.ungram'],
uc: ['file.uc'],
udevconf: ['/etc/udev/udev.conf', 'any/etc/udev/udev.conf'],
@@ -785,7 +804,7 @@ def s:GetFilenameChecks(): dict<list<string>>
vgrindefs: ['vgrindefs'],
vhdl: ['file.hdl', 'file.vhd', 'file.vhdl', 'file.vbe', 'file.vst', 'file.vhdl_123', 'file.vho', 'some.vhdl_1', 'some.vhdl_1-file'],
vhs: ['file.tape'],
- vim: ['file.vim', '.exrc', '_exrc', 'some-vimrc', 'some-vimrc-file', 'vimrc', 'vimrc-file'],
+ vim: ['file.vim', '.exrc', '_exrc', 'some-vimrc', 'some-vimrc-file', 'vimrc', 'vimrc-file', '.netrwhist'],
viminfo: ['.viminfo', '_viminfo'],
vmasm: ['file.mar'],
voscm: ['file.cm'],
@@ -811,7 +830,7 @@ def s:GetFilenameChecks(): dict<list<string>>
xinetd: ['/etc/xinetd.conf', '/etc/xinetd.d/file', 'any/etc/xinetd.conf', 'any/etc/xinetd.d/file'],
xkb: ['/usr/share/X11/xkb/compat/pc', '/usr/share/X11/xkb/geometry/pc', '/usr/share/X11/xkb/keycodes/evdev', '/usr/share/X11/xkb/symbols/pc', '/usr/share/X11/xkb/types/pc'],
xmath: ['file.msc', 'file.msf'],
- xml: ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.fsproj', 'file.fsproj.user', 'file.vbproj', 'file.vbproj.user', 'file.ui', 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old', 'any/etc/xdg/menus/file.menu', 'file.atom', 'file.rss', 'file.cdxml', 'file.psc1', 'file.mpd'],
+ xml: ['/etc/blkid.tab', '/etc/blkid.tab.old', 'file.xmi', 'file.csproj', 'file.csproj.user', 'file.fsproj', 'file.fsproj.user', 'file.vbproj', 'file.vbproj.user', 'file.ui', 'file.tpm', '/etc/xdg/menus/file.menu', 'fglrxrc', 'file.xlf', 'file.xliff', 'file.xul', 'file.wsdl', 'file.wpl', 'any/etc/blkid.tab', 'any/etc/blkid.tab.old', 'any/etc/xdg/menus/file.menu', 'file.atom', 'file.rss', 'file.cdxml', 'file.psc1', 'file.mpd', 'fonts.conf', 'file.xcu', 'file.xlb', 'file.xlc', 'file.xba', 'file.xpr', 'file.xpfm', 'file.spfm', 'file.bxml'],
xmodmap: ['anyXmodmap', 'Xmodmap', 'some-Xmodmap', 'some-xmodmap', 'some-xmodmap-file', 'xmodmap', 'xmodmap-file'],
xpm: ['file.xpm'],
xpm2: ['file.xpm2'],
@@ -820,16 +839,17 @@ def s:GetFilenameChecks(): dict<list<string>>
xsd: ['file.xsd'],
xslt: ['file.xsl', 'file.xslt'],
yacc: ['file.yy', 'file.yxx', 'file.y++'],
- yaml: ['file.yaml', 'file.yml', 'file.eyaml', '.clangd', '.clang-format', '.clang-tidy'],
+ yaml: ['file.yaml', 'file.yml', 'file.eyaml', 'any/.bundle/config', '.clangd', '.clang-format', '.clang-tidy', 'file.mplstyle', 'matplotlibrc', 'yarn.lock'],
yang: ['file.yang'],
yuck: ['file.yuck'],
z8a: ['file.z8a'],
+ zathurarc: ['zathurarc'],
zig: ['file.zig', 'build.zig.zon'],
zimbu: ['file.zu'],
zimbutempl: ['file.zut'],
zserio: ['file.zs'],
- zsh: ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh',
- '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc',
+ zsh: ['.zprofile', '/etc/zprofile', '.zfbfmarks', 'file.zsh', 'file.zsh-theme', 'file.zunit',
+ '.zcompdump', '.zlogin', '.zlogout', '.zshenv', '.zshrc', '.zsh_history',
'.zcompdump-file', '.zlog', '.zlog-file', '.zsh', '.zsh-file',
'any/etc/zprofile', 'zlog', 'zlog-file', 'zsh', 'zsh-file'],
@@ -2422,4 +2442,26 @@ func Test_def_file()
filetype off
endfunc
+func Test_uci_file()
+ filetype on
+
+ call mkdir('any/etc/config', 'pR')
+ call writefile(['config firewall'], 'any/etc/config/firewall', 'D')
+ split any/etc/config/firewall
+ call assert_equal('uci', &filetype)
+ bwipe!
+
+ call writefile(['# config for nginx here'], 'any/etc/config/firewall', 'D')
+ split any/etc/config/firewall
+ call assert_notequal('uci', &filetype)
+ bwipe!
+
+ call writefile(['# Copyright Cool Cats 1997', 'config firewall'], 'any/etc/config/firewall', 'D')
+ split any/etc/config/firewall
+ call assert_equal('uci', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index fecebc4..f0d7385 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -3794,6 +3794,43 @@ func Test_funcref_to_string()
call assert_equal("function('g:Test_funcref_to_string')", string(Fn))
endfunc
+" A funcref cannot start with an underscore (except when used as a protected
+" class or object variable)
+func Test_funcref_with_underscore()
+ " at script level
+ let lines =<< trim END
+ vim9script
+ var _Fn = () => 10
+ END
+ call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Fn')
+
+ " inside a function
+ let lines =<< trim END
+ vim9script
+ def Func()
+ var _Fn = () => 10
+ enddef
+ defcompile
+ END
+ call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Fn', 1)
+
+ " as a function argument
+ let lines =<< trim END
+ vim9script
+ def Func(_Fn: func)
+ enddef
+ defcompile
+ END
+ call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Fn', 2)
+
+ " as a lambda argument
+ let lines =<< trim END
+ vim9script
+ var Fn = (_Farg: func) => 10
+ END
+ call v9.CheckSourceFailure(lines, 'E704: Funcref variable name must start with a capital: _Farg', 2)
+endfunc
+
" Test for isabsolutepath()
func Test_isabsolutepath()
call assert_false(isabsolutepath(''))
diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim
index d6c9f50..9bc5f12 100644
--- a/src/testdir/test_highlight.vim
+++ b/src/testdir/test_highlight.vim
@@ -856,6 +856,15 @@ func Test_highlight_User()
hi clear
endfunc
+" Test for MsgArea highlighting
+func Test_highlight_MsgArea()
+ CheckNotGui
+ hi MsgArea ctermfg=20
+ redraw!
+ call assert_equal('20', synIDattr(synIDtrans(hlID('MsgArea')), 'fg'))
+ hi clear
+endfunc
+
" Test for using RGB color values in a highlight group
func Test_xxlast_highlight_RGB_color()
CheckCanRunGui
diff --git a/src/testdir/test_history.vim b/src/testdir/test_history.vim
index 482328a..19490f2 100644
--- a/src/testdir/test_history.vim
+++ b/src/testdir/test_history.vim
@@ -254,7 +254,7 @@ func Test_history_crypt_key()
set key& bs& ts&
endfunc
-" The following used to overflow and causing an use-after-free
+" The following used to overflow and causing a use-after-free
func Test_history_max_val()
set history=10
diff --git a/src/testdir/test_ins_complete.vim b/src/testdir/test_ins_complete.vim
index 52306e8..eb89a15 100644
--- a/src/testdir/test_ins_complete.vim
+++ b/src/testdir/test_ins_complete.vim
@@ -1130,7 +1130,7 @@ func Test_complete_wholeline_unlistedbuf()
edit Xfile1
enew
set complete=U
- " completing from a unloaded buffer should fail
+ " completing from an unloaded buffer should fail
exe "normal! ia\<C-X>\<C-L>\<C-P>"
call assert_equal('a', getline(1))
%d
@@ -2429,4 +2429,26 @@ func Test_complete_changed_complete_info()
call StopVimInTerminal(buf)
endfunc
+func Test_completefunc_first_call_complete_add()
+ new
+
+ func Complete(findstart, base) abort
+ if a:findstart
+ let col = col('.')
+ call complete_add('#')
+ return col - 1
+ else
+ return []
+ endif
+ endfunc
+
+ set completeopt=longest completefunc=Complete
+ " This used to cause heap-buffer-overflow
+ call assert_fails('call feedkeys("ifoo#\<C-X>\<C-U>", "xt")', 'E840:')
+
+ delfunc Complete
+ set completeopt& completefunc&
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/src/testdir/test_let.vim b/src/testdir/test_let.vim
index c99207c..2aba1d3 100644
--- a/src/testdir/test_let.vim
+++ b/src/testdir/test_let.vim
@@ -396,6 +396,45 @@ func Test_let_heredoc_fails()
call assert_report('Caught exception: ' .. v:exception)
endtry
+ try
+ let @- =<< trim TEXT
+ change
+ insert
+ append
+ TEXT
+ call assert_report('No exception thrown')
+ catch /E730:/
+ catch
+ call assert_report('Caught exception: ' .. v:exception)
+ endtry
+
+ try
+ let [] =<< trim TEXT
+ TEXT
+ call assert_report('No exception thrown')
+ catch /E475:/
+ catch
+ call assert_report('Caught exception: ' .. v:exception)
+ endtry
+
+ try
+ let [a b c] =<< trim TEXT
+ TEXT
+ call assert_report('No exception thrown')
+ catch /E475:/
+ catch
+ call assert_report('Caught exception: ' .. v:exception)
+ endtry
+
+ try
+ let [a; b; c] =<< trim TEXT
+ TEXT
+ call assert_report('No exception thrown')
+ catch /E452:/
+ catch
+ call assert_report('Caught exception: ' .. v:exception)
+ endtry
+
let text =<< trim END
func WrongSyntax()
let v =<< that there
@@ -497,6 +536,13 @@ END
XX
call assert_equal(['Line1'], var1)
+ let var1 =<< trim XX " comment
+ Line1
+ Line2
+ Line3
+ XX
+ call assert_equal(['Line1', ' Line2', 'Line3'], var1)
+
" ignore "endfunc"
let var1 =<< END
something
@@ -571,6 +617,22 @@ append
END
call assert_equal(['change', 'insert', 'append'], [a, b, c])
+ " unpack assignment with semicolon
+ let [a; b] =<< END
+change
+insert
+append
+END
+ call assert_equal(['change', ['insert', 'append']], [a, b])
+
+ " unpack assignment with registers
+ let [@/, @", @-] =<< END
+change
+insert
+append
+END
+ call assert_equal(['change', 'insert', 'append'], [@/, @", @-])
+
" curly braces name and list slice assignment
let foo_3_bar = ['', '', '']
let foo_{1 + 2}_bar[ : ] =<< END
@@ -627,6 +689,48 @@ END
END
call assert_equal(['let a = {abc}', 'let b = X', 'let c = {'], code)
+ " Evaluate a dictionary
+ let d1 = #{a: 10, b: 'ss', c: {}}
+ let code =<< eval trim END
+ let d2 = {d1}
+ END
+ call assert_equal(["let d2 = {'a': 10, 'b': 'ss', 'c': {}}"], code)
+
+ " Empty dictionary
+ let d1 = {}
+ let code =<< eval trim END
+ let d2 = {d1}
+ END
+ call assert_equal(["let d2 = {}"], code)
+
+ " null dictionary
+ let d1 = test_null_dict()
+ let code =<< eval trim END
+ let d2 = {d1}
+ END
+ call assert_equal(["let d2 = {}"], code)
+
+ " Evaluate a List
+ let l1 = ['a', 'b', 'c']
+ let code =<< eval trim END
+ let l2 = {l1}
+ END
+ call assert_equal(["let l2 = ['a', 'b', 'c']"], code)
+
+ " Empty List
+ let l1 = []
+ let code =<< eval trim END
+ let l2 = {l1}
+ END
+ call assert_equal(["let l2 = []"], code)
+
+ " Null List
+ let l1 = test_null_list()
+ let code =<< eval trim END
+ let l2 = {l1}
+ END
+ call assert_equal(["let l2 = []"], code)
+
let code = 'xxx'
let code =<< eval trim END
let n = {5 +
@@ -660,6 +764,34 @@ END
LINES
call v9.CheckScriptFailure(lines, 'E15:')
+ " Test for using heredoc in a single string using :execute or execute()
+ for [cmd, res] in items({
+ \ "let x =<< trim END\n one\n two\nEND": ['one', 'two'],
+ \ "let x =<< trim END\n one\n two\nEND": ['one', ' two'],
+ \ " let x =<< trim END\n one\n two\n END": ['one', 'two'],
+ \ " let x =<< trim END\n one\n two\n END": ['one', ' two'],
+ \ "let x =<< END\n one\n two\nEND": [' one', ' two'],
+ \ "let x =<< END\none\ntwo\nEND": ['one', 'two'],
+ \ "let x =<< END \" comment\none\ntwo\nEND": ['one', 'two'],
+ \ })
+ execute cmd
+ call assert_equal(res, x)
+ unlet x
+ call assert_equal($"\n{string(res)}", execute($"{cmd}\necho x"))
+ unlet x
+ endfor
+ for [cmd, err] in items({
+ \ "let x =<<\none\ntwo": "E172:",
+ \ "let x =<< trim\n one\n two": "E172:",
+ \ "let x =<< end\none\ntwo\nend": "E221:",
+ \ "let x =<< END\none\ntwo": "E990: Missing end marker 'END'",
+ \ "let x =<< END !\none\ntwo\nEND": "E488: Trailing characters: !",
+ \ "let x =<< eval END\none\ntwo{y}\nEND": "E121: Undefined variable: y",
+ \ })
+ call assert_fails('execute cmd', err)
+ call assert_fails('call execute(cmd)', err)
+ endfor
+
" skipped heredoc
if 0
let msg =<< trim eval END
diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim
index 8b2c27a..4c69476 100644
--- a/src/testdir/test_listdict.vim
+++ b/src/testdir/test_listdict.vim
@@ -1530,4 +1530,10 @@ func Test_indexof()
delfunc TestIdx
endfunc
+func Test_extendnew_leak()
+ " This used to leak memory
+ for i in range(100) | silent! call extendnew([], [], []) | endfor
+ for i in range(100) | silent! call extendnew({}, {}, {}) | endfor
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim
index 71d9046..1175310 100644
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -248,21 +248,25 @@ func Test_map_meta_multibyte()
endfunc
func Test_map_super_quotes()
- if has('gui_gtk') || has('gui_gtk3') || has("macos")
- imap <D-"> foo
- call feedkeys("Go-\<*D-\">-\<Esc>", "xt")
- call assert_equal("-foo-", getline('$'))
- set nomodified
- iunmap <D-">
+ if "\<D-j>"[-1:] == '>'
+ throw 'Skipped: <D- modifier not supported'
endif
+
+ imap <D-"> foo
+ call feedkeys("Go-\<*D-\">-\<Esc>", "xt")
+ call assert_equal("-foo-", getline('$'))
+ set nomodified
+ iunmap <D-">
endfunc
func Test_map_super_multibyte()
- if has('gui_gtk') || has('gui_gtk3') || has("macos")
- imap <D-á> foo
- call assert_match('i <D-á>\s*foo', execute('imap'))
- iunmap <D-á>
+ if "\<D-j>"[-1:] == '>'
+ throw 'Skipped: <D- modifier not supported'
endif
+
+ imap <D-á> foo
+ call assert_match('i <D-á>\s*foo', execute('imap'))
+ iunmap <D-á>
endfunc
func Test_abbr_after_line_join()
@@ -1807,6 +1811,49 @@ func Test_map_after_timed_out_nop()
call StopVimInTerminal(buf)
endfunc
+" Test 'showcmd' behavior with a partial mapping
+func Test_showcmd_part_map()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ set notimeout showcmd
+ nnoremap ,a <Ignore>
+ nnoremap ;a <Ignore>
+ nnoremap Àa <Ignore>
+ nnoremap Ëa <Ignore>
+ nnoremap βa <Ignore>
+ nnoremap ωa <Ignore>
+ nnoremap …a <Ignore>
+ nnoremap <C-W>a <Ignore>
+ END
+ call writefile(lines, 'Xtest_showcmd_part_map', 'D')
+ let buf = RunVimInTerminal('-S Xtest_showcmd_part_map', #{rows: 6})
+
+ call term_sendkeys(buf, ":set noruler | echo\<CR>")
+ call WaitForAssert({-> assert_equal('', term_getline(buf, 6))})
+
+ for c in [',', ';', 'À', 'Ë', 'β', 'ω', '…']
+ call term_sendkeys(buf, c)
+ call WaitForAssert({-> assert_equal(c, trim(term_getline(buf, 6)))})
+ call term_sendkeys(buf, 'a')
+ call WaitForAssert({-> assert_equal('', trim(term_getline(buf, 6)))})
+ endfor
+
+ call term_sendkeys(buf, "\<C-W>")
+ call WaitForAssert({-> assert_equal('^W', trim(term_getline(buf, 6)))})
+ call term_sendkeys(buf, 'a')
+ call WaitForAssert({-> assert_equal('', trim(term_getline(buf, 6)))})
+
+ " Use feedkeys() as terminal buffer cannot forward unsimplified Ctrl-W.
+ " This is like typing Ctrl-W with modifyOtherKeys enabled.
+ call term_sendkeys(buf, ':call feedkeys("\<*C-W>", "m")' .. " | echo\<CR>")
+ call WaitForAssert({-> assert_equal('^W', trim(term_getline(buf, 6)))})
+ call term_sendkeys(buf, 'a')
+ call WaitForAssert({-> assert_equal('', trim(term_getline(buf, 6)))})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_using_past_typeahead()
nnoremap :00 0
exe "norm :set \x80\xfb0=0\<CR>"
diff --git a/src/testdir/test_match.vim b/src/testdir/test_match.vim
index 1896158..eb77791 100644
--- a/src/testdir/test_match.vim
+++ b/src/testdir/test_match.vim
@@ -307,6 +307,7 @@ func Test_matchaddpos_error()
" Why doesn't the following error have an error code E...?
call assert_fails("call matchaddpos('Error', [{}])", 'E290:')
call assert_equal(-1, matchaddpos('Error', test_null_list()))
+ call assert_equal(-1, matchaddpos('Error', []))
call assert_fails("call matchaddpos('Error', [1], [], 1)", 'E745:')
call assert_equal(-1, matchaddpos('Search', [[]]))
call assert_fails("call matchaddpos('Search', [[{}]])", 'E728:')
@@ -433,5 +434,4 @@ func Test_match_tab_with_linebreak()
call StopVimInTerminal(buf)
endfunc
-
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_mksession.vim b/src/testdir/test_mksession.vim
index 78d301f..914d1e3 100644
--- a/src/testdir/test_mksession.vim
+++ b/src/testdir/test_mksession.vim
@@ -708,11 +708,11 @@ endfunc
func Test_mkview_no_file_name()
new
- " :mkview or :mkview {nr} should fail in a unnamed buffer.
+ " :mkview or :mkview {nr} should fail in an unnamed buffer.
call assert_fails('mkview', 'E32:')
call assert_fails('mkview 1', 'E32:')
- " :mkview {file} should succeed in a unnamed buffer.
+ " :mkview {file} should succeed in an unnamed buffer.
mkview Xview
help
source Xview
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index b180637..4b7e5e6 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -130,7 +130,7 @@ func Test_normal01_keymodel()
call assert_equal([0, 1, 1, 0], getpos("'<"))
call assert_equal([0, 3, 1, 0], getpos("'>"))
call feedkeys("Gz\<CR>8|\<S-PageUp>y", 'xt')
- call assert_equal([0, 2, 1, 0], getpos("'<"))
+ call assert_equal([0, 3, 1, 0], getpos("'<"))
call assert_equal([0, 3, 8, 0], getpos("'>"))
" Test for <S-C-Home> and <S-C-End>
call cursor(2, 12)
@@ -912,12 +912,10 @@ func Test_normal14_page()
set scrolloff=0
100
exe "norm! $\<c-b>"
- call assert_equal('92', getline('.'))
call assert_equal([0, 92, 1, 0, 1], getcurpos())
100
set nostartofline
exe "norm! $\<c-b>"
- call assert_equal('92', getline('.'))
call assert_equal([0, 92, 2, 0, v:maxcol], getcurpos())
" cleanup
set startofline
@@ -1284,7 +1282,7 @@ func Test_vert_scroll_cmds()
exe "normal \<C-U>"
call assert_equal(36, line('.'))
exe "normal \<C-U>"
- call assert_equal(10, line('.'))
+ call assert_equal(1, line('.'))
exe "normal \<C-U>"
call assert_equal(1, line('.'))
set scroll&
@@ -3815,8 +3813,8 @@ func Test_normal_vert_scroll_longline()
call assert_equal(11, line('.'))
call assert_equal(1, winline())
exe "normal \<C-B>"
- call assert_equal(10, line('.'))
- call assert_equal(3, winline())
+ call assert_equal(11, line('.'))
+ call assert_equal(5, winline())
exe "normal \<C-B>\<C-B>"
call assert_equal(5, line('.'))
call assert_equal(5, winline())
@@ -4174,12 +4172,8 @@ endfunc
" Test for { and } paragraph movements in a single line
func Test_brace_single_line()
- let text =<< trim [DATA]
- foobar one two three
- [DATA]
-
new
- call setline(1, text)
+ call setline(1, ['foobar one two three'])
1
norm! 0}
@@ -4189,4 +4183,81 @@ func Test_brace_single_line()
bw!
endfunc
+" Test for Ctrl-B/Ctrl-U in buffer with a single line
+func Test_single_line_scroll()
+ CheckFeature textprop
+
+ new
+ call setline(1, ['foobar one two three'])
+ let vt = 'virt_above'
+ call prop_type_add(vt, {'highlight': 'IncSearch'})
+ call prop_add(1, 0, {'type': vt, 'text': '---', 'text_align': 'above'})
+ call cursor(1, 1)
+
+ " Ctrl-B/Ctrl-U scroll up with hidden "above" virtual text.
+ set smoothscroll
+ exe "normal \<C-E>"
+ call assert_notequal(0, winsaveview().skipcol)
+ exe "normal \<C-B>"
+ call assert_equal(0, winsaveview().skipcol)
+ exe "normal \<C-E>"
+ call assert_notequal(0, winsaveview().skipcol)
+ exe "normal \<C-U>"
+ call assert_equal(0, winsaveview().skipcol)
+
+ set smoothscroll&
+ bw!
+ call prop_type_delete(vt)
+endfunc
+
+" Test for zb in buffer with a single line and filler lines
+func Test_single_line_filler_zb()
+ call setline(1, ['', 'foobar one two three'])
+ diffthis
+ new
+ call setline(1, ['foobar one two three'])
+ diffthis
+
+ " zb scrolls to reveal filler lines at the start of the buffer.
+ exe "normal \<C-E>zb"
+ call assert_equal(1, winsaveview().topfill)
+
+ bw!
+endfunc
+
+" Test for Ctrl-U not getting stuck at end of buffer with 'scrolloff'.
+func Test_halfpage_scrolloff_eob()
+ set scrolloff=5
+
+ call setline(1, range(1, 100))
+ exe "norm! Gzz\<C-U>zz"
+ call assert_notequal(100, line('.'))
+
+ set scrolloff&
+ bwipe!
+endfunc
+
+" Test for Ctrl-U/D moving the cursor at the buffer boundaries.
+func Test_halfpage_cursor_startend()
+ call setline(1, range(1, 100))
+ exe "norm! jztj\<C-U>"
+ call assert_equal(1, line('.'))
+ exe "norm! G\<C-Y>k\<C-D>"
+ call assert_equal(100, line('.'))
+ bwipe!
+endfunc
+
+" Test for Ctrl-F/B moving the cursor to the window boundaries.
+func Test_page_cursor_topbot()
+ 10new
+ call setline(1, range(1, 100))
+ exe "norm! gg2\<C-F>"
+ call assert_equal(17, line('.'))
+ exe "norm! \<C-B>"
+ call assert_equal(18, line('.'))
+ exe "norm! \<C-B>\<C-F>"
+ call assert_equal(9, line('.'))
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab nofoldenable
diff --git a/src/testdir/test_put.vim b/src/testdir/test_put.vim
index 5b5c354..69c2943 100644
--- a/src/testdir/test_put.vim
+++ b/src/testdir/test_put.vim
@@ -319,4 +319,21 @@ func Test_put_visual_replace_fold_marker()
bwipe!
endfunc
+func Test_put_dict()
+ new
+ let d = #{a: #{b: 'abc'}, c: [1, 2], d: 0z10}
+ put! =d
+ call assert_equal(["{'a': {'b': 'abc'}, 'c': [1, 2], 'd': 0z10}", ''],
+ \ getline(1, '$'))
+ bw!
+endfunc
+
+func Test_put_list()
+ new
+ let l = ['a', 'b', 'c']
+ put! =l
+ call assert_equal(['a', 'b', 'c', ''], getline(1, '$'))
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_recover.vim b/src/testdir/test_recover.vim
index a084ef4..e85b2e9 100644
--- a/src/testdir/test_recover.vim
+++ b/src/testdir/test_recover.vim
@@ -380,7 +380,7 @@ func Test_recover_encrypted_swap_file()
call delete('Xfile1')
endfunc
-" Test for :recover using a unreadable swap file
+" Test for :recover using an unreadable swap file
func Test_recover_unreadable_swap_file()
CheckUnix
CheckNotRoot
diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim
index 9acb12b..63f093a 100644
--- a/src/testdir/test_regexp_latin.vim
+++ b/src/testdir/test_regexp_latin.vim
@@ -874,12 +874,26 @@ func Regex_Mark()
%d
endfunc
+" Same test as above, but use verymagic
+func Regex_Mark_Verymagic()
+ call append(0, ['', '', '', 'Marks:', 'asdfSasdfsadfEasdf', 'asdfSas',
+ \ 'dfsadfEasdf', '', '', '', '', ''])
+ call cursor(4, 1)
+ exe "normal jfSmsfEme:.-4,.+6s/\\v.%>'s.*%<'e../here/\<CR>"
+ exe "normal jfSmsj0fEme:.-4,.+6s/\\v.%>'s\\_.*%<'e../again/\<CR>"
+ call assert_equal(['', '', '', 'Marks:', 'asdfhereasdf', 'asdfagainasdf',
+ \ '', '', '', '', '', ''], getline(1, '$'))
+ %d
+endfunc
+
func Test_matching_marks()
new
set regexpengine=1
call Regex_Mark()
+ call Regex_Mark_Verymagic()
set regexpengine=2
call Regex_Mark()
+ call Regex_Mark_Verymagic()
bwipe!
endfunc
diff --git a/src/testdir/test_regexp_utf8.vim b/src/testdir/test_regexp_utf8.vim
index 6669dee..bc70544 100644
--- a/src/testdir/test_regexp_utf8.vim
+++ b/src/testdir/test_regexp_utf8.vim
@@ -342,7 +342,7 @@ func Test_multibyte_chars()
endfunc
" check that 'ambiwidth' does not change the meaning of \p
-func Test_ambiwidth()
+func Test_regexp_ambiwidth()
set regexpengine=1 ambiwidth=single
call assert_equal(0, match("\u00EC", '\p'))
set regexpengine=1 ambiwidth=double
diff --git a/src/testdir/test_registers.vim b/src/testdir/test_registers.vim
index cb4cee7..b2261d4 100644
--- a/src/testdir/test_registers.vim
+++ b/src/testdir/test_registers.vim
@@ -209,6 +209,71 @@ func Test_recording_with_select_mode()
bwipe!
endfunc
+func Run_test_recording_with_select_mode_utf8()
+ new
+
+ " Test with different text lengths: 5, 7, 9, 11, 13, 15, to check that
+ " a character isn't split between two buffer blocks.
+ for s in ['12345', '口=口', '口口口', '口=口=口', '口口=口口', '口口口口口']
+ " 0x80 is K_SPECIAL
+ " 0x9B is CSI
+ " 哦: 0xE5 0x93 0xA6
+ " 洛: 0xE6 0xB4 0x9B
+ " 固: 0xE5 0x9B 0xBA
+ " 四: 0xE5 0x9B 0x9B
+ " 最: 0xE6 0x9C 0x80
+ " 倒: 0xE5 0x80 0x92
+ " 倀: 0xE5 0x80 0x80
+ for c in ['哦', '洛', '固', '四', '最', '倒', '倀']
+ call setline(1, 'asdf')
+ call feedkeys($"qacc{s}\<Esc>gH{c}\<Esc>q", "tx")
+ call assert_equal(c, getline(1))
+ call assert_equal($"cc{s}\<Esc>gH{c}\<Esc>", @a)
+ call setline(1, 'asdf')
+ normal! @a
+ call assert_equal(c, getline(1))
+
+ " Test with Shift modifier.
+ let shift_c = eval($'"\<S-{c}>"')
+ call setline(1, 'asdf')
+ call feedkeys($"qacc{s}\<Esc>gH{shift_c}\<Esc>q", "tx")
+ call assert_equal(c, getline(1))
+ call assert_equal($"cc{s}\<Esc>gH{shift_c}\<Esc>", @a)
+ call setline(1, 'asdf')
+ normal! @a
+ call assert_equal(c, getline(1))
+ endfor
+ endfor
+
+ bwipe!
+endfunc
+
+func Test_recording_with_select_mode_utf8()
+ call Run_test_recording_with_select_mode_utf8()
+endfunc
+
+" This must be done as one of the last tests, because it starts the GUI, which
+" cannot be undone.
+func Test_zz_recording_with_select_mode_utf8_gui()
+ CheckCanRunGui
+
+ gui -f
+ call Run_test_recording_with_select_mode_utf8()
+endfunc
+
+func Test_recording_with_super_mod()
+ if "\<D-j>"[-1:] == '>'
+ throw 'Skipped: <D- modifier not supported'
+ endif
+
+ nnoremap <D-j> <Ignore>
+ let s = repeat("\<D-j>", 1000)
+ " This used to crash Vim
+ call feedkeys($'qr{s}q', 'tx')
+ call assert_equal(s, @r)
+ nunmap <D-j>
+endfunc
+
" Test for executing the last used register (@)
func Test_last_used_exec_reg()
" Test for the @: command
@@ -745,13 +810,13 @@ func Test_ve_blockpaste()
call cursor(1,1)
exe ":norm! \<C-V>3ljdP"
call assert_equal(1, col('.'))
- call assert_equal(getline(1, 2), ['QWERTZ', 'ASDFGH'])
+ call assert_equal(['QWERTZ', 'ASDFGH'], getline(1, 2))
call cursor(1,1)
exe ":norm! \<C-V>3ljd"
call cursor(1,1)
norm! $3lP
call assert_equal(5, col('.'))
- call assert_equal(getline(1, 2), ['TZ QWER', 'GH ASDF'])
+ call assert_equal(['TZ QWER', 'GH ASDF'], getline(1, 2))
set ve&vim
bwipe!
endfunc
diff --git a/src/testdir/test_remote.vim b/src/testdir/test_remote.vim
index ae931fd..1475052 100644
--- a/src/testdir/test_remote.vim
+++ b/src/testdir/test_remote.vim
@@ -76,4 +76,49 @@ func Test_remote_servername()
close
endfunc
+func Test_remote_servername_shellslash()
+ " Note this test does not currently run on Windows
+ " because:
+ " 1) we cannot run the gui version of Vim inside a terminal
+ " 2) Running Windows vim.exe inside a terminal would work, but is
+ " disabled because of the limited colors inside the default Windows
+ " console (see CanRunVimInTerminal in term_util.vim)
+ CheckRunVimInTerminal
+ CheckMSWindows
+
+ " That is the file we want the server to open,
+ " despite the wildignore setting
+ call mkdir(expand('~/remote/'), 'pD')
+ call writefile(range(1, 20), expand('~/remote/XTEST.txt'), 'D')
+ " just a dummy file, so that the ':wq' further down is successful
+ call writefile(range(1, 20), 'Xdummy.log', 'D')
+
+ " Run Vim in a terminal and open a terminal window to run Vim in.
+ let lines =<< trim END
+ set shellslash
+ cd ~/remote
+ END
+ call writefile(lines, 'XRemoteEditing1.vim', 'D')
+ let buf = RunVimInTerminal('--servername XVIMTEST -S XRemoteEditing1.vim Xdummy.log', {'rows': 10})
+ call TermWait(buf)
+
+ " wildignore setting should be ignored and the XVIMTEST server should now
+ " open XTEST.txt, if wildignore setting is not ignored, the server
+ " will continue with the Xdummy.log file
+ let buf2 = RunVimInTerminal('--servername XVIMTEST --remote-silent ~/remote/XTEST.txt', {'rows': 5, 'wait_for_ruler': 0})
+ " job should be no-longer running, so we can just close it
+ exe buf2 .. 'bw!'
+
+ call term_sendkeys(buf, ":pwd\<CR>")
+ call WaitForAssert({-> assert_match('remote/$', term_getline(buf, 10))}, 1000)
+ call TermWait(buf)
+ call term_sendkeys(buf, ":q!\<CR>")
+ call TermWait(buf)
+ if term_getstatus(buf) == 'running'
+ call StopVimInTerminal(buf)
+ endif
+ bw!
+ close
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index 3467760..cda9bf0 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -552,11 +552,11 @@ func Test_smoothscroll_cursor_position()
" Test "g0/g<Home>"
exe "normal gg\<C-E>"
norm $gkg0
- call s:check_col_calc(1, 2, 21)
+ call s:check_col_calc(4, 1, 24)
" Test moving the cursor behind the <<< display with 'virtualedit'
set virtualedit=all
- exe "normal \<C-E>3lgkh"
+ exe "normal \<C-E>gkh"
call s:check_col_calc(3, 2, 23)
set virtualedit&
@@ -738,6 +738,7 @@ func Test_smoothscroll_mouse_pos()
let &mouse = save_mouse
let &term = save_term
let &ttymouse = save_ttymouse
+ bwipe!
endfunc
" this was dividing by zero
@@ -829,7 +830,7 @@ func Test_smoothscroll_eob()
call VerifyScreenDump(buf, 'Test_smooth_eob_1', {})
" cursor is not placed below window
- call term_sendkeys(buf, ":call setline(92, 'a'->repeat(100))\<CR>\<C-B>G")
+ call term_sendkeys(buf, ":call setline(92, 'a'->repeat(100))\<CR>\<C-L>\<C-B>G")
call VerifyScreenDump(buf, 'Test_smooth_eob_2', {})
call StopVimInTerminal(buf)
@@ -998,4 +999,113 @@ func Test_smoothscroll_textoff_small_winwidth()
set smoothscroll& number&
endfunc
+func Test_smoothscroll_page()
+ call NewWindow(10, 40)
+ setlocal smoothscroll
+ call setline(1, 'abcde '->repeat(150))
+
+ exe "norm! \<C-F>"
+ call assert_equal(400, winsaveview().skipcol)
+ exe "norm! \<C-F>"
+ call assert_equal(800, winsaveview().skipcol)
+ exe "norm! \<C-F>"
+ call assert_equal(880, winsaveview().skipcol)
+ exe "norm! \<C-B>"
+ call assert_equal(480, winsaveview().skipcol)
+ exe "norm! \<C-B>"
+ call assert_equal(80, winsaveview().skipcol)
+ exe "norm! \<C-B>"
+ call assert_equal(0, winsaveview().skipcol)
+
+ " Half-page scrolling does not go beyond end of buffer and moves the cursor.
+ " Even with 'nostartofline', the correct amount of lines is scrolled.
+ setl nostartofline
+ exe "norm! 15|\<C-D>"
+ call assert_equal(200, winsaveview().skipcol)
+ call assert_equal(215, col('.'))
+ exe "norm! \<C-D>"
+ call assert_equal(400, winsaveview().skipcol)
+ call assert_equal(415, col('.'))
+ exe "norm! \<C-D>"
+ call assert_equal(520, winsaveview().skipcol)
+ call assert_equal(615, col('.'))
+ exe "norm! \<C-D>"
+ call assert_equal(520, winsaveview().skipcol)
+ call assert_equal(815, col('.'))
+ exe "norm! \<C-D>"
+ call assert_equal(520, winsaveview().skipcol)
+ call assert_equal(895, col('.'))
+ exe "norm! \<C-U>"
+ call assert_equal(320, winsaveview().skipcol)
+ call assert_equal(695, col('.'))
+ exe "norm! \<C-U>"
+ call assert_equal(120, winsaveview().skipcol)
+ call assert_equal(495, col('.'))
+ exe "norm! \<C-U>"
+ call assert_equal(0, winsaveview().skipcol)
+ call assert_equal(295, col('.'))
+ exe "norm! \<C-U>"
+ call assert_equal(0, winsaveview().skipcol)
+ call assert_equal(95, col('.'))
+ exe "norm! \<C-U>"
+ call assert_equal(0, winsaveview().skipcol)
+ call assert_equal(15, col('.'))
+
+ bwipe!
+endfunc
+
+func Test_smoothscroll_next_topline()
+ call NewWindow(10, 40)
+ setlocal smoothscroll
+ call setline(1, ['abcde '->repeat(150)]->repeat(2))
+
+ " Scrolling a screenline that causes the cursor to move to the next buffer
+ " line should not skip part of that line to bring the cursor into view.
+ exe "norm! 22\<C-E>"
+ call assert_equal(880, winsaveview().skipcol)
+ exe "norm! \<C-E>"
+ redraw
+ call assert_equal(0, winsaveview().skipcol)
+
+ " Also when scrolling back.
+ exe "norm! G\<C-Y>"
+ redraw
+ call assert_equal(880, winsaveview().skipcol)
+
+ " Cursor in correct place when not in the first screenline of a buffer line.
+ exe "norm! gg4gj20\<C-D>\<C-D>"
+ redraw
+ call assert_equal(2, line('w0'))
+
+ " Cursor does not end up above topline, adjusting topline later.
+ setlocal nu cpo+=n
+ exe "norm! G$g013\<C-Y>"
+ redraw
+ call assert_equal(2, line('.'))
+ call assert_equal(0, winsaveview().skipcol)
+
+ set cpo-=n
+ bwipe!
+endfunc
+
+func Test_smoothscroll_long_line_zb()
+ call NewWindow(10, 40)
+ call setline(1, 'abcde '->repeat(150))
+
+ " Also works without 'smoothscroll' when last line of buffer doesn't fit.
+ " Used to set topline to buffer line count plus one, causing an empty screen.
+ norm zb
+ redraw
+ call assert_equal(1, winsaveview().topline)
+
+ " Moving cursor to bottom works on line that doesn't fit with 'smoothscroll'.
+ " Skipcol was adjusted later for cursor being on not visible part of line.
+ setlocal smoothscroll
+ norm zb
+ redraw
+ call assert_equal(520, winsaveview().skipcol)
+
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_sound.vim b/src/testdir/test_sound.vim
index e97ac61..401753e 100644
--- a/src/testdir/test_sound.vim
+++ b/src/testdir/test_sound.vim
@@ -15,6 +15,7 @@ func Test_play_event()
if has('win32')
throw 'Skipped: Playing event with callback is not supported on Windows'
endif
+ let g:result = 0
let g:playcallback_count = 0
let g:id = 0
let event_name = 'bell'
@@ -37,6 +38,7 @@ endfunc
func Test_play_silent()
let fname = fnamemodify('silent.wav', '%p')
let g:playcallback_count = 0
+ let g:result = -1
" play without callback
let id1 = sound_playfile(fname)
diff --git a/src/testdir/test_tabpage.vim b/src/testdir/test_tabpage.vim
index a531f19..3624790 100644
--- a/src/testdir/test_tabpage.vim
+++ b/src/testdir/test_tabpage.vim
@@ -117,10 +117,16 @@ function Test_tabpage()
call assert_equal(3, tabpagenr())
+3tabmove
call assert_equal(6, tabpagenr())
+ silent -tabmove
+ call assert_equal(5, tabpagenr())
+ silent -2 tabmove
+ call assert_equal(3, tabpagenr())
+ silent -2 tabmove
+ call assert_equal(1, tabpagenr())
- " The following are a no-op
norm! 2gt
call assert_equal(2, tabpagenr())
+ " The following are a no-op
tabmove 2
call assert_equal(2, tabpagenr())
2tabmove
diff --git a/src/testdir/test_taglist.vim b/src/testdir/test_taglist.vim
index 39e78bc..2dd2366 100644
--- a/src/testdir/test_taglist.vim
+++ b/src/testdir/test_taglist.vim
@@ -100,7 +100,10 @@ func Test_tagfiles()
help
let tf = tagfiles()
- call assert_equal(1, len(tf))
+ " if 'helplang includes another language, then we may find
+ " 2 tagfiles (e.g.: for EN and RU)
+ " we may need to adjust this, if further translated help files are included
+ call assert_inrange(1, 2, len(tf))
call assert_equal(fnamemodify(expand('$VIMRUNTIME/doc/tags'), ':p:gs?\\?/?'),
\ fnamemodify(tf[0], ':p:gs?\\?/?'))
helpclose
diff --git a/src/testdir/test_terminal3.vim b/src/testdir/test_terminal3.vim
index 96a9e63..223bcc5 100644
--- a/src/testdir/test_terminal3.vim
+++ b/src/testdir/test_terminal3.vim
@@ -931,5 +931,25 @@ func Test_terminal_term_start_error()
delfunc s:term_start_error
endfunc
+func Test_terminal_vt420()
+ CheckRunVimInTerminal
+ " For Termcap
+ CheckUnix
+ let rows=15
+ call writefile([':set term=vt420'], 'Xterm420', 'D')
+
+ let buf = RunVimInTerminal('-S Xterm420', #{rows: rows})
+ call TermWait(buf, 100)
+ call term_sendkeys(buf, ":set t_xo?\<CR>")
+ call WaitForAssert({-> assert_match('t_xo=y', term_getline(buf, rows))})
+ call StopVimInTerminal(buf)
+
+ call writefile([''], 'Xterm420')
+ let buf = RunVimInTerminal('-S Xterm420', #{rows: rows})
+ call TermWait(buf, 100)
+ call term_sendkeys(buf, ":set t_xo?\<CR>")
+ call WaitForAssert({-> assert_match('t_xo=\s\+', term_getline(buf, rows))})
+ call StopVimInTerminal(buf)
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim
index c5f5975..a9cffd0 100644
--- a/src/testdir/test_textformat.vim
+++ b/src/testdir/test_textformat.vim
@@ -1303,4 +1303,13 @@ func Test_correct_cursor_position()
set encoding=utf8
endfunc
+" This was crashing Vim
+func Test_textwdith_overflow()
+ new
+ setl tw=999999999
+ normal 10ig
+ call feedkeys('a ab cd ef', 'xt')
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index a06f733..2bf2834 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2690,6 +2690,48 @@ func Test_prop_inserts_text_normal_gj_gk()
call Run_test_prop_inserts_text_normal_gj_gk('set virtualedit=all')
endfunc
+func Test_prop_normal_gj_gk_gM_with_outer_virtual_text()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ vim9script
+ setlocal number
+ setline(1, ['First line fits on screen line.', '', 'Third line fits on screen line.'])
+
+ var vt = 'test'
+ prop_type_add(vt, {highlight: 'ToDo'})
+ for ln in range(1, line('$'))
+ prop_add(ln, 0, {type: vt, text: 'Above', text_align: 'above'})
+ prop_add(ln, 0, {type: vt, text: 'After text wraps to next line.', text_align: 'after', text_wrap: 'wrap'})
+ prop_add(ln, 0, {type: vt, text: 'Right text wraps to next line.', text_align: 'right', text_wrap: 'wrap'})
+ prop_add(ln, 0, {type: vt, text: 'Below', text_align: 'below'})
+ endfor
+ normal 3l
+ END
+ call writefile(lines, 'XscriptPropsNormal_gj_gk_gM_with_outer_text', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropsNormal_gj_gk_gM_with_outer_text', #{rows: 16, cols: 40})
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1', {})
+
+ call term_sendkeys(buf, "gj")
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2', {})
+ call term_sendkeys(buf, "gj")
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3', {})
+ call term_sendkeys(buf, "gk")
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_2', {})
+ call term_sendkeys(buf, "gk")
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1', {})
+
+ call term_sendkeys(buf, "2gj")
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_3', {})
+ call term_sendkeys(buf, "2gk")
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_1', {})
+
+ call term_sendkeys(buf, "gM")
+ call VerifyScreenDump(buf, 'Test_prop_normal_gj_gk_gM_with_outer_virtual_text_4', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_prop_inserts_text_visual_block()
CheckRunVimInTerminal
@@ -3026,6 +3068,43 @@ func Test_props_with_text_after_below_trunc()
call StopVimInTerminal(buf)
endfunc
+func Test_props_with_text_truncated_just_before_after()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ vim9script
+ set showbreak=+++
+ set list listchars=extends:>
+ set nowrap
+
+ setline(1, [
+ 'here is text long enough to fill the row',
+ 'second line',
+ ])
+
+ prop_type_add("test", {"highlight": "Error"})
+ prop_add(1, 0, {type: "test", text_align: "right", text: "right text"})
+ def g:AddPropBelow()
+ prop_add(1, 0, {type: "test", text_align: "below", text: "below text"})
+ enddef
+ def g:AddPropAfter()
+ prop_add(1, 0, {type: "test", text: "after text", text_padding_left: 1})
+ enddef
+ normal G$
+ END
+ call writefile(lines, 'XscriptPropsWithTextTruncatedJustBeforeAfter', 'D')
+ let buf = RunVimInTerminal('-S XscriptPropsWithTextTruncatedJustBeforeAfter', #{rows: 8, cols: 40})
+ call VerifyScreenDump(buf, 'Test_props_with_text_truncated_just_before_after_1', {})
+
+ call term_sendkeys(buf, ":call AddPropBelow()\<CR>")
+ call VerifyScreenDump(buf, 'Test_props_with_text_truncated_just_before_after_2', {})
+
+ call term_sendkeys(buf, ":call AddPropAfter()\<CR>:\<Esc>")
+ call VerifyScreenDump(buf, 'Test_props_with_text_truncated_just_before_after_2', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
func Test_prop_with_text_below_after_empty()
CheckRunVimInTerminal
diff --git a/src/testdir/test_utf8.vim b/src/testdir/test_utf8.vim
index 3bb7459..0f46240 100644
--- a/src/testdir/test_utf8.vim
+++ b/src/testdir/test_utf8.vim
@@ -62,6 +62,9 @@ func Test_customlist_completion()
call assert_equal('"Test3 N', getreg(':'))
call garbagecollect(1)
+ delcommand Test1
+ delcommand Test2
+ delcommand Test3
endfunc
" Yank one 3 byte character and check the mark columns.
@@ -170,6 +173,7 @@ func Test_screenchar_utf8()
endfunc
func Test_setcellwidths()
+ new
call setcellwidths([
\ [0x1330, 0x1330, 2],
\ [9999, 10000, 1],
@@ -212,6 +216,18 @@ func Test_setcellwidths()
" Ambiguous width chars
call assert_equal(2, strwidth("\u00A1"))
call assert_equal(2, strwidth("\u2010"))
+
+ call setcellwidths([])
+ call setline(1, repeat("\u2103", 10))
+ normal! $
+ redraw
+ call assert_equal((aw == 'single') ? 10 : 19, wincol())
+ call setcellwidths([[0x2103, 0x2103, 1]])
+ redraw
+ call assert_equal(10, wincol())
+ call setcellwidths([[0x2103, 0x2103, 2]])
+ redraw
+ call assert_equal(19, wincol())
endfor
set ambiwidth& isprint&
@@ -245,6 +261,7 @@ func Test_setcellwidths()
set listchars&
set fillchars&
call setcellwidths([])
+ bwipe!
endfunc
func Test_getcellwidths()
@@ -283,64 +300,66 @@ func Test_setcellwidths_dump()
call StopVimInTerminal(buf)
endfunc
-func Test_print_overlong()
- " Text with more composing characters than MB_MAXBYTES.
- new
- call setline(1, 'axxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
- s/x/\=nr2char(1629)/g
- print
- bwipe!
-endfunc
+" Test setcellwidths() on characters that are not targets of 'ambiwidth'.
+func Test_setcellwidths_with_non_ambiwidth_character_dump()
+ CheckRunVimInTerminal
-func Test_recording_with_select_mode_utf8()
- call Run_test_recording_with_select_mode_utf8()
+ let lines =<< trim END
+ call setline(1, [repeat("\u279c", 60), repeat("\u279c", 60)])
+ set ambiwidth=single
+ END
+ call writefile(lines, 'XCellwidthsWithNonAmbiwidthCharacter', 'D')
+ let buf = RunVimInTerminal('-S XCellwidthsWithNonAmbiwidthCharacter', {'rows': 6, 'cols': 50})
+ call term_sendkeys(buf, ":call setcellwidths([[0x279c, 0x279c, 1]])\<CR>")
+ call term_sendkeys(buf, ":echo\<CR>")
+ call VerifyScreenDump(buf, 'Test_setcellwidths_with_non_ambiwidth_character_dump_1', {})
+
+ call term_sendkeys(buf, ":call setcellwidths([[0x279c, 0x279c, 2]])\<CR>")
+ call term_sendkeys(buf, ":echo\<CR>")
+ call VerifyScreenDump(buf, 'Test_setcellwidths_with_non_ambiwidth_character_dump_2', {})
+
+ call StopVimInTerminal(buf)
endfunc
-func Run_test_recording_with_select_mode_utf8()
- new
+" For some reason this test causes Test_customlist_completion() to fail on CI,
+" so run it as the last test.
+func Test_zz_ambiwidth_hl_dump()
+ CheckRunVimInTerminal
- " No escaping
- call feedkeys("qacc12345\<Esc>gH哦\<Esc>q", "tx")
- call assert_equal("哦", getline(1))
- call assert_equal("cc12345\<Esc>gH哦\<Esc>", @a)
- call setline(1, 'asdf')
- normal! @a
- call assert_equal("哦", getline(1))
-
- " 固 is 0xE5 0x9B 0xBA where 0x9B is CSI
- call feedkeys("qacc12345\<Esc>gH固\<Esc>q", "tx")
- call assert_equal("固", getline(1))
- call assert_equal("cc12345\<Esc>gH固\<Esc>", @a)
- call setline(1, 'asdf')
- normal! @a
- call assert_equal("固", getline(1))
-
- " 四 is 0xE5 0x9B 0x9B where 0x9B is CSI
- call feedkeys("qacc12345\<Esc>gH四\<Esc>q", "tx")
- call assert_equal("四", getline(1))
- call assert_equal("cc12345\<Esc>gH四\<Esc>", @a)
- call setline(1, 'asdf')
- normal! @a
- call assert_equal("四", getline(1))
-
- " 倒 is 0xE5 0x80 0x92 where 0x80 is K_SPECIAL
- call feedkeys("qacc12345\<Esc>gH倒\<Esc>q", "tx")
- call assert_equal("倒", getline(1))
- call assert_equal("cc12345\<Esc>gH倒\<Esc>", @a)
- call setline(1, 'asdf')
- normal! @a
- call assert_equal("倒", getline(1))
+ let lines =<< trim END
+ call setline(1, [repeat("\u2103", 60), repeat("\u2103", 60)])
+ set ambiwidth=single cursorline list display=lastline
+ END
+ call writefile(lines, 'XAmbiwidthHl', 'D')
+ let buf = RunVimInTerminal('-S XAmbiwidthHl', {'rows': 6, 'cols': 50})
+ call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_1', {})
- bwipe!
-endfunc
+ call term_sendkeys(buf, ":set ambiwidth=double\<CR>")
+ call term_sendkeys(buf, ":echo\<CR>")
+ call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_2', {})
+
+ call term_sendkeys(buf, ":set ambiwidth=single\<CR>")
+ call term_sendkeys(buf, ":echo\<CR>")
+ call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_1', {})
+
+ call term_sendkeys(buf, ":call setcellwidths([[0x2103, 0x2103, 2]])\<CR>")
+ call term_sendkeys(buf, ":echo\<CR>")
+ call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_2', {})
+
+ call term_sendkeys(buf, ":call setcellwidths([[0x2103, 0x2103, 1]])\<CR>")
+ call term_sendkeys(buf, ":echo\<CR>")
+ call VerifyScreenDump(buf, 'Test_ambiwidth_hl_dump_1', {})
-" This must be done as one of the last tests, because it starts the GUI, which
-" cannot be undone.
-func Test_zz_recording_with_select_mode_utf8_gui()
- CheckCanRunGui
+ call StopVimInTerminal(buf)
+endfunc
- gui -f
- call Run_test_recording_with_select_mode_utf8()
+func Test_print_overlong()
+ " Text with more composing characters than MB_MAXBYTES.
+ new
+ call setline(1, 'axxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
+ s/x/\=nr2char(1629)/g
+ print
+ bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_vim9_assign.vim b/src/testdir/test_vim9_assign.vim
index 4414f55..4296c37 100644
--- a/src/testdir/test_vim9_assign.vim
+++ b/src/testdir/test_vim9_assign.vim
@@ -1104,6 +1104,27 @@ def Test_assignment_partial()
Ref(0)
END
v9.CheckScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected string but got number')
+
+ lines =<< trim END
+ var Fn1 = () => {
+ return 10
+ }
+ assert_equal('func(): number', typename(Fn1))
+ var Fn2 = () => {
+ return "a"
+ }
+ assert_equal('func(): string', typename(Fn2))
+ var Fn3 = () => {
+ return {a: [1]}
+ }
+ assert_equal('func(): dict<list<number>>', typename(Fn3))
+ var Fn4 = (...l: list<string>) => {
+ return []
+ }
+ assert_equal('func(...list<string>): list<any>', typename(Fn4))
+ END
+ v9.CheckSourceSuccess(['vim9script'] + lines)
+ v9.CheckSourceSuccess(['def Xfunc()'] + lines + ['enddef', 'defcompile'])
enddef
def Test_assignment_list_any_index()
@@ -1997,6 +2018,31 @@ def Test_heredoc()
END
v9.CheckScriptSuccess(lines)
+ # commented out heredoc assignment without space after '#'
+ lines =<< trim END
+ vim9script
+ def Func()
+ #x =<< trim [CODE]
+ #[CODE]
+ enddef
+ Func()
+ END
+ v9.CheckScriptSuccess(lines)
+
+ # heredoc start should not be recognized in string
+ lines =<< trim END
+ vim9script
+ def Func()
+ new
+ @" = 'bar'
+ ['foo', @"]->setline("]=<<"->count('='))
+ assert_equal(['foo', 'bar'], getline(1, '$'))
+ bwipe!
+ enddef
+ Func()
+ END
+ v9.CheckScriptSuccess(lines)
+
v9.CheckDefFailure(['var lines =<< trim END X', 'END'], 'E488:')
v9.CheckDefFailure(['var lines =<< trim END " comment', 'END'], 'E488:')
@@ -2938,6 +2984,66 @@ def Test_heredoc_expr()
CODE
v9.CheckDefAndScriptSuccess(lines)
+ # Evaluate a dictionary
+ lines =<< trim CODE
+ var d1 = {'a': 10, 'b': [1, 2]}
+ var code =<< trim eval END
+ var d2 = {d1}
+ END
+ assert_equal(["var d2 = {'a': 10, 'b': [1, 2]}"], code)
+ CODE
+ v9.CheckDefAndScriptSuccess(lines)
+
+ # Evaluate an empty dictionary
+ lines =<< trim CODE
+ var d1 = {}
+ var code =<< trim eval END
+ var d2 = {d1}
+ END
+ assert_equal(["var d2 = {}"], code)
+ CODE
+ v9.CheckDefAndScriptSuccess(lines)
+
+ # Evaluate a null dictionary
+ lines =<< trim CODE
+ var d1 = test_null_dict()
+ var code =<< trim eval END
+ var d2 = {d1}
+ END
+ assert_equal(["var d2 = {}"], code)
+ CODE
+ v9.CheckDefAndScriptSuccess(lines)
+
+ # Evaluate a List
+ lines =<< trim CODE
+ var l1 = ['a', 'b', 'c']
+ var code =<< trim eval END
+ var l2 = {l1}
+ END
+ assert_equal(["var l2 = ['a', 'b', 'c']"], code)
+ CODE
+ v9.CheckDefAndScriptSuccess(lines)
+
+ # Evaluate an empty List
+ lines =<< trim CODE
+ var l1 = []
+ var code =<< trim eval END
+ var l2 = {l1}
+ END
+ assert_equal(["var l2 = []"], code)
+ CODE
+ v9.CheckDefAndScriptSuccess(lines)
+
+ # Evaluate a null List
+ lines =<< trim CODE
+ var l1 = test_null_list()
+ var code =<< trim eval END
+ var l2 = {l1}
+ END
+ assert_equal(["var l2 = []"], code)
+ CODE
+ v9.CheckDefAndScriptSuccess(lines)
+
lines =<< trim CODE
var code =<< eval trim END
var s = "{$SOME_ENV_VAR}"
diff --git a/src/testdir/test_vim9_builtin.vim b/src/testdir/test_vim9_builtin.vim
index 442d375..42d09fe 100644
--- a/src/testdir/test_vim9_builtin.vim
+++ b/src/testdir/test_vim9_builtin.vim
@@ -66,16 +66,16 @@ def Test_abs()
assert_equal(0, abs(0))
assert_equal(2, abs(-2))
assert_equal(3, abs(3))
- v9.CheckDefAndScriptFailure(['abs("text")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['abs("text")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal(0, abs(0))
assert_equal(2.0, abs(-2.0))
assert_equal(3.0, abs(3.0))
enddef
def Test_add()
- v9.CheckDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1226: List or Blob required for argument 1'])
- v9.CheckDefAndScriptFailure(['add([])'], 'E119:')
- v9.CheckDefExecFailure([
+ v9.CheckSourceDefAndScriptFailure(['add({}, 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1226: List or Blob required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['add([])'], 'E119:')
+ v9.CheckSourceDefExecFailure([
'var ln: list<number> = [1]',
'add(ln, "a")'],
'E1012: Type mismatch; expected number but got string')
@@ -91,7 +91,7 @@ def Test_add()
enddef
TryChange()
END
- v9.CheckScriptFailure(lines, 'E741:')
+ v9.CheckSourceScriptFailure(lines, 'E741:')
enddef
def Test_add_blob()
@@ -107,18 +107,18 @@ def Test_add_blob()
var b: blob
add(b, "x")
END
- v9.CheckDefFailure(lines, 'E1012:', 2)
+ v9.CheckSourceDefFailure(lines, 'E1012:', 2)
lines =<< trim END
add(test_null_blob(), 123)
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1131:', 1)
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1131:', 1)
lines =<< trim END
var b: blob = test_null_blob()
add(b, 123)
END
- v9.CheckDefExecFailure(lines, 'E1131:', 2)
+ v9.CheckSourceDefExecFailure(lines, 'E1131:', 2)
# Getting variable with NULL blob fails
lines =<< trim END
@@ -126,7 +126,7 @@ def Test_add_blob()
var b: blob = test_null_blob()
add(b, 123)
END
- v9.CheckScriptFailure(lines, 'E1131:', 3)
+ v9.CheckSourceScriptFailure(lines, 'E1131:', 3)
enddef
def Test_add_list()
@@ -138,18 +138,18 @@ def Test_add_list()
var l: list<number>
add(l, "x")
END
- v9.CheckDefFailure(lines, 'E1012:', 2)
+ v9.CheckSourceDefFailure(lines, 'E1012:', 2)
lines =<< trim END
add(test_null_list(), 123)
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1130:', 1)
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1130:', 1)
lines =<< trim END
var l: list<number> = test_null_list()
add(l, 123)
END
- v9.CheckDefExecFailure(lines, 'E1130:', 2)
+ v9.CheckSourceDefExecFailure(lines, 'E1130:', 2)
# Getting an uninitialized variable allocates a new list at script level
lines =<< trim END
@@ -157,7 +157,7 @@ def Test_add_list()
var l: list<number>
add(l, 123)
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
# Adding to a variable set to a NULL list fails
lines =<< trim END
@@ -165,21 +165,21 @@ def Test_add_list()
var l: list<number> = test_null_list()
add(l, 123)
END
- v9.CheckScriptFailure(lines, 'E1130:', 3)
+ v9.CheckSourceScriptFailure(lines, 'E1130:', 3)
lines =<< trim END
vim9script
var l: list<string> = ['a']
l->add(123)
END
- v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3)
+ v9.CheckSourceScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3)
lines =<< trim END
vim9script
var l: list<string>
l->add(123)
END
- v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3)
+ v9.CheckSourceScriptFailure(lines, 'E1012: Type mismatch; expected string but got number', 3)
enddef
def Test_add_const()
@@ -187,26 +187,26 @@ def Test_add_const()
const l = [1, 2]
add(l, 3)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
lines =<< trim END
final l = [1, 2]
add(l, 3)
assert_equal([1, 2, 3], l)
END
- v9.CheckDefSuccess(lines)
+ v9.CheckSourceDefSuccess(lines)
lines =<< trim END
const b = 0z0102
add(b, 0z03)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const blob')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const blob')
enddef
def Test_and()
- v9.CheckDefAndScriptFailure(['and("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['and(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['and("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['and(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_append()
@@ -224,12 +224,12 @@ def Test_append()
assert_equal("{'a': 10}", getline(1))
append(0, function('min'))
assert_equal("function('min')", getline(1))
- v9.CheckDefAndScriptFailure(['append([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['append("", "x")'], 'E1209: Invalid value for a line number')
- v9.CheckDefExecAndScriptFailure(['append(".a", "x")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['append([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['append("", "x")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecAndScriptFailure(['append(".a", "x")'], 'E1209: Invalid value for a line number')
# only get one error
assert_fails('append("''aa", "x")', ['E1209: Invalid value for a line number: "''aa"', 'E1209:'])
- v9.CheckDefExecAndScriptFailure(['append(-1, "x")'], 'E966: Invalid line number: -1')
+ v9.CheckSourceDefExecAndScriptFailure(['append(-1, "x")'], 'E966: Invalid line number: -1')
bwipe!
enddef
@@ -245,12 +245,12 @@ def Test_appendbufline()
assert_equal(['0', 'one', '1', 'two', '2', ''], getbufline(bnum, 1, '$'))
appendbufline(bnum, 0, 'zero')
assert_equal(['zero'], getbufline(bnum, 1))
- v9.CheckDefAndScriptFailure(['appendbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['appendbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1')
- v9.CheckDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', "$a", "x")'], 'E1030: Using a String as a Number: "$a"')
+ v9.CheckSourceDefAndScriptFailure(['appendbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['appendbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1')
+ v9.CheckSourceDefExecAndScriptFailure(['appendbufline(' .. bnum .. ', "$a", "x")'], 'E1030: Using a String as a Number: "$a"')
assert_fails('appendbufline(' .. bnum .. ', "$a", "x")', ['E1030: Using a String as a Number: "$a"', 'E1030:'])
- v9.CheckDefAndScriptFailure(['appendbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['appendbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 3'])
bnum->bufwinid()->win_gotoid()
appendbufline('', 0, 'numbers')
getline(1)->assert_equal('numbers')
@@ -258,80 +258,80 @@ def Test_appendbufline()
enddef
def Test_argc()
- v9.CheckDefAndScriptFailure(['argc("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['argc("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_arglistid()
- v9.CheckDefAndScriptFailure(['arglistid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['arglistid(1, "y")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['arglistid("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['arglistid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['arglistid(1, "y")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['arglistid("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_argv()
- v9.CheckDefAndScriptFailure(['argv("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['argv(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['argv("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['argv("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['argv(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['argv("x", "y")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_assert_beeps()
- v9.CheckDefAndScriptFailure(['assert_beeps(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['assert_beeps(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
enddef
def Test_assert_equalfile()
- v9.CheckDefAndScriptFailure(['assert_equalfile(1, "f2")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['assert_equalfile("f1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['assert_equalfile("f1", "f2", ["a"])'], ['E1013: Argument 3: type mismatch, expected string but got list<string>', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['assert_equalfile(1, "f2")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['assert_equalfile("f1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['assert_equalfile("f1", "f2", ["a"])'], ['E1013: Argument 3: type mismatch, expected string but got list<string>', 'E1174: String required for argument 3'])
enddef
def Test_assert_exception()
- v9.CheckDefAndScriptFailure(['assert_exception({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['assert_exception("E1:", v:null)'], ['E1013: Argument 2: type mismatch, expected string but got special', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['assert_exception({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['assert_exception("E1:", v:null)'], ['E1013: Argument 2: type mismatch, expected string but got special', 'E1174: String required for argument 2'])
enddef
def Test_assert_fails()
- v9.CheckDefAndScriptFailure(['assert_fails([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['assert_fails("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1222: String or List required for argument 2'])
- v9.CheckDefAndScriptFailure(['assert_fails("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
- v9.CheckDefAndScriptFailure(['assert_fails("a", "b", "c", 4, 5)'], ['E1013: Argument 5: type mismatch, expected string but got number', 'E1174: String required for argument 5'])
+ v9.CheckSourceDefAndScriptFailure(['assert_fails([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['assert_fails("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1222: String or List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['assert_fails("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['assert_fails("a", "b", "c", 4, 5)'], ['E1013: Argument 5: type mismatch, expected string but got number', 'E1174: String required for argument 5'])
enddef
def Test_assert_inrange()
- v9.CheckDefAndScriptFailure(['assert_inrange("a", 2, 3)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['assert_inrange(1, "b", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['assert_inrange(1, 2, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['assert_inrange(1, 2, 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['assert_inrange("a", 2, 3)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['assert_inrange(1, "b", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['assert_inrange(1, 2, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['assert_inrange(1, 2, 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
enddef
def Test_assert_match()
- v9.CheckDefAndScriptFailure(['assert_match({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', ''])
- v9.CheckDefAndScriptFailure(['assert_match("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', ''])
- v9.CheckDefAndScriptFailure(['assert_match("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', ''])
+ v9.CheckSourceDefAndScriptFailure(['assert_match({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', ''])
+ v9.CheckSourceDefAndScriptFailure(['assert_match("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', ''])
+ v9.CheckSourceDefAndScriptFailure(['assert_match("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', ''])
enddef
def Test_assert_nobeep()
- v9.CheckDefAndScriptFailure(['assert_nobeep(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['assert_nobeep(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
enddef
def Test_assert_notmatch()
- v9.CheckDefAndScriptFailure(['assert_notmatch({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', ''])
- v9.CheckDefAndScriptFailure(['assert_notmatch("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', ''])
- v9.CheckDefAndScriptFailure(['assert_notmatch("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', ''])
+ v9.CheckSourceDefAndScriptFailure(['assert_notmatch({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', ''])
+ v9.CheckSourceDefAndScriptFailure(['assert_notmatch("a", 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', ''])
+ v9.CheckSourceDefAndScriptFailure(['assert_notmatch("a", "b", null)'], ['E1013: Argument 3: type mismatch, expected string but got special', ''])
enddef
def Test_assert_report()
- v9.CheckDefAndScriptFailure(['assert_report([1, 2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['assert_report([1, 2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
enddef
def Test_autocmd_add()
- v9.CheckDefAndScriptFailure(['autocmd_add({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['autocmd_add({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
enddef
def Test_autocmd_delete()
- v9.CheckDefAndScriptFailure(['autocmd_delete({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['autocmd_delete({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
enddef
def Test_autocmd_get()
- v9.CheckDefAndScriptFailure(['autocmd_get(10)'], ['E1013: Argument 1: type mismatch, expected dict<any> but got number', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['autocmd_get(10)'], ['E1013: Argument 1: type mismatch, expected dict<any> but got number', 'E1206: Dictionary required for argument 1'])
enddef
def Test_balloon_show()
@@ -341,8 +341,8 @@ def Test_balloon_show()
assert_fails('balloon_show(10)', 'E1222:')
assert_fails('balloon_show(true)', 'E1222:')
- v9.CheckDefAndScriptFailure(['balloon_show(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['balloon_show({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['balloon_show(1.2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['balloon_show({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
enddef
def Test_balloon_split()
@@ -354,22 +354,22 @@ enddef
def Test_blob2list()
assert_equal(['x', 'x'], blob2list(0z1234)->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['blob2list(10)'], ['E1013: Argument 1: type mismatch, expected blob but got number', 'E1238: Blob required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['blob2list(10)'], ['E1013: Argument 1: type mismatch, expected blob but got number', 'E1238: Blob required for argument 1'])
enddef
def Test_browse()
CheckFeature browse
- v9.CheckDefAndScriptFailure(['browse(2, "title", "dir", "file")'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['browse(true, 2, "dir", "file")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['browse(true, "title", 3, "file")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
- v9.CheckDefAndScriptFailure(['browse(true, "title", "dir", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['browse(2, "title", "dir", "file")'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['browse(true, 2, "dir", "file")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['browse(true, "title", 3, "file")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['browse(true, "title", "dir", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
enddef
def Test_browsedir()
if has('browse')
- v9.CheckDefAndScriptFailure(['browsedir({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['browsedir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['browsedir({}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['browsedir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
endif
enddef
@@ -425,8 +425,8 @@ def Test_bufnr()
buf = bufnr('Xdummy', true)
buf->assert_notequal(-1)
exe 'bwipe! ' .. buf
- v9.CheckDefAndScriptFailure(['bufnr([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['bufnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['bufnr([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['bufnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
enddef
def Test_bufwinid()
@@ -452,23 +452,23 @@ def Test_bufwinnr()
enddef
def Test_byte2line()
- v9.CheckDefAndScriptFailure(['byte2line("1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['byte2line([])'], ['E1013: Argument 1: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['byte2line("1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['byte2line([])'], ['E1013: Argument 1: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 1'])
byte2line(0)->assert_equal(-1)
enddef
def Test_byteidx()
- v9.CheckDefAndScriptFailure(['byteidx(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['byteidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['byteidx("a", 0, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['byteidx(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['byteidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['byteidx("a", 0, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
byteidx('', 0)->assert_equal(0)
byteidx('', 1)->assert_equal(-1)
enddef
def Test_byteidxcomp()
- v9.CheckDefAndScriptFailure(['byteidxcomp(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['byteidxcomp("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['byteidxcomp("a", 0, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['byteidxcomp(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['byteidxcomp("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['byteidxcomp("a", 0, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
enddef
def Test_call_call()
@@ -488,20 +488,20 @@ def Test_call_call()
assert_equal('Inner', g:done)
unlet g:done
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
delfunc g:Inner
- v9.CheckDefExecAndScriptFailure(['call(123, [2])'], 'E1256: String or function required for argument 1')
- v9.CheckDefExecAndScriptFailure(['call(true, [2])'], 'E1256: String or function required for argument 1')
- v9.CheckDefAndScriptFailure(['call("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
- v9.CheckDefAndScriptFailure(['call("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['call(123, [2])'], 'E1256: String or function required for argument 1')
+ v9.CheckSourceDefExecAndScriptFailure(['call(true, [2])'], 'E1256: String or function required for argument 1')
+ v9.CheckSourceDefAndScriptFailure(['call("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['call("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
enddef
def Test_ch_canread()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_canread(10)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_canread(10)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
endif
enddef
@@ -509,7 +509,7 @@ def Test_ch_close()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_close("c")'], ['E1013: Argument 1: type mismatch, expected channel but got string', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_close("c")'], ['E1013: Argument 1: type mismatch, expected channel but got string', 'E1217: Channel or Job required for argument 1'])
endif
enddef
@@ -517,7 +517,7 @@ def Test_ch_close_in()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_close_in(true)'], ['E1013: Argument 1: type mismatch, expected channel but got bool', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_close_in(true)'], ['E1013: Argument 1: type mismatch, expected channel but got bool', 'E1217: Channel or Job required for argument 1'])
endif
enddef
@@ -525,8 +525,8 @@ def Test_ch_evalexpr()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_evalexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_evalexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['ch_evalexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_evalexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
endif
enddef
@@ -534,9 +534,9 @@ def Test_ch_evalraw()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_evalraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_evalraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2'])
- v9.CheckDefAndScriptFailure(['ch_evalraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['ch_evalraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_evalraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_evalraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
endif
enddef
@@ -544,8 +544,8 @@ def Test_ch_getbufnr()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_getbufnr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_getbufnr(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_getbufnr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_getbufnr(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
# test empty string argument for ch_getbufnr()
var job: job = job_start(&shell)
g:WaitForAssert(() => assert_equal('run', job_status(job)))
@@ -558,8 +558,8 @@ def Test_ch_getjob()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_getjob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_getjob({"a": 10})'], ['E1013: Argument 1: type mismatch, expected channel but got dict<number>', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_getjob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_getjob({"a": 10})'], ['E1013: Argument 1: type mismatch, expected channel but got dict<number>', 'E1217: Channel or Job required for argument 1'])
assert_equal(0, ch_getjob(test_null_channel()))
endif
enddef
@@ -568,7 +568,7 @@ def Test_ch_info()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_info([1])'], ['E1013: Argument 1: type mismatch, expected channel but got list<number>', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_info([1])'], ['E1013: Argument 1: type mismatch, expected channel but got list<number>', 'E1217: Channel or Job required for argument 1'])
endif
enddef
@@ -576,8 +576,8 @@ def Test_ch_log()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_log(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_log("a", 1)'], ['E1013: Argument 2: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_log(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_log("a", 1)'], ['E1013: Argument 2: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 2'])
endif
enddef
@@ -589,8 +589,8 @@ def Test_ch_logfile()
assert_fails('ch_logfile("foo", true)', 'E1174:')
ch_logfile('', '')->assert_equal(0)
- v9.CheckDefAndScriptFailure(['ch_logfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_logfile("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_logfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_logfile("a", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1174: String required for argument 2'])
endif
enddef
@@ -598,9 +598,9 @@ def Test_ch_open()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_open({"a": 10}, "a")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_open("a", [1])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['ch_open("")'], 'E475: Invalid argument')
+ v9.CheckSourceDefAndScriptFailure(['ch_open({"a": 10}, "a")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_open("a", [1])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['ch_open("")'], 'E475: Invalid argument')
endif
enddef
@@ -608,8 +608,8 @@ def Test_ch_read()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_read(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_read(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_read(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_read(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
endif
enddef
@@ -617,8 +617,8 @@ def Test_ch_readblob()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_readblob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_readblob(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_readblob(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_readblob(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
endif
enddef
@@ -626,8 +626,8 @@ def Test_ch_readraw()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_readraw(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_readraw(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_readraw(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_readraw(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
endif
enddef
@@ -635,8 +635,8 @@ def Test_ch_sendexpr()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_sendexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_sendexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['ch_sendexpr(1, "a")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_sendexpr(test_null_channel(), 1, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
endif
enddef
@@ -644,9 +644,9 @@ def Test_ch_sendraw()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_sendraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_sendraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2'])
- v9.CheckDefAndScriptFailure(['ch_sendraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['ch_sendraw(1, "")'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_sendraw(test_null_channel(), 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1221: String or Blob required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_sendraw(test_null_channel(), "", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
endif
enddef
@@ -654,8 +654,8 @@ def Test_ch_setoptions()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_setoptions(1, {})'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_setoptions(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_setoptions(1, {})'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_setoptions(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
endif
enddef
@@ -663,8 +663,8 @@ def Test_ch_status()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['ch_status(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['ch_status(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['ch_status(1)'], ['E1013: Argument 1: type mismatch, expected channel but got number', 'E1217: Channel or Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ch_status(test_null_channel(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
endif
enddef
@@ -672,8 +672,8 @@ def Test_char2nr()
char2nr('あ', true)->assert_equal(12354)
assert_fails('char2nr(true)', 'E1174:')
- v9.CheckDefAndScriptFailure(['char2nr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['char2nr("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['char2nr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['char2nr("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
assert_equal(97, char2nr('a', 1))
assert_equal(97, char2nr('a', 0))
assert_equal(97, char2nr('a', true))
@@ -687,10 +687,10 @@ def Test_charclass()
enddef
def Test_charcol()
- v9.CheckDefAndScriptFailure(['charcol(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['charcol({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['charcol(".", [])'], ['E1013: Argument 2: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['charcol("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['charcol(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['charcol({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['charcol(".", [])'], ['E1013: Argument 2: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['charcol("")'], 'E1209: Invalid value for a line number')
new
setline(1, ['abcdefgh'])
cursor(1, 4)
@@ -701,10 +701,10 @@ def Test_charcol()
enddef
def Test_charidx()
- v9.CheckDefAndScriptFailure(['charidx(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['charidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['charidx("a", 1, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
- v9.CheckDefAndScriptFailure(['charidx("a", 1, 0, "")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['charidx(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['charidx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['charidx("a", 1, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['charidx("a", 1, 0, "")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4'])
charidx('', 0)->assert_equal(0)
charidx('', 1)->assert_equal(-1)
enddef
@@ -714,15 +714,15 @@ def Test_chdir()
enddef
def Test_cindent()
- v9.CheckDefAndScriptFailure(['cindent([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['cindent(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['cindent("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['cindent([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['cindent(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['cindent("")'], 'E1209: Invalid value for a line number')
assert_equal(-1, cindent(0))
assert_equal(0, cindent('.'))
enddef
def Test_clearmatches()
- v9.CheckDefAndScriptFailure(['clearmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['clearmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_col()
@@ -735,26 +735,26 @@ def Test_col()
assert_fails('col(true)', 'E1222:')
- v9.CheckDefAndScriptFailure(['col(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['col({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['col(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['col(".", [])'], ['E1013: Argument 2: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['col("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['col(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['col({a: 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['col(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['col(".", [])'], ['E1013: Argument 2: type mismatch, expected number but got list<any>', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['col("")'], 'E1209: Invalid value for a line number')
bw!
enddef
def Test_complete()
- v9.CheckDefAndScriptFailure(['complete("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['complete(1, {})'], ['E1013: Argument 2: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['complete("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['complete(1, {})'], ['E1013: Argument 2: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 2'])
enddef
def Test_complete_add()
- v9.CheckDefAndScriptFailure(['complete_add([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1223: String or Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['complete_add([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1223: String or Dictionary required for argument 1'])
enddef
def Test_complete_info()
- v9.CheckDefAndScriptFailure(['complete_info("")'], ['E1013: Argument 1: type mismatch, expected list<string> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['complete_info({})'], ['E1013: Argument 1: type mismatch, expected list<string> but got dict<any>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['complete_info("")'], ['E1013: Argument 1: type mismatch, expected list<string> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['complete_info({})'], ['E1013: Argument 1: type mismatch, expected list<string> but got dict<any>', 'E1211: List required for argument 1'])
assert_equal({'pum_visible': 0, 'mode': '', 'selected': -1, 'items': []}, complete_info())
assert_equal({'mode': '', 'items': []}, complete_info(['mode', 'items']))
enddef
@@ -767,10 +767,10 @@ def Test_confirm()
assert_fails('confirm(true)', 'E1174:')
assert_fails('confirm("yes", true)', 'E1174:')
assert_fails('confirm("yes", "maybe", 2, true)', 'E1174:')
- v9.CheckDefAndScriptFailure(['confirm(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['confirm("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['confirm("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['confirm("a", "b", 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['confirm(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['confirm("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['confirm("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['confirm("a", "b", 3, 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
enddef
def Test_copy_return_type()
@@ -798,7 +798,7 @@ def Test_copy_return_type()
var nll: list<list<number>> = [[1, 2]]
nll->copy()[0]->extend(['x'])
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<number> but got list<string> in extend()')
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<number> but got list<string> in extend()')
var nd: dict<number> = {a: 1, b: 2}
assert_equal({a: 1, b: 2, c: 'x'}, nd->copy()->extend({c: 'x'}))
@@ -806,7 +806,7 @@ def Test_copy_return_type()
var ndd: dict<dict<number>> = {a: {x: 1, y: 2}}
ndd->copy()['a']->extend({z: 'x'})
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<number> but got dict<string> in extend()')
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<number> but got dict<string> in extend()')
# after a deepcopy() the item type can also change
var nll: list<list<number>> = [[1, 2]]
@@ -822,9 +822,9 @@ enddef
def Test_count()
count('ABC ABC ABC', 'b', true)->assert_equal(3)
count('ABC ABC ABC', 'b', false)->assert_equal(0)
- v9.CheckDefAndScriptFailure(['count(10, 1)'], 'E1225: String, List or Dictionary required for argument 1')
- v9.CheckDefAndScriptFailure(['count("a", [1], 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
- v9.CheckDefAndScriptFailure(['count("a", [1], 0, "b")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['count(10, 1)'], 'E1225: String, List or Dictionary required for argument 1')
+ v9.CheckSourceDefAndScriptFailure(['count("a", [1], 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['count("a", [1], 0, "b")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
count([1, 2, 2, 3], 2)->assert_equal(2)
count([1, 2, 2, 3], 2, false, 2)->assert_equal(1)
count({a: 1.1, b: 2.2, c: 1.1}, 1.1)->assert_equal(2)
@@ -833,9 +833,9 @@ enddef
def Test_cscope_connection()
CheckFeature cscope
assert_equal(0, cscope_connection())
- v9.CheckDefAndScriptFailure(['cscope_connection("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['cscope_connection(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['cscope_connection(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['cscope_connection("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['cscope_connection(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['cscope_connection(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
enddef
def Test_cursor()
@@ -851,35 +851,35 @@ def Test_cursor()
var lines =<< trim END
cursor('2', 1)
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1209:')
- v9.CheckDefAndScriptFailure(['cursor(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['cursor(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['cursor(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['cursor("", 2)'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1209:')
+ v9.CheckSourceDefAndScriptFailure(['cursor(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['cursor(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['cursor(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['cursor("", 2)'], 'E1209: Invalid value for a line number')
enddef
def Test_debugbreak()
CheckMSWindows
- v9.CheckDefAndScriptFailure(['debugbreak("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['debugbreak("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_deepcopy()
- v9.CheckDefAndScriptFailure(['deepcopy({}, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['deepcopy({}, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
enddef
def Test_delete()
var res: bool = delete('doesnotexist')
assert_equal(true, res)
- v9.CheckDefAndScriptFailure(['delete(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['delete("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['delete("")'], 'E474: Invalid argument')
+ v9.CheckSourceDefAndScriptFailure(['delete(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['delete("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['delete("")'], 'E474: Invalid argument')
enddef
def Test_deletebufline()
- v9.CheckDefAndScriptFailure(['deletebufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['deletebufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['deletebufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['deletebufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['deletebufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['deletebufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3'])
new
setline(1, ['one', 'two'])
deletebufline('', 1)
@@ -892,58 +892,58 @@ def Test_deletebufline()
enddef
def Test_diff_filler()
- v9.CheckDefAndScriptFailure(['diff_filler([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['diff_filler(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['diff_filler("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['diff_filler([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['diff_filler(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['diff_filler("")'], 'E1209: Invalid value for a line number')
assert_equal(0, diff_filler(1))
assert_equal(0, diff_filler('.'))
enddef
def Test_diff_hlID()
- v9.CheckDefAndScriptFailure(['diff_hlID(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['diff_hlID(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['diff_hlID("", 10)'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['diff_hlID(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['diff_hlID(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['diff_hlID("", 10)'], 'E1209: Invalid value for a line number')
enddef
def Test_digraph_get()
- v9.CheckDefAndScriptFailure(['digraph_get(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['digraph_get("")'], 'E1214: Digraph must be just two characters')
+ v9.CheckSourceDefAndScriptFailure(['digraph_get(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['digraph_get("")'], 'E1214: Digraph must be just two characters')
enddef
def Test_digraph_getlist()
- v9.CheckDefAndScriptFailure(['digraph_getlist(10)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['digraph_getlist("")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['digraph_getlist(10)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['digraph_getlist("")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
enddef
def Test_digraph_set()
- v9.CheckDefAndScriptFailure(['digraph_set(10, "a")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['digraph_set("ab", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['digraph_set("", "a")'], 'E1214: Digraph must be just two characters')
+ v9.CheckSourceDefAndScriptFailure(['digraph_set(10, "a")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['digraph_set("ab", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['digraph_set("", "a")'], 'E1214: Digraph must be just two characters')
enddef
def Test_digraph_setlist()
- v9.CheckDefAndScriptFailure(['digraph_setlist("a")'], ['E1013: Argument 1: type mismatch, expected list<string> but got string', 'E1216: digraph_setlist() argument must be a list of lists with two items'])
- v9.CheckDefAndScriptFailure(['digraph_setlist({})'], ['E1013: Argument 1: type mismatch, expected list<string> but got dict<any>', 'E1216: digraph_setlist() argument must be a list of lists with two items'])
+ v9.CheckSourceDefAndScriptFailure(['digraph_setlist("a")'], ['E1013: Argument 1: type mismatch, expected list<string> but got string', 'E1216: digraph_setlist() argument must be a list of lists with two items'])
+ v9.CheckSourceDefAndScriptFailure(['digraph_setlist({})'], ['E1013: Argument 1: type mismatch, expected list<string> but got dict<any>', 'E1216: digraph_setlist() argument must be a list of lists with two items'])
enddef
def Test_echoraw()
- v9.CheckDefAndScriptFailure(['echoraw(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['echoraw(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['echoraw(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['echoraw(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
enddef
def Test_escape()
- v9.CheckDefAndScriptFailure(['escape(10, " ")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['escape(true, false)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['escape("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['escape(10, " ")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['escape(true, false)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['escape("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
assert_equal('a\:b', escape("a:b", ":"))
escape('abc', '')->assert_equal('abc')
escape('', ':')->assert_equal('')
enddef
def Test_eval()
- v9.CheckDefAndScriptFailure(['eval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['eval(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['eval("")'], 'E15: Invalid expression')
+ v9.CheckSourceDefAndScriptFailure(['eval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['eval(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['eval("")'], 'E15: Invalid expression')
assert_equal(2, eval('1 + 1'))
enddef
@@ -951,8 +951,8 @@ def Test_executable()
assert_false(executable(""))
assert_false(executable(test_null_string()))
- v9.CheckDefExecFailure(['echo executable(123)'], 'E1013:')
- v9.CheckDefExecFailure(['echo executable(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo executable(123)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo executable(true)'], 'E1013:')
enddef
def Test_execute()
@@ -961,22 +961,22 @@ def Test_execute()
res = execute(["echo 'here'", "echo 'there'"])
assert_equal("\nhere\nthere", res)
- v9.CheckDefAndScriptFailure(['execute(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1'])
- v9.CheckDefFailure(['execute([123])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>')
- v9.CheckDefExecFailure(['echo execute(["xx", 123])'], 'E492')
- v9.CheckDefAndScriptFailure(['execute("xx", 123)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['execute(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefFailure(['execute([123])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>')
+ v9.CheckSourceDefExecFailure(['echo execute(["xx", 123])'], 'E492')
+ v9.CheckSourceDefAndScriptFailure(['execute("xx", 123)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
enddef
def Test_exepath()
- v9.CheckDefExecFailure(['echo exepath(true)'], 'E1013:')
- v9.CheckDefExecFailure(['echo exepath(v:null)'], 'E1013:')
- v9.CheckDefExecFailure(['echo exepath("")'], 'E1175:')
+ v9.CheckSourceDefExecFailure(['echo exepath(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo exepath(v:null)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo exepath("")'], 'E1175:')
enddef
command DoSomeCommand let g:didSomeCommand = 4
def Test_exists()
- v9.CheckDefAndScriptFailure(['exists(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['exists(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
call assert_equal(1, exists('&tabstop'))
var lines =<< trim END
@@ -985,14 +985,14 @@ def Test_exists()
endif
endif
END
- v9.CheckDefFailure(lines, 'E113:')
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceDefFailure(lines, 'E113:')
+ v9.CheckSourceScriptSuccess(lines)
enddef
def Test_exists_compiled()
call assert_equal(1, exists_compiled('&tabstop'))
- v9.CheckDefAndScriptFailure(['exists_compiled(10)'], ['E1232:', 'E1233:'])
- v9.CheckDefAndScriptFailure(['exists_compiled(v:progname)'], ['E1232:', 'E1233:'])
+ v9.CheckSourceDefAndScriptFailure(['exists_compiled(10)'], ['E1232:', 'E1233:'])
+ v9.CheckSourceDefAndScriptFailure(['exists_compiled(v:progname)'], ['E1232:', 'E1233:'])
if exists_compiled('+newoption')
if &newoption == 'ok'
@@ -1044,9 +1044,9 @@ def Test_expand()
split SomeFile
expand('%', true, true)->assert_equal(['SomeFile'])
close
- v9.CheckDefAndScriptFailure(['expand(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['expand("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
- v9.CheckDefAndScriptFailure(['expand("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['expand(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['expand("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['expand("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
expand('')->assert_equal('')
var caught = false
@@ -1065,8 +1065,8 @@ def Test_expandcmd()
assert_equal("yes", expandcmd("`={a: 'yes'}['a']`"))
expandcmd('')->assert_equal('')
- v9.CheckDefAndScriptFailure(['expandcmd([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['expandcmd("abc", [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['expandcmd([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['expandcmd("abc", [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_extend_arg_types()
@@ -1093,7 +1093,7 @@ def Test_extend_arg_types()
dany->extend({b: 'x'})
assert_equal({a: 0, b: 'x'}, dany)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
assert_equal([1, 2, "x"], extend([1, 2], ["x"]))
@@ -1101,17 +1101,17 @@ def Test_extend_arg_types()
assert_equal({a: 1, b: "x"}, extend({a: 1}, {b: "x"}))
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
- v9.CheckDefAndScriptFailure(['extend("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E712: Argument of extend() must be a List or Dictionary'])
- v9.CheckDefAndScriptFailure(['extend([1, 2], 3)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E712: Argument of extend() must be a List or Dictionary'])
- v9.CheckDefAndScriptFailure(['var ll = [1, 2]', 'extend(ll, ["x"])'], ['E1013: Argument 2: type mismatch, expected list<number> but got list<string>', 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>'])
- v9.CheckDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string')
+ v9.CheckSourceDefAndScriptFailure(['extend("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E712: Argument of extend() must be a List or Dictionary'])
+ v9.CheckSourceDefAndScriptFailure(['extend([1, 2], 3)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E712: Argument of extend() must be a List or Dictionary'])
+ v9.CheckSourceDefAndScriptFailure(['var ll = [1, 2]', 'extend(ll, ["x"])'], ['E1013: Argument 2: type mismatch, expected list<number> but got list<string>', 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>'])
+ v9.CheckSourceDefFailure(['extend([1, 2], [3], "x")'], 'E1013: Argument 3: type mismatch, expected number but got string')
- v9.CheckDefFailure(['extend({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict<any> but got number')
- v9.CheckDefFailure(['extend({a: 1}, {b: 2}, 1)'], 'E1013: Argument 3: type mismatch, expected string but got number')
+ v9.CheckSourceDefFailure(['extend({a: 1}, 42)'], 'E1013: Argument 2: type mismatch, expected dict<any> but got number')
+ v9.CheckSourceDefFailure(['extend({a: 1}, {b: 2}, 1)'], 'E1013: Argument 3: type mismatch, expected string but got number')
- v9.CheckScriptFailure(['vim9script', 'var l = [1]', 'extend(l, ["b", 1])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<any> in extend()')
+ v9.CheckSourceScriptFailure(['vim9script', 'var l = [1]', 'extend(l, ["b", 1])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<any> in extend()')
enddef
func g:ExtendDict(d)
@@ -1123,26 +1123,26 @@ def Test_extend_dict_item_type()
var d: dict<number> = {a: 1}
extend(d, {b: 2})
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
var d: dict<number> = {a: 1}
extend(d, {b: 'x'})
END
- v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<number> but got dict<string>', 2)
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<number> but got dict<string>', 2)
lines =<< trim END
var d: dict<number> = {a: 1}
g:ExtendDict(d)
END
- v9.CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0)
- v9.CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
+ v9.CheckSourceDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0)
+ v9.CheckSourceScriptFailure(['vim9script'] + lines, 'E1012:', 1)
lines =<< trim END
var d: dict<bool>
extend(d, {b: 0})
END
- v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<bool> but got dict<number>', 2)
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected dict<bool> but got dict<number>', 2)
enddef
func g:ExtendList(l)
@@ -1154,26 +1154,26 @@ def Test_extend_list_item_type()
var l: list<number> = [1]
extend(l, [2])
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
var l: list<number> = [1]
extend(l, ['x'])
END
- v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>', 2)
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>', 2)
lines =<< trim END
var l: list<number> = [1]
g:ExtendList(l)
END
- v9.CheckDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0)
- v9.CheckScriptFailure(['vim9script'] + lines, 'E1012:', 1)
+ v9.CheckSourceDefExecFailure(lines, 'E1012: Type mismatch; expected number but got string', 0)
+ v9.CheckSourceScriptFailure(['vim9script'] + lines, 'E1012:', 1)
lines =<< trim END
var l: list<bool>
extend(l, [0])
END
- v9.CheckDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<bool> but got list<number>', 2)
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1013: Argument 2: type mismatch, expected list<bool> but got list<number>', 2)
enddef
def Test_extend_return_type()
@@ -1203,7 +1203,7 @@ def Test_extend_with_error_function()
Test()
END
- v9.CheckScriptFailure(lines, 'E1001: Variable not found: m')
+ v9.CheckSourceScriptFailure(lines, 'E1001: Variable not found: m')
enddef
def Test_extend_const()
@@ -1211,20 +1211,20 @@ def Test_extend_const()
const l = [1, 2]
extend(l, [3])
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
lines =<< trim END
const d = {a: 1, b: 2}
extend(d, {c: 3})
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
lines =<< trim END
final d = {a: 1, b: 2}
extend(d, {c: 3})
assert_equal({a: 1, b: 2, c: 3}, d)
END
- v9.CheckDefSuccess(lines)
+ v9.CheckSourceDefSuccess(lines)
# item in a for loop is final
lines =<< trim END
@@ -1233,23 +1233,23 @@ def Test_extend_const()
item->extend({x: 2})
endfor
END
- v9.CheckDefSuccess(lines)
+ v9.CheckSourceDefSuccess(lines)
enddef
def Test_extendnew()
assert_equal([1, 2, 'a'], extendnew([1, 2], ['a']))
assert_equal({one: 1, two: 'a'}, extendnew({one: 1}, {two: 'a'}))
- v9.CheckDefAndScriptFailure(['extendnew({a: 1}, 42)'], ['E1013: Argument 2: type mismatch, expected dict<number> but got number', 'E712: Argument of extendnew() must be a List or Dictionary'])
- v9.CheckDefAndScriptFailure(['extendnew({a: 1}, [42])'], ['E1013: Argument 2: type mismatch, expected dict<number> but got list<number>', 'E712: Argument of extendnew() must be a List or Dictionary'])
- v9.CheckDefAndScriptFailure(['extendnew([1, 2], "x")'], ['E1013: Argument 2: type mismatch, expected list<number> but got string', 'E712: Argument of extendnew() must be a List or Dictionary'])
- v9.CheckDefAndScriptFailure(['extendnew([1, 2], {x: 1})'], ['E1013: Argument 2: type mismatch, expected list<number> but got dict<number>', 'E712: Argument of extendnew() must be a List or Dictionary'])
+ v9.CheckSourceDefAndScriptFailure(['extendnew({a: 1}, 42)'], ['E1013: Argument 2: type mismatch, expected dict<number> but got number', 'E712: Argument of extendnew() must be a List or Dictionary'])
+ v9.CheckSourceDefAndScriptFailure(['extendnew({a: 1}, [42])'], ['E1013: Argument 2: type mismatch, expected dict<number> but got list<number>', 'E712: Argument of extendnew() must be a List or Dictionary'])
+ v9.CheckSourceDefAndScriptFailure(['extendnew([1, 2], "x")'], ['E1013: Argument 2: type mismatch, expected list<number> but got string', 'E712: Argument of extendnew() must be a List or Dictionary'])
+ v9.CheckSourceDefAndScriptFailure(['extendnew([1, 2], {x: 1})'], ['E1013: Argument 2: type mismatch, expected list<number> but got dict<number>', 'E712: Argument of extendnew() must be a List or Dictionary'])
enddef
def Test_feedkeys()
- v9.CheckDefAndScriptFailure(['feedkeys(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['feedkeys("x", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['feedkeys([], {})'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['feedkeys(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['feedkeys("x", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['feedkeys([], {})'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
g:TestVar = 1
feedkeys(":g:TestVar = 789\n", 'xt')
assert_equal(789, g:TestVar)
@@ -1260,16 +1260,16 @@ def Test_filereadable()
assert_false(filereadable(""))
assert_false(filereadable(test_null_string()))
- v9.CheckDefExecFailure(['echo filereadable(123)'], 'E1013:')
- v9.CheckDefExecFailure(['echo filereadable(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo filereadable(123)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo filereadable(true)'], 'E1013:')
enddef
def Test_filewritable()
assert_false(filewritable(""))
assert_false(filewritable(test_null_string()))
- v9.CheckDefExecFailure(['echo filewritable(123)'], 'E1013:')
- v9.CheckDefExecFailure(['echo filewritable(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo filewritable(123)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo filewritable(true)'], 'E1013:')
enddef
def Test_finddir()
@@ -1278,20 +1278,20 @@ def Test_finddir()
var lines =<< trim END
var l: list<string> = finddir('nothing', '*;', -1)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
delete('Xtestdir', 'rf')
- v9.CheckDefAndScriptFailure(['finddir(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['finddir(v:null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1'])
- v9.CheckDefExecFailure(['echo finddir("")'], 'E1175:')
- v9.CheckDefAndScriptFailure(['finddir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['finddir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['finddir(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['finddir(v:null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefExecFailure(['echo finddir("")'], 'E1175:')
+ v9.CheckSourceDefAndScriptFailure(['finddir("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['finddir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
finddir('abc', '')->assert_equal('')
- v9.CheckDefFailure(['var s: list<string> = finddir("foo")'], 'E1012: Type mismatch; expected list<string> but got string')
- v9.CheckDefFailure(['var s: list<string> = finddir("foo", "path")'], 'E1012: Type mismatch; expected list<string> but got string')
+ v9.CheckSourceDefFailure(['var s: list<string> = finddir("foo")'], 'E1012: Type mismatch; expected list<string> but got string')
+ v9.CheckSourceDefFailure(['var s: list<string> = finddir("foo", "path")'], 'E1012: Type mismatch; expected list<string> but got string')
# with third argument only runtime type checking
- v9.CheckDefCompileSuccess(['var s: list<string> = finddir("foo", "path", 1)'])
+ v9.CheckSourceDefCompileSuccess(['var s: list<string> = finddir("foo", "path", 1)'])
enddef
def Test_findfile()
@@ -1299,13 +1299,13 @@ def Test_findfile()
var lines =<< trim END
var l: list<string> = findfile('nothing', '*;', -1)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
- v9.CheckDefExecFailure(['findfile(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool')
- v9.CheckDefExecFailure(['findfile(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special')
- v9.CheckDefExecFailure(['findfile("")'], 'E1175:')
- v9.CheckDefAndScriptFailure(['findfile("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['findfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefExecFailure(['findfile(true)'], 'E1013: Argument 1: type mismatch, expected string but got bool')
+ v9.CheckSourceDefExecFailure(['findfile(v:null)'], 'E1013: Argument 1: type mismatch, expected string but got special')
+ v9.CheckSourceDefExecFailure(['findfile("")'], 'E1175:')
+ v9.CheckSourceDefAndScriptFailure(['findfile("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['findfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
findfile('abc', '')->assert_equal('')
enddef
@@ -1313,7 +1313,7 @@ def Test_flatten()
var lines =<< trim END
echo flatten([1, 2, 3])
END
- v9.CheckDefAndScriptFailure(lines, 'E1158:')
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1158:')
enddef
def Test_flattennew()
@@ -1328,106 +1328,106 @@ def Test_flattennew()
var ll: list<list<string>> = [['a', 'b', 'c']]
assert_equal(['a', 'b', 'c'], ll->flattennew())
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
- v9.CheckDefAndScriptFailure(['flattennew({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['flattennew([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['flattennew({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['flattennew([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
" Test for float functions argument type
def Test_float_funcs_args()
# acos()
- v9.CheckDefAndScriptFailure(['acos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['acos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('1.570796', string(acos(0.0)))
# asin()
- v9.CheckDefAndScriptFailure(['asin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['asin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(asin(0.0)))
# atan()
- v9.CheckDefAndScriptFailure(['atan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['atan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(atan(0.0)))
# atan2()
- v9.CheckDefAndScriptFailure(['atan2("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['atan2("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('-2.356194', string(atan2(-1, -1)))
- v9.CheckDefAndScriptFailure(['atan2(1.2, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['atan2(1.2)'], ['E119:', 'E119:'])
+ v9.CheckSourceDefAndScriptFailure(['atan2(1.2, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['atan2(1.2)'], ['E119:', 'E119:'])
# ceil()
- v9.CheckDefAndScriptFailure(['ceil("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['ceil("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('2.0', string(ceil(2.0)))
# cos()
- v9.CheckDefAndScriptFailure(['cos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['cos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('1.0', string(cos(0.0)))
# cosh()
- v9.CheckDefAndScriptFailure(['cosh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['cosh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('1.0', string(cosh(0.0)))
# exp()
- v9.CheckDefAndScriptFailure(['exp("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['exp("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('1.0', string(exp(0.0)))
# float2nr()
- v9.CheckDefAndScriptFailure(['float2nr("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['float2nr("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal(1, float2nr(1.234))
# floor()
- v9.CheckDefAndScriptFailure(['floor("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['floor("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('2.0', string(floor(2.0)))
# fmod()
- v9.CheckDefAndScriptFailure(['fmod(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['fmod("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['fmod(1.1)'], ['E119:', 'E119:'])
+ v9.CheckSourceDefAndScriptFailure(['fmod(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['fmod("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['fmod(1.1)'], ['E119:', 'E119:'])
assert_equal('0.13', string(fmod(12.33, 1.22)))
# isinf()
- v9.CheckDefAndScriptFailure(['isinf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['isinf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal(1, isinf(1.0 / 0.0))
# isnan()
- v9.CheckDefAndScriptFailure(['isnan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['isnan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_true(isnan(0.0 / 0.0))
# log()
- v9.CheckDefAndScriptFailure(['log("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['log("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(log(1.0)))
# log10()
- v9.CheckDefAndScriptFailure(['log10("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['log10("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(log10(1.0)))
# pow()
- v9.CheckDefAndScriptFailure(['pow("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['pow(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['pow(1.1)'], ['E119:', 'E119:'])
+ v9.CheckSourceDefAndScriptFailure(['pow("a", 1.1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['pow(1.1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['pow(1.1)'], ['E119:', 'E119:'])
assert_equal('1.0', string(pow(0.0, 0.0)))
# round()
- v9.CheckDefAndScriptFailure(['round("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['round("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('2.0', string(round(2.1)))
# sin()
- v9.CheckDefAndScriptFailure(['sin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sin("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(sin(0.0)))
# sinh()
- v9.CheckDefAndScriptFailure(['sinh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sinh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(sinh(0.0)))
# sqrt()
- v9.CheckDefAndScriptFailure(['sqrt("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sqrt("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(sqrt(0.0)))
# tan()
- v9.CheckDefAndScriptFailure(['tan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['tan("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(tan(0.0)))
# tanh()
- v9.CheckDefAndScriptFailure(['tanh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['tanh("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('0.0', string(tanh(0.0)))
# trunc()
- v9.CheckDefAndScriptFailure(['trunc("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['trunc("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1219: Float or Number required for argument 1'])
assert_equal('2.0', string(trunc(2.1)))
enddef
def Test_fnameescape()
- v9.CheckDefAndScriptFailure(['fnameescape(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['fnameescape(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal('\+a\%b\|', fnameescape('+a%b|'))
fnameescape('')->assert_equal('')
enddef
def Test_fnamemodify()
- v9.CheckDefSuccess(['echo fnamemodify(test_null_string(), ":p")'])
- v9.CheckDefSuccess(['echo fnamemodify("", ":p")'])
- v9.CheckDefSuccess(['echo fnamemodify("file", test_null_string())'])
- v9.CheckDefSuccess(['echo fnamemodify("file", "")'])
+ v9.CheckSourceDefSuccess(['echo fnamemodify(test_null_string(), ":p")'])
+ v9.CheckSourceDefSuccess(['echo fnamemodify("", ":p")'])
+ v9.CheckSourceDefSuccess(['echo fnamemodify("file", test_null_string())'])
+ v9.CheckSourceDefSuccess(['echo fnamemodify("file", "")'])
- v9.CheckDefExecFailure(['echo fnamemodify(true, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got bool')
- v9.CheckDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got special')
- v9.CheckDefExecFailure(['echo fnamemodify("file", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool')
+ v9.CheckSourceDefExecFailure(['echo fnamemodify(true, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got bool')
+ v9.CheckSourceDefExecFailure(['echo fnamemodify(v:null, ":p")'], 'E1013: Argument 1: type mismatch, expected string but got special')
+ v9.CheckSourceDefExecFailure(['echo fnamemodify("file", true)'], 'E1013: Argument 2: type mismatch, expected string but got bool')
enddef
def Wrong_dict_key_type(items: list<number>): list<number>
@@ -1454,10 +1454,10 @@ def Test_filter()
enddef
assert_equal(['xxx'], Func())
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
- v9.CheckDefAndScriptFailure(['filter(1.1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got float', 'E1251: List, Dictionary, Blob or String required for argument 1'])
- v9.CheckDefAndScriptFailure(['filter([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String'])
+ v9.CheckSourceDefAndScriptFailure(['filter(1.1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got float', 'E1251: List, Dictionary, Blob or String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['filter([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String'])
lines =<< trim END
def F(i: number, v: any): string
@@ -1465,51 +1465,51 @@ def Test_filter()
enddef
echo filter([1, 2, 3], F)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool but got func(number, any): string', 'E1135: Using a String as a Bool:'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool but got func(number, any): string', 'E1135: Using a String as a Bool:'])
# check first function argument type
lines =<< trim END
var l = [1, 2, 3]
filter(l, (i: string, v: number) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(string, number): bool', 'E1013: Argument 1: type mismatch, expected string but got number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(string, number): bool', 'E1013: Argument 1: type mismatch, expected string but got number'])
lines =<< trim END
var d = {a: 1}
filter(d, (i: number, v: number) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?number): bool but got func(number, number): bool', 'E1013: Argument 1: type mismatch, expected number but got string'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?number): bool but got func(number, number): bool', 'E1013: Argument 1: type mismatch, expected number but got string'])
lines =<< trim END
var b = 0z1122
filter(b, (i: string, v: number) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(string, number): bool', 'E1013: Argument 1: type mismatch, expected string but got number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(string, number): bool', 'E1013: Argument 1: type mismatch, expected string but got number'])
lines =<< trim END
var s = 'text'
filter(s, (i: string, v: string) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?string): bool but got func(string, string): bool', 'E1013: Argument 1: type mismatch, expected string but got number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?string): bool but got func(string, string): bool', 'E1013: Argument 1: type mismatch, expected string but got number'])
# check second function argument type
lines =<< trim END
var l = [1, 2, 3]
filter(l, (i: number, v: string) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(number, string): bool', 'E1013: Argument 2: type mismatch, expected string but got number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(number, string): bool', 'E1013: Argument 2: type mismatch, expected string but got number'])
lines =<< trim END
var d = {a: 1}
filter(d, (i: string, v: string) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?number): bool but got func(string, string): bool', 'E1013: Argument 2: type mismatch, expected string but got number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?number): bool but got func(string, string): bool', 'E1013: Argument 2: type mismatch, expected string but got number'])
lines =<< trim END
var b = 0z1122
filter(b, (i: number, v: string) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(number, string): bool', 'E1013: Argument 2: type mismatch, expected string but got number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): bool but got func(number, string): bool', 'E1013: Argument 2: type mismatch, expected string but got number'])
lines =<< trim END
var s = 'text'
filter(s, (i: number, v: number) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?string): bool but got func(number, number): bool', 'E1013: Argument 2: type mismatch, expected number but got string'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?string): bool but got func(number, number): bool', 'E1013: Argument 2: type mismatch, expected number but got string'])
enddef
def Test_filter_wrong_dict_key_type()
@@ -1536,39 +1536,39 @@ def Test_filter_const()
const l = [1, 2, 3]
filter(l, 'v:val == 2')
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
lines =<< trim END
const d = {a: 1, b: 2}
filter(d, 'v:val == 2')
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
enddef
def Test_foldclosed()
- v9.CheckDefAndScriptFailure(['foldclosed(function("min"))'], ['E1013: Argument 1: type mismatch, expected string but got func(...): unknown', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['foldclosed("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['foldclosed(function("min"))'], ['E1013: Argument 1: type mismatch, expected string but got func(...): unknown', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['foldclosed("")'], 'E1209: Invalid value for a line number')
assert_equal(-1, foldclosed(1))
assert_equal(-1, foldclosed('$'))
enddef
def Test_foldclosedend()
- v9.CheckDefAndScriptFailure(['foldclosedend(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['foldclosedend("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['foldclosedend(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['foldclosedend("")'], 'E1209: Invalid value for a line number')
assert_equal(-1, foldclosedend(1))
assert_equal(-1, foldclosedend('w0'))
enddef
def Test_foldlevel()
- v9.CheckDefAndScriptFailure(['foldlevel(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['foldlevel("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['foldlevel(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['foldlevel("")'], 'E1209: Invalid value for a line number')
assert_equal(0, foldlevel(1))
assert_equal(0, foldlevel('.'))
enddef
def Test_foldtextresult()
- v9.CheckDefAndScriptFailure(['foldtextresult(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['foldtextresult("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['foldtextresult(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['foldtextresult("")'], 'E1209: Invalid value for a line number')
assert_equal('', foldtextresult(1))
assert_equal('', foldtextresult('.'))
enddef
@@ -1605,8 +1605,8 @@ def Test_fullcommand()
enddef
def Test_funcref()
- v9.CheckDefAndScriptFailure(['funcref("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
- v9.CheckDefAndScriptFailure(['funcref("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['funcref("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['funcref("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
var lines =<< trim END
vim9script
@@ -1623,7 +1623,7 @@ def Test_funcref()
defcompile
GetRefOk()
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
lines =<< trim END
vim9script
@@ -1635,14 +1635,14 @@ def Test_funcref()
enddef
GetRefBad()
END
- v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)')
+ v9.CheckSourceScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)')
enddef
def Test_function()
- v9.CheckDefExecAndScriptFailure(['function(123)'], 'E1256: String or function required for argument 1')
+ v9.CheckSourceDefExecAndScriptFailure(['function(123)'], 'E1256: String or function required for argument 1')
- v9.CheckDefAndScriptFailure(['function("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
- v9.CheckDefAndScriptFailure(['function("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['function("reverse", 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['function("reverse", [2], [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
var lines =<< trim END
vim9script
@@ -1659,7 +1659,7 @@ def Test_function()
defcompile
GetRefOk()
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
lines =<< trim END
vim9script
@@ -1671,17 +1671,17 @@ def Test_function()
enddef
GetRefBad()
END
- v9.CheckScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)')
+ v9.CheckSourceScriptFailure(lines, 'E1012: Type mismatch; expected func(number) but got func(bool)')
enddef
def Test_garbagecollect()
garbagecollect(true)
- v9.CheckDefAndScriptFailure(['garbagecollect("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['garbagecollect(20)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['garbagecollect("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['garbagecollect(20)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
enddef
def Test_get()
- v9.CheckDefAndScriptFailure(['get("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E896: Argument of get() must be a List, Dictionary or Blob'])
+ v9.CheckSourceDefAndScriptFailure(['get("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E896: Argument of get() must be a List, Dictionary or Blob'])
[3, 5, 2]->get(1)->assert_equal(5)
[3, 5, 2]->get(3)->assert_equal(0)
[3, 5, 2]->get(3, 9)->assert_equal(9)
@@ -1701,7 +1701,7 @@ def Test_get()
enddef
assert_equal(0, DoThat())
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
enddef
def Test_getbufinfo()
@@ -1714,7 +1714,7 @@ def Test_getbufinfo()
getbufinfo({bufloaded: true, buflisted: true, bufmodified: false})
->len()->assert_equal(3)
bwipe Xtestfile1 Xtestfile2
- v9.CheckDefAndScriptFailure(['getbufinfo(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getbufinfo(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
enddef
def Test_getbufline()
@@ -1738,17 +1738,17 @@ def Test_getbufline()
assert_fails('getbufoneline("", "$a")', ['E1030: Using a String as a Number: "$a"', 'E1030: Using a String as a Number: "$a"'])
bwipe!
- v9.CheckDefAndScriptFailure(['getbufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getbufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['getbufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['getbufline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getbufline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getbufline("a", 2, 0z10)'], ['E1013: Argument 3: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['getbufoneline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getbufoneline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getbufoneline([], 2)'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getbufoneline("a", [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 2'])
enddef
def Test_getbufvar()
- v9.CheckDefAndScriptFailure(['getbufvar(true, "v")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getbufvar(true, "v")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
enddef
def Test_getchangelist()
@@ -1764,21 +1764,21 @@ def Test_getchar()
endwhile
getchar(true)->assert_equal(0)
getchar(1)->assert_equal(0)
- v9.CheckDefAndScriptFailure(['getchar(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['getchar("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getchar(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getchar("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
enddef
def Test_getcharpos()
assert_equal(['x', 'x', 'x', 'x'], getcharpos('.')->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['getcharpos(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['getcharpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['getcharpos("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['getcharpos(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcharpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['getcharpos("")'], 'E1209: Invalid value for a line number')
enddef
def Test_getcharstr()
- v9.CheckDefAndScriptFailure(['getcharstr(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['getcharstr("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcharstr(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcharstr("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
enddef
def Test_getcompletion()
@@ -1786,29 +1786,29 @@ def Test_getcompletion()
var l = getcompletion('run', 'file', true)
l->assert_equal([])
set wildignore&
- v9.CheckDefAndScriptFailure(['getcompletion(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['getcompletion("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['getcompletion("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['getcompletion("a", "")'], 'E475: Invalid argument')
+ v9.CheckSourceDefAndScriptFailure(['getcompletion(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcompletion("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getcompletion("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['getcompletion("a", "")'], 'E475: Invalid argument')
getcompletion('', 'messages')->assert_equal(['clear'])
enddef
def Test_getcurpos()
assert_equal(['x', 'x', 'x', 'x', 'x'], getcurpos()->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['getcurpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcurpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_getcursorcharpos()
assert_equal(['x', 'x', 'x', 'x', 'x'], getcursorcharpos()->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['getcursorcharpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcursorcharpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_getcwd()
- v9.CheckDefAndScriptFailure(['getcwd("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getcwd("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getcwd(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getcwd("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcwd("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getcwd(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_getenv()
@@ -1827,7 +1827,7 @@ def Test_getenv()
enddef
def Test_getfontname()
- v9.CheckDefAndScriptFailure(['getfontname(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getfontname(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
#getfontname('')->assert_equal('')
enddef
@@ -1835,38 +1835,38 @@ def Test_getfperm()
assert_equal('', getfperm(""))
assert_equal('', getfperm(test_null_string()))
- v9.CheckDefExecFailure(['echo getfperm(true)'], 'E1013:')
- v9.CheckDefExecFailure(['echo getfperm(v:null)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getfperm(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getfperm(v:null)'], 'E1013:')
enddef
def Test_getfsize()
assert_equal(-1, getfsize(""))
assert_equal(-1, getfsize(test_null_string()))
- v9.CheckDefExecFailure(['echo getfsize(true)'], 'E1013:')
- v9.CheckDefExecFailure(['echo getfsize(v:null)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getfsize(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getfsize(v:null)'], 'E1013:')
enddef
def Test_getftime()
assert_equal(-1, getftime(""))
assert_equal(-1, getftime(test_null_string()))
- v9.CheckDefExecFailure(['echo getftime(true)'], 'E1013:')
- v9.CheckDefExecFailure(['echo getftime(v:null)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getftime(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getftime(v:null)'], 'E1013:')
enddef
def Test_getftype()
assert_equal('', getftype(""))
assert_equal('', getftype(test_null_string()))
- v9.CheckDefExecFailure(['echo getftype(true)'], 'E1013:')
- v9.CheckDefExecFailure(['echo getftype(v:null)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getftype(true)'], 'E1013:')
+ v9.CheckSourceDefExecFailure(['echo getftype(v:null)'], 'E1013:')
enddef
def Test_getjumplist()
- v9.CheckDefAndScriptFailure(['getjumplist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getjumplist("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getjumplist(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getjumplist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getjumplist("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getjumplist(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_getline()
@@ -1882,20 +1882,20 @@ def Test_getline()
assert_equal([3, 3, 3], getline(1, 3)->map((_, _) => 3))
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
echo getline('1')
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1209:')
- v9.CheckDefAndScriptFailure(['getline(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getline(1, true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['getline("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1209:')
+ v9.CheckSourceDefAndScriptFailure(['getline(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getline(1, true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['getline("")'], 'E1209: Invalid value for a line number')
enddef
def Test_getloclist()
- v9.CheckDefAndScriptFailure(['getloclist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getloclist(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getloclist("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getloclist(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_getloclist_return_type()
@@ -1907,26 +1907,26 @@ def Test_getloclist_return_type()
enddef
def Test_getmarklist()
- v9.CheckDefAndScriptFailure(['getmarklist([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getmarklist([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
assert_equal([], getmarklist(10000))
assert_fails('getmarklist("a%b@#")', 'E94:')
enddef
def Test_getmatches()
- v9.CheckDefAndScriptFailure(['getmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getmatches("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_getpos()
assert_equal(['x', 'x', 'x', 'x'], getpos('.')->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['getpos(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getpos(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal([0, 1, 1, 0], getpos('.'))
- v9.CheckDefExecFailure(['getpos("a")'], 'E1209:')
- v9.CheckDefExecAndScriptFailure(['getpos("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecFailure(['getpos("a")'], 'E1209:')
+ v9.CheckSourceDefExecAndScriptFailure(['getpos("")'], 'E1209: Invalid value for a line number')
enddef
def Test_getqflist()
- v9.CheckDefAndScriptFailure(['getqflist([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getqflist([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
call assert_equal({}, getqflist({}))
enddef
@@ -1945,9 +1945,9 @@ def Test_getreg()
assert_equal([7, 7, 7], getreg('a', true, true)->map((_, _) => 7))
assert_fails('getreg("ab")', 'E1162:')
- v9.CheckDefAndScriptFailure(['getreg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['getreg(".", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
- v9.CheckDefAndScriptFailure(['getreg(".", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['getreg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getreg(".", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getreg(".", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
@" = 'A1B2C3'
getreg('')->assert_equal('A1B2C3')
enddef
@@ -1977,7 +1977,7 @@ def Test_getregtype()
enddef
def Test_getscriptinfo()
- v9.CheckDefAndScriptFailure(['getscriptinfo("x")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getscriptinfo("x")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 1'])
var lines1 =<< trim END
vim9script
@@ -2016,78 +2016,78 @@ def Test_getscriptinfo()
assert_true(index(l[0].functions, f) != -1)
endfor
END
- v9.CheckDefAndScriptSuccess(lines2)
+ v9.CheckSourceDefAndScriptSuccess(lines2)
enddef
def Test_gettabinfo()
- v9.CheckDefAndScriptFailure(['gettabinfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['gettabinfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_gettabvar()
- v9.CheckDefAndScriptFailure(['gettabvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['gettabvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['gettabvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['gettabvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
enddef
def Test_gettabwinvar()
- v9.CheckDefAndScriptFailure(['gettabwinvar("a", 2, "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['gettabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['gettabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['gettabwinvar("a", 2, "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['gettabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['gettabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
enddef
def Test_gettagstack()
- v9.CheckDefAndScriptFailure(['gettagstack("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['gettagstack("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_gettext()
- v9.CheckDefAndScriptFailure(['gettext(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['gettext("")'], 'E1175: Non-empty string required for argument 1')
+ v9.CheckSourceDefAndScriptFailure(['gettext(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['gettext("")'], 'E1175: Non-empty string required for argument 1')
assert_equal('abc', gettext("abc"))
assert_fails('gettext("")', 'E1175:')
enddef
def Test_getwininfo()
- v9.CheckDefAndScriptFailure(['getwininfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getwininfo("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_getwinpos()
assert_equal(['x', 'x'], getwinpos()->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['getwinpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getwinpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_getwinvar()
- v9.CheckDefAndScriptFailure(['getwinvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['getwinvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['getwinvar("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getwinvar(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
enddef
def Test_glob()
glob('runtest.vim', true, true, true)->assert_equal(['runtest.vim'])
- v9.CheckDefAndScriptFailure(['glob(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['glob("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
- v9.CheckDefAndScriptFailure(['glob("a", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
- v9.CheckDefAndScriptFailure(['glob("a", 1, true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['glob(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['glob("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['glob("a", 1, "b")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['glob("a", 1, true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
glob('')->assert_equal('')
enddef
def Test_glob2regpat()
- v9.CheckDefAndScriptFailure(['glob2regpat(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['glob2regpat(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1174: String required for argument 1'])
glob2regpat('')->assert_equal('^$')
enddef
def Test_globpath()
globpath('.', 'runtest.vim', true, true, true)->assert_equal(['./runtest.vim'])
- v9.CheckDefAndScriptFailure(['globpath(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['globpath("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['globpath("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
- v9.CheckDefAndScriptFailure(['globpath("a", "b", true, "d")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4'])
- v9.CheckDefAndScriptFailure(['globpath("a", "b", true, false, "e")'], ['E1013: Argument 5: type mismatch, expected bool but got string', 'E1212: Bool required for argument 5'])
+ v9.CheckSourceDefAndScriptFailure(['globpath(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['globpath("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['globpath("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['globpath("a", "b", true, "d")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['globpath("a", "b", true, false, "e")'], ['E1013: Argument 5: type mismatch, expected bool but got string', 'E1212: Bool required for argument 5'])
globpath('', '')->assert_equal('')
enddef
def Test_has()
has('eval', true)->assert_equal(1)
- v9.CheckDefAndScriptFailure(['has(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['has("a", "b")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['has(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['has("a", "b")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
has('')->assert_equal(0)
enddef
@@ -2098,14 +2098,14 @@ def Test_has_key()
assert_false(has_key(d, 'x'))
assert_false(has_key(d, 99))
- v9.CheckDefAndScriptFailure(['has_key([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['has_key({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list<string>', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['has_key([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['has_key({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list<string>', 'E1220: String or Number required for argument 2'])
enddef
def Test_haslocaldir()
- v9.CheckDefAndScriptFailure(['haslocaldir("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['haslocaldir("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['haslocaldir(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['haslocaldir("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['haslocaldir("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['haslocaldir(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_hasmapto()
@@ -2113,81 +2113,81 @@ def Test_hasmapto()
iabbrev foo foobar
hasmapto('foobar', 'i', true)->assert_equal(1)
iunabbrev foo
- v9.CheckDefAndScriptFailure(['hasmapto(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['hasmapto("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['hasmapto("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['hasmapto(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['hasmapto("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['hasmapto("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
hasmapto('', '')->assert_equal(0)
enddef
def Test_histadd()
- v9.CheckDefAndScriptFailure(['histadd(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['histadd(":", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['histadd(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['histadd(":", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
histadd("search", 'skyblue')
assert_equal('skyblue', histget('/', -1))
histadd("search", '')->assert_equal(0)
enddef
def Test_histdel()
- v9.CheckDefAndScriptFailure(['histdel(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['histdel(":", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['histdel(1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['histdel(":", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
histdel('search', '')->assert_equal(0)
enddef
def Test_histget()
- v9.CheckDefAndScriptFailure(['histget(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['histget("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['histget(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['histget("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_histnr()
- v9.CheckDefAndScriptFailure(['histnr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['histnr(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal(-1, histnr('abc'))
enddef
def Test_hlID()
- v9.CheckDefAndScriptFailure(['hlID(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['hlID(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal(0, hlID('NonExistingHighlight'))
hlID('')->assert_equal(0)
enddef
def Test_hlexists()
- v9.CheckDefAndScriptFailure(['hlexists([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['hlexists([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
assert_equal(0, hlexists('NonExistingHighlight'))
hlexists('')->assert_equal(0)
enddef
def Test_hlget()
- v9.CheckDefAndScriptFailure(['hlget([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['hlget([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
hlget('')->assert_equal([])
enddef
def Test_hlset()
- v9.CheckDefAndScriptFailure(['hlset("id")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['hlset("id")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
hlset([])->assert_equal(0)
enddef
def Test_iconv()
- v9.CheckDefAndScriptFailure(['iconv(1, "from", "to")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['iconv("abc", 10, "to")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['iconv("abc", "from", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['iconv(1, "from", "to")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['iconv("abc", 10, "to")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['iconv("abc", "from", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
assert_equal('abc', iconv('abc', 'fromenc', 'toenc'))
iconv('', '', '')->assert_equal('')
enddef
def Test_indent()
- v9.CheckDefAndScriptFailure(['indent([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['indent(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['indent("")'], 'E1209: Invalid value for a line number')
- v9.CheckDefExecAndScriptFailure(['indent(-1)'], 'E966: Invalid line number: -1')
+ v9.CheckSourceDefAndScriptFailure(['indent([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['indent(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['indent("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecAndScriptFailure(['indent(-1)'], 'E966: Invalid line number: -1')
assert_equal(0, indent(1))
enddef
def Test_index()
index(['a', 'b', 'a', 'B'], 'b', 2, true)->assert_equal(3)
- v9.CheckDefAndScriptFailure(['index("a", "a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1226: List or Blob required for argument 1'])
- v9.CheckDefFailure(['index(["1"], 1)'], 'E1013: Argument 2: type mismatch, expected string but got number')
- v9.CheckDefAndScriptFailure(['index(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['index([1], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['index(0z1020, 10, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['index("a", "a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1226: List or Blob required for argument 1'])
+ v9.CheckSourceDefFailure(['index(["1"], 1)'], 'E1013: Argument 2: type mismatch, expected string but got number')
+ v9.CheckSourceDefAndScriptFailure(['index(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['index([1], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['index(0z1020, 10, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
enddef
def Test_indexof()
@@ -2210,7 +2210,7 @@ def Test_indexof()
indexof([{color: "red"}], TestIdx)
END
- v9.CheckDefAndScriptFailure(lines, ['E176: Invalid number of arguments', 'E118: Too many arguments for function'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E176: Invalid number of arguments', 'E118: Too many arguments for function'])
lines =<< trim END
def TestIdx(k: number, v: dict<any>)
@@ -2218,7 +2218,7 @@ def Test_indexof()
indexof([{color: "red"}], TestIdx)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool', 'E1031: Cannot use void value'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool', 'E1031: Cannot use void value'])
lines =<< trim END
def TestIdx(k: number, v: dict<any>): string
@@ -2227,35 +2227,35 @@ def Test_indexof()
indexof([{color: "red"}], TestIdx)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool', 'E1135: Using a String as a Bool'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?any): bool', 'E1135: Using a String as a Bool'])
enddef
def Test_input()
- v9.CheckDefAndScriptFailure(['input(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['input(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['input("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['input("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['input(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['input(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['input("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['input("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
enddef
def Test_inputdialog()
- v9.CheckDefAndScriptFailure(['inputdialog(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['inputdialog(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['inputdialog("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['inputdialog("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['inputdialog(5)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['inputdialog(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['inputdialog("p", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['inputdialog("p", "q", 20)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
enddef
def Test_inputlist()
- v9.CheckDefAndScriptFailure(['inputlist(10)'], ['E1013: Argument 1: type mismatch, expected list<string> but got number', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['inputlist("abc")'], ['E1013: Argument 1: type mismatch, expected list<string> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefFailure(['inputlist([1, 2, 3])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>')
+ v9.CheckSourceDefAndScriptFailure(['inputlist(10)'], ['E1013: Argument 1: type mismatch, expected list<string> but got number', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['inputlist("abc")'], ['E1013: Argument 1: type mismatch, expected list<string> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefFailure(['inputlist([1, 2, 3])'], 'E1013: Argument 1: type mismatch, expected list<string> but got list<number>')
feedkeys("2\<CR>", 't')
var r: number = inputlist(['a', 'b', 'c'])
assert_equal(2, r)
enddef
def Test_inputsecret()
- v9.CheckDefAndScriptFailure(['inputsecret(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['inputsecret("Pass:", 20)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['inputsecret(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['inputsecret("Pass:", 20)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
feedkeys("\<CR>", 't')
var ans: string = inputsecret('Pass:', '123')
assert_equal('123', ans)
@@ -2282,12 +2282,12 @@ def Test_insert()
var lines =<< trim END
insert(test_null_list(), 123)
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1130:', 1)
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1130:', 1)
lines =<< trim END
insert(test_null_blob(), 123)
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1131:', 1)
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1131:', 1)
assert_equal([1, 2, 3], insert([2, 3], 1))
assert_equal([1, 2, 3], insert([2, 3], number_one))
@@ -2296,9 +2296,9 @@ def Test_insert()
assert_equal(['a', 'b', 'c'], insert(['b', 'c'], 'a'))
assert_equal(0z1234, insert(0z34, 0x12))
- v9.CheckDefAndScriptFailure(['insert("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1226: List or Blob required for argument 1'])
- v9.CheckDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
- v9.CheckDefAndScriptFailure(['insert([2, 3], 1, "x")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['insert("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1226: List or Blob required for argument 1'])
+ v9.CheckSourceDefFailure(['insert([2, 3], "a")'], 'E1013: Argument 2: type mismatch, expected number but got string')
+ v9.CheckSourceDefAndScriptFailure(['insert([2, 3], 1, "x")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
enddef
def Test_instanceof()
@@ -2308,7 +2308,7 @@ def Test_instanceof()
endclass
instanceof('hello', Foo)
END
- v9.CheckScriptFailure(lines, 'E616: Object required for argument 1')
+ v9.CheckSourceScriptFailure(lines, 'E616: Object required for argument 1')
lines =<< trim END
vim9script
@@ -2316,7 +2316,7 @@ def Test_instanceof()
endclass
instanceof(Foo.new(), 123)
END
- v9.CheckScriptFailure(lines, 'E693: Class or class typealias required for argument 2')
+ v9.CheckSourceScriptFailure(lines, 'E693: Class or class typealias required for argument 2')
lines =<< trim END
vim9script
@@ -2327,7 +2327,7 @@ def Test_instanceof()
enddef
Bar()
END
- v9.CheckScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected object<Unknown> but got string')
+ v9.CheckSourceScriptFailure(lines, 'E1013: Argument 1: type mismatch, expected object<Unknown> but got string')
lines =<< trim END
vim9script
@@ -2338,7 +2338,7 @@ def Test_instanceof()
enddef
Bar()
END
- v9.CheckScriptFailure(lines, 'E693: Class or class typealias required for argument 2')
+ v9.CheckSourceScriptFailure(lines, 'E693: Class or class typealias required for argument 2')
lines =<< trim END
vim9script
@@ -2346,7 +2346,7 @@ def Test_instanceof()
endclass
instanceof(Foo.new(), [{}])
END
- v9.CheckSourceFailure(lines, 'E693: Class or class typealias required for argument 2')
+ v9.CheckSourceScriptFailure(lines, 'E693: Class or class typealias required for argument 2')
lines =<< trim END
vim9script
@@ -2357,22 +2357,22 @@ def Test_instanceof()
enddef
Bar()
END
- v9.CheckSourceFailure(lines, 'E693: Class or class typealias required for argument 2')
+ v9.CheckSourceScriptFailure(lines, 'E693: Class or class typealias required for argument 2')
enddef
def Test_invert()
- v9.CheckDefAndScriptFailure(['invert("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['invert("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_isdirectory()
- v9.CheckDefAndScriptFailure(['isdirectory(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['isdirectory(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
assert_false(isdirectory('NonExistingDir'))
assert_false(isdirectory(''))
enddef
def Test_islocked()
- v9.CheckDefAndScriptFailure(['islocked(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['var n1: number = 10', 'islocked(n1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['islocked(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['var n1: number = 10', 'islocked(n1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
g:v1 = 10
assert_false(islocked('g:v1'))
lockvar g:v1
@@ -2382,7 +2382,7 @@ def Test_islocked()
enddef
def Test_items()
- v9.CheckDefFailure(['123->items()'], 'E1225:')
+ v9.CheckSourceDefFailure(['123->items()'], 'E1225:')
assert_equal([['a', 10], ['b', 20]], {'a': 10, 'b': 20}->items())
assert_equal([], {}->items())
assert_equal(['x', 'x'], {'a': 10, 'b': 20}->items()->map((_, _) => 'x'))
@@ -2400,7 +2400,7 @@ def Test_job_getchannel()
if !has('job')
CheckFeature job
else
- v9.CheckDefAndScriptFailure(['job_getchannel("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['job_getchannel("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
assert_fails('job_getchannel(test_null_job())', 'E916: Not a valid job')
endif
enddef
@@ -2409,7 +2409,7 @@ def Test_job_info()
if !has('job')
CheckFeature job
else
- v9.CheckDefAndScriptFailure(['job_info("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['job_info("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
assert_fails('job_info(test_null_job())', 'E916: Not a valid job')
endif
enddef
@@ -2420,8 +2420,8 @@ def Test_job_setoptions()
if !has('job')
CheckFeature job
else
- v9.CheckDefAndScriptFailure(['job_setoptions(test_null_channel(), {})'], ['E1013: Argument 1: type mismatch, expected job but got channel', 'E1218: Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['job_setoptions(test_null_job(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['job_setoptions(test_null_channel(), {})'], ['E1013: Argument 1: type mismatch, expected job but got channel', 'E1218: Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['job_setoptions(test_null_job(), [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
assert_equal('fail', job_status(test_null_job()))
endif
enddef
@@ -2430,7 +2430,7 @@ def Test_job_status()
if !has('job')
CheckFeature job
else
- v9.CheckDefAndScriptFailure(['job_status("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['job_status("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
assert_equal('fail', job_status(test_null_job()))
endif
enddef
@@ -2439,25 +2439,25 @@ def Test_job_stop()
if !has('job')
CheckFeature job
else
- v9.CheckDefAndScriptFailure(['job_stop("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
- v9.CheckDefAndScriptFailure(['job_stop(test_null_job(), true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['job_stop("a")'], ['E1013: Argument 1: type mismatch, expected job but got string', 'E1218: Job required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['job_stop(test_null_job(), true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
endif
enddef
def Test_join()
- v9.CheckDefAndScriptFailure(['join("abc")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['join([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['join("abc")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['join([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
join([''], '')->assert_equal('')
enddef
def Test_js_decode()
- v9.CheckDefAndScriptFailure(['js_decode(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['js_decode(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal([1, 2], js_decode('[1,2]'))
js_decode('')->assert_equal(v:none)
enddef
def Test_json_decode()
- v9.CheckDefAndScriptFailure(['json_decode(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['json_decode(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1174: String required for argument 1'])
assert_equal(1.0, json_decode('1.0'))
json_decode('')->assert_equal(v:none)
enddef
@@ -2465,7 +2465,7 @@ enddef
def Test_keys()
assert_equal([7, 7], keys({a: 1, b: 2})->map((_, _) => 7))
- v9.CheckDefAndScriptFailure(['keys([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['keys([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
assert_equal(['a'], {a: 'v'}->keys())
assert_equal([], {}->keys())
enddef
@@ -2476,7 +2476,7 @@ def Test_keys_return_type()
enddef
def Test_len()
- v9.CheckDefAndScriptFailure(['len(true)'], ['E1013: Argument 1: type mismatch, expected list<any> but got bool', 'E701: Invalid type for len()'])
+ v9.CheckSourceDefAndScriptFailure(['len(true)'], ['E1013: Argument 1: type mismatch, expected list<any> but got bool', 'E701: Invalid type for len()'])
assert_equal(2, "ab"->len())
assert_equal(3, 456->len())
assert_equal(0, []->len())
@@ -2486,42 +2486,42 @@ enddef
def Test_libcall()
CheckFeature libcall
- v9.CheckDefAndScriptFailure(['libcall(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['libcall("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['libcall("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['libcall(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['libcall("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['libcall("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3'])
enddef
def Test_libcallnr()
CheckFeature libcall
- v9.CheckDefAndScriptFailure(['libcallnr(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['libcallnr("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['libcallnr("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['libcallnr(1, "b", 3)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['libcallnr("a", 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['libcallnr("a", "b", 1.1)'], ['E1013: Argument 3: type mismatch, expected string but got float', 'E1220: String or Number required for argument 3'])
enddef
def Test_line()
assert_fails('line(true)', 'E1174:')
- v9.CheckDefAndScriptFailure(['line(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['line(".", "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['line("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['line(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['line(".", "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['line("")'], 'E1209: Invalid value for a line number')
enddef
def Test_line2byte()
- v9.CheckDefAndScriptFailure(['line2byte(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['line2byte("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['line2byte(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['line2byte("")'], 'E1209: Invalid value for a line number')
assert_equal(-1, line2byte(1))
assert_equal(-1, line2byte(10000))
enddef
def Test_lispindent()
- v9.CheckDefAndScriptFailure(['lispindent({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['lispindent("")'], 'E1209: Invalid value for a line number')
- v9.CheckDefExecAndScriptFailure(['lispindent(-1)'], 'E966: Invalid line number: -1')
+ v9.CheckSourceDefAndScriptFailure(['lispindent({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['lispindent("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecAndScriptFailure(['lispindent(-1)'], 'E966: Invalid line number: -1')
assert_equal(0, lispindent(1))
enddef
def Test_list2blob()
- v9.CheckDefAndScriptFailure(['list2blob(10)'], ['E1013: Argument 1: type mismatch, expected list<number> but got number', 'E1211: List required for argument 1'])
- v9.CheckDefFailure(['list2blob([0z10, 0z02])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<blob>')
+ v9.CheckSourceDefAndScriptFailure(['list2blob(10)'], ['E1013: Argument 1: type mismatch, expected list<number> but got number', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefFailure(['list2blob([0z10, 0z02])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<blob>')
enddef
def Test_list2str_str2list_utf8()
@@ -2532,8 +2532,8 @@ def Test_list2str_str2list_utf8()
enddef
def Test_list2str()
- v9.CheckDefAndScriptFailure(['list2str(".", true)'], ['E1013: Argument 1: type mismatch, expected list<number> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['list2str([1], 0z10)'], ['E1013: Argument 2: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['list2str(".", true)'], ['E1013: Argument 1: type mismatch, expected list<number> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['list2str([1], 0z10)'], ['E1013: Argument 2: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 2'])
enddef
def s:SID(): number
@@ -2543,22 +2543,22 @@ def s:SID(): number
enddef
def Test_listener_add()
- v9.CheckDefAndScriptFailure(['listener_add("1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['listener_add("1", true)'], ['E1013: Argument 2: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 2'])
enddef
def Test_listener_flush()
- v9.CheckDefAndScriptFailure(['listener_flush([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['listener_flush([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
enddef
def Test_listener_remove()
- v9.CheckDefAndScriptFailure(['listener_remove("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['listener_remove("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_luaeval()
if !has('lua')
CheckFeature lua
endif
- v9.CheckDefAndScriptFailure(['luaeval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['luaeval(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
if exists_compiled('*luaeval')
luaeval('')->assert_equal(v:null)
endif
@@ -2566,10 +2566,10 @@ enddef
def Test_map()
if has('channel')
- v9.CheckDefAndScriptFailure(['map(test_null_channel(), "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got channel', 'E1251: List, Dictionary, Blob or String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['map(test_null_channel(), "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got channel', 'E1251: List, Dictionary, Blob or String required for argument 1'])
endif
- v9.CheckDefAndScriptFailure(['map(1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1251: List, Dictionary, Blob or String required for argument 1'])
- v9.CheckDefAndScriptFailure(['map([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String'])
+ v9.CheckSourceDefAndScriptFailure(['map(1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1251: List, Dictionary, Blob or String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['map([1, 2], 4)'], ['E1256: String or function required for argument 2', 'E1024: Using a Number as a String'])
# type of dict remains dict<any> even when type of values changes
# same for list
@@ -2599,7 +2599,7 @@ def Test_map()
assert_equal({a: 'x'}, {a: [1, 2]}->map((_, v) => 'x'))
assert_equal({a: 'x'}, {a: {b: 2}}->map((_, v) => 'x'))
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
enddef
def Test_map_failure()
@@ -2627,7 +2627,7 @@ def Test_map_failure()
g:gd = d
map(g:gd, (k, v) => true)
END
- v9.CheckDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got bool')
+ v9.CheckSourceDefExecAndScriptFailure(lines, 'E1012: Type mismatch; expected number but got bool')
enddef
def Test_map_const()
@@ -2635,13 +2635,13 @@ def Test_map_const()
const l = [1, 2, 3]
map(l, 'SomeFunc')
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
lines =<< trim END
const d = {a: 1, b: 2}
map(d, 'SomeFunc')
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
enddef
def Test_map_function_arg()
@@ -2653,16 +2653,16 @@ def Test_map_function_arg()
map(l, MapOne)
assert_equal(['0:a', '1:b', '2:c'], l)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
range(3)->map((a, b, c) => a + b + c)
END
- v9.CheckDefAndScriptFailure(lines, ['E176:', 'E1190: One argument too few'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E176:', 'E1190: One argument too few'])
lines =<< trim END
range(3)->map((a, b, c, d) => a + b + c + d)
END
- v9.CheckDefAndScriptFailure(lines, ['E176:', 'E1190: 2 arguments too few'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E176:', 'E1190: 2 arguments too few'])
# declared list cannot change type
lines =<< trim END
@@ -2672,7 +2672,7 @@ def Test_map_function_arg()
var ll: list<number> = [1, 2, 3]
echo map(ll, Map)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, number): string', 'E1012: Type mismatch; expected number but got string'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, number): string', 'E1012: Type mismatch; expected number but got string'])
# not declared list can change type
echo [1, 2, 3]->map((..._) => 'x')
@@ -2684,25 +2684,25 @@ def Test_map_item_type()
map(l, (k, v) => k .. '/' .. v )
assert_equal(['0/a', '1/b', '2/c'], l)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
var l: list<number> = [0]
echo map(l, (_, v) => [])
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(any, any): list<any>', 'E1012: Type mismatch; expected number but got list<any>'], 2)
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(any, any): list<any>', 'E1012: Type mismatch; expected number but got list<any>'], 2)
lines =<< trim END
var l: list<number> = range(2)
echo map(l, (_, v) => [])
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(any, any): list<any>', 'E1012: Type mismatch; expected number but got list<any>'], 2)
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(any, any): list<any>', 'E1012: Type mismatch; expected number but got list<any>'], 2)
lines =<< trim END
var d: dict<number> = {key: 0}
echo map(d, (_, v) => [])
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?number): number but got func(any, any): list<any>', 'E1012: Type mismatch; expected number but got list<any>'], 2)
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?number): number but got func(any, any): list<any>', 'E1012: Type mismatch; expected number but got list<any>'], 2)
enddef
def Test_maparg()
@@ -2725,10 +2725,10 @@ def Test_maparg()
abbr: 0,
mode_bits: 0x47})
unmap foo
- v9.CheckDefAndScriptFailure(['maparg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['maparg("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['maparg("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
- v9.CheckDefAndScriptFailure(['maparg("a", "b", true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['maparg(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['maparg("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['maparg("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['maparg("a", "b", true, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
maparg('')->assert_equal('')
# value argument type is checked at compile time
@@ -2736,46 +2736,46 @@ def Test_maparg()
var l = [123]
l->map((i: number, v: string) => 0)
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, string): number')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, string): number')
lines =<< trim END
var d = {a: 123}
d->map((i: string, v: string) => 0)
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?string, ?number): number but got func(string, string): number')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?string, ?number): number but got func(string, string): number')
lines =<< trim END
var s = 'abc'
s->map((i: number, v: number) => 'x')
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?string): string but got func(number, number): string')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?string): string but got func(number, number): string')
lines =<< trim END
var s = 0z1122
s->map((i: number, v: string) => 0)
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, string): number')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, string): number')
# index argument type is checked at compile time
lines =<< trim END
['x']->map((i: string, v: string) => 'y')
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?any): any but got func(string, string): string')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?any): any but got func(string, string): string')
lines =<< trim END
{a: 1}->map((i: number, v: number) => 0)
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?string, ?any): any but got func(number, number): number')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?string, ?any): any but got func(number, number): number')
lines =<< trim END
'abc'->map((i: string, v: string) => 'x')
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?string): string but got func(string, string): string')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?string): string but got func(string, string): string')
lines =<< trim END
0z1122->map((i: string, v: number) => 0)
END
- v9.CheckDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(string, number): number')
+ v9.CheckSourceDefFailure(lines, 'E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(string, number): number')
enddef
def Test_maparg_mapset()
@@ -2790,31 +2790,31 @@ def Test_mapcheck()
iabbrev foo foobar
mapcheck('foo', 'i', true)->assert_equal('foobar')
iunabbrev foo
- v9.CheckDefAndScriptFailure(['mapcheck(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['mapcheck("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['mapcheck("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['mapcheck(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mapcheck("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['mapcheck("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
mapcheck('')->assert_equal('')
mapcheck('', '')->assert_equal('')
enddef
def Test_mapnew()
if has('channel')
- v9.CheckDefAndScriptFailure(['mapnew(test_null_job(), "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got job', 'E1251: List, Dictionary, Blob or String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mapnew(test_null_job(), "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got job', 'E1251: List, Dictionary, Blob or String required for argument 1'])
endif
- v9.CheckDefAndScriptFailure(['mapnew(1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1251: List, Dictionary, Blob or String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mapnew(1, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1251: List, Dictionary, Blob or String required for argument 1'])
enddef
def Test_mapset()
- v9.CheckDefAndScriptFailure(['mapset(1, true, {})'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1223: String or Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['mapset("a", 2, {})'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
- v9.CheckDefAndScriptFailure(['mapset("a", false, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['mapset(1, true, {})'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1223: String or Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mapset("a", 2, {})'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['mapset("a", false, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
enddef
def Test_match()
- v9.CheckDefAndScriptFailure(['match(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['match(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['match("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['match("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['match(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['match(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['match("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['match("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
assert_equal(2, match('ab12cd', '12'))
assert_equal(-1, match('ab12cd', '34'))
assert_equal(6, match('ab12cd12ef', '12', 4))
@@ -2829,39 +2829,39 @@ def Test_match()
enddef
def Test_matchadd()
- v9.CheckDefAndScriptFailure(['matchadd(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchadd("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchadd("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['matchadd("a", "b", 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
- v9.CheckDefAndScriptFailure(['matchadd("a", "b", 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 5'])
+ v9.CheckSourceDefAndScriptFailure(['matchadd(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchadd("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchadd("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchadd("a", "b", 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['matchadd("a", "b", 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 5'])
matchadd('', 'a')->assert_equal(-1)
matchadd('Search', '')->assert_equal(-1)
enddef
def Test_matchaddpos()
- v9.CheckDefAndScriptFailure(['matchaddpos(1, [1])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchaddpos("a", "b")'], ['E1013: Argument 2: type mismatch, expected list<any> but got string', 'E1211: List required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchaddpos("a", [1], "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['matchaddpos("a", [1], 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
- v9.CheckDefAndScriptFailure(['matchaddpos("a", [1], 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 5'])
+ v9.CheckSourceDefAndScriptFailure(['matchaddpos(1, [1])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchaddpos("a", "b")'], ['E1013: Argument 2: type mismatch, expected list<any> but got string', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchaddpos("a", [1], "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchaddpos("a", [1], 1, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['matchaddpos("a", [1], 1, 1, [])'], ['E1013: Argument 5: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 5'])
matchaddpos('', [1])->assert_equal(-1)
enddef
def Test_matcharg()
- v9.CheckDefAndScriptFailure(['matcharg("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matcharg("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_matchdelete()
- v9.CheckDefAndScriptFailure(['matchdelete("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchdelete("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchdelete(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchdelete("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchdelete("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchdelete(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_matchend()
- v9.CheckDefAndScriptFailure(['matchend(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchend(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchend("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['matchend("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['matchend(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchend(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchend("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchend("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
assert_equal(4, matchend('ab12cd', '12'))
assert_equal(-1, matchend('ab12cd', '34'))
assert_equal(8, matchend('ab12cd12ef', '12', 4))
@@ -2876,9 +2876,9 @@ def Test_matchend()
enddef
def Test_matchfuzzy()
- v9.CheckDefAndScriptFailure(['matchfuzzy({}, "p")'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchfuzzy([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchfuzzy([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchfuzzy({}, "p")'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchfuzzy([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchfuzzy([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
matchfuzzy(['abc', 'xyz'], '')->assert_equal([])
var lines =<< trim END
var items = [{name: 'xyz', id: 1}, {name: 'def', id: 2},
@@ -2888,13 +2888,13 @@ def Test_matchfuzzy()
var k: list<string> = matchfuzzy(['one', 'two', 'who'], 'o')
assert_equal(['one', 'two', 'who'], k)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
enddef
def Test_matchfuzzypos()
- v9.CheckDefAndScriptFailure(['matchfuzzypos({}, "p")'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchfuzzypos([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchfuzzypos([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchfuzzypos({}, "p")'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchfuzzypos([], 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchfuzzypos([], "a", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
matchfuzzypos(['abc', 'xyz'], '')->assert_equal([[], [], []])
var lines =<< trim END
var items = [{name: 'xyz', id: 1}, {name: 'def', id: 2},
@@ -2904,14 +2904,14 @@ def Test_matchfuzzypos()
var k: list<string> = matchfuzzypos(['one', 'two', 'who'], 'o')[0]
assert_equal(['one', 'two', 'who'], k)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
enddef
def Test_matchlist()
- v9.CheckDefAndScriptFailure(['matchlist(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchlist(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchlist("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['matchlist("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['matchlist(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchlist(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchlist("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchlist("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
var l: list<string> = ['12', '', '', '', '', '', '', '', '', '']
assert_equal(l, matchlist('ab12cd', '12'))
assert_equal([], matchlist('ab12cd', '34'))
@@ -2929,10 +2929,10 @@ def Test_matchlist()
enddef
def Test_matchstr()
- v9.CheckDefAndScriptFailure(['matchstr(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchstr(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchstr("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['matchstr("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['matchstr(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchstr(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchstr("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchstr("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
assert_equal('12', matchstr('ab12cd', '12'))
assert_equal('', matchstr('ab12cd', '34'))
assert_equal('12', matchstr('ab12cd12ef', '12', 4))
@@ -2947,10 +2947,10 @@ def Test_matchstr()
enddef
def Test_matchstrpos()
- v9.CheckDefAndScriptFailure(['matchstrpos(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['matchstrpos(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['matchstrpos("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['matchstrpos("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['matchstrpos(0z12, "p")'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['matchstrpos(["s"], [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['matchstrpos("s", "p", "q")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['matchstrpos("s", "p", 1, "r")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
assert_equal(['12', 2, 4], matchstrpos('ab12cd', '12'))
assert_equal(['', -1, -1], matchstrpos('ab12cd', '34'))
assert_equal(['12', 6, 8], matchstrpos('ab12cd12ef', '12', 4))
@@ -2978,13 +2978,13 @@ def Test_max()
? [1, max([2, 3])]
: [4, 5]
assert_equal([4, 5], l2)
- v9.CheckDefAndScriptFailure(['max(5)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1227: List or Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['max(5)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1227: List or Dictionary required for argument 1'])
enddef
def Test_menu_info()
- v9.CheckDefAndScriptFailure(['menu_info(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['menu_info(10, "n")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['menu_info("File", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['menu_info(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['menu_info(10, "n")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['menu_info("File", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
assert_equal({}, menu_info('aMenu'))
enddef
@@ -3000,49 +3000,49 @@ def Test_min()
? [1, min([2, 3])]
: [4, 5]
assert_equal([4, 5], l2)
- v9.CheckDefAndScriptFailure(['min(5)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1227: List or Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['min(5)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1227: List or Dictionary required for argument 1'])
enddef
def Test_mkdir()
- v9.CheckDefAndScriptFailure(['mkdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['mkdir("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['mkdir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['mkdir("")'], 'E1175: Non-empty string required for argument 1')
+ v9.CheckSourceDefAndScriptFailure(['mkdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mkdir("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['mkdir("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['mkdir("")'], 'E1175: Non-empty string required for argument 1')
delete('a', 'rf')
enddef
def Test_mode()
- v9.CheckDefAndScriptFailure(['mode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['mode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
enddef
def Test_mzeval()
if !has('mzscheme')
CheckFeature mzscheme
endif
- v9.CheckDefAndScriptFailure(['mzeval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['mzeval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
enddef
def Test_nextnonblank()
- v9.CheckDefAndScriptFailure(['nextnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['nextnonblank("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['nextnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['nextnonblank("")'], 'E1209: Invalid value for a line number')
assert_equal(0, nextnonblank(1))
enddef
def Test_nr2char()
nr2char(97, true)->assert_equal('a')
- v9.CheckDefAndScriptFailure(['nr2char("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['nr2char(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['nr2char("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['nr2char(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
enddef
def Test_or()
- v9.CheckDefAndScriptFailure(['or("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['or(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['or("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['or(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_pathshorten()
- v9.CheckDefAndScriptFailure(['pathshorten(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['pathshorten("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['pathshorten(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['pathshorten("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
pathshorten('')->assert_equal('')
enddef
@@ -3050,12 +3050,12 @@ def Test_perleval()
if !has('perl')
CheckFeature perl
endif
- v9.CheckDefAndScriptFailure(['perleval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['perleval(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
enddef
def Test_popup_atcursor()
- v9.CheckDefAndScriptFailure(['popup_atcursor({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_atcursor("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_atcursor({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_atcursor("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
# Pass variable of type 'any' to popup_atcursor()
var what: any = 'Hello'
@@ -3065,17 +3065,17 @@ def Test_popup_atcursor()
enddef
def Test_popup_beval()
- v9.CheckDefAndScriptFailure(['popup_beval({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_beval("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_beval({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_beval("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_popup_clear()
- v9.CheckDefAndScriptFailure(['popup_clear(["a"])'], ['E1013: Argument 1: type mismatch, expected bool but got list<string>', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_clear(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_clear(["a"])'], ['E1013: Argument 1: type mismatch, expected bool but got list<string>', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_clear(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
enddef
def Test_popup_close()
- v9.CheckDefAndScriptFailure(['popup_close("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_close("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_popup_create()
@@ -3087,81 +3087,81 @@ def Test_popup_create()
enddef
def Test_popup_dialog()
- v9.CheckDefAndScriptFailure(['popup_dialog({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_dialog("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_dialog({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_dialog("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_popup_filter_menu()
- v9.CheckDefAndScriptFailure(['popup_filter_menu("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_filter_menu(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_filter_menu("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_filter_menu(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
var id: number = popup_menu(["one", "two", "three"], {})
popup_filter_menu(id, '')
popup_close(id)
enddef
def Test_popup_filter_yesno()
- v9.CheckDefAndScriptFailure(['popup_filter_yesno("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_filter_yesno(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_filter_yesno("x", "")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_filter_yesno(1, 1)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
enddef
def Test_popup_getoptions()
- v9.CheckDefAndScriptFailure(['popup_getoptions("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_getoptions(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_getoptions("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_getoptions(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
enddef
def Test_popup_getpos()
- v9.CheckDefAndScriptFailure(['popup_getpos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_getpos(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_getpos("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_getpos(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
enddef
def Test_popup_hide()
- v9.CheckDefAndScriptFailure(['popup_hide("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_hide(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_hide("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_hide(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
enddef
def Test_popup_locate()
- v9.CheckDefAndScriptFailure(['popup_locate("a", 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_locate(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_locate("a", 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_locate(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_popup_menu()
- v9.CheckDefAndScriptFailure(['popup_menu({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_menu("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_menu({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_menu("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_popup_move()
- v9.CheckDefAndScriptFailure(['popup_move("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_move(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_move("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_move(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_popup_notification()
- v9.CheckDefAndScriptFailure(['popup_notification({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_notification("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_notification({"a": 10}, {})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_notification("a", [1, 2])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_popup_setoptions()
- v9.CheckDefAndScriptFailure(['popup_setoptions("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_setoptions(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_setoptions("x", {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_setoptions(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_popup_settext()
- v9.CheckDefAndScriptFailure(['popup_settext("x", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_settext(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['popup_settext("x", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_settext(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2'])
enddef
def Test_popup_show()
- v9.CheckDefAndScriptFailure(['popup_show("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['popup_show(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_show("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['popup_show(true)'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
enddef
def Test_prevnonblank()
- v9.CheckDefAndScriptFailure(['prevnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['prevnonblank("")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['prevnonblank(null)'], ['E1013: Argument 1: type mismatch, expected string but got special', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['prevnonblank("")'], 'E1209: Invalid value for a line number')
assert_equal(0, prevnonblank(1))
enddef
def Test_printf()
- v9.CheckDefAndScriptFailure(['printf([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['printf([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
printf(0x10)->assert_equal('16')
assert_equal(" abc", "abc"->printf("%4s"))
enddef
@@ -3170,7 +3170,7 @@ def Test_prompt_getprompt()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['prompt_getprompt([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prompt_getprompt([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
assert_equal('', prompt_getprompt('NonExistingBuf'))
endif
enddef
@@ -3179,7 +3179,7 @@ def Test_prompt_setcallback()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['prompt_setcallback(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prompt_setcallback(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
endif
enddef
@@ -3187,7 +3187,7 @@ def Test_prompt_setinterrupt()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['prompt_setinterrupt(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prompt_setinterrupt(true, "1")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
endif
enddef
@@ -3195,109 +3195,109 @@ def Test_prompt_setprompt()
if !has('channel')
CheckFeature channel
else
- v9.CheckDefAndScriptFailure(['prompt_setprompt([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['prompt_setprompt(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prompt_setprompt([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prompt_setprompt(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
endif
enddef
def Test_prop_add()
- v9.CheckDefAndScriptFailure(['prop_add("a", 2, {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_add(1, "b", {})'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['prop_add(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['prop_add("a", 2, {})'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_add(1, "b", {})'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_add(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
enddef
def Test_prop_add_list()
- v9.CheckDefAndScriptFailure(['prop_add_list([], [])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_add_list({}, {})'], ['E1013: Argument 2: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_add_list([], [])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_add_list({}, {})'], ['E1013: Argument 2: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 2'])
enddef
def Test_prop_clear()
- v9.CheckDefAndScriptFailure(['prop_clear("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_clear(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['prop_clear(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['prop_clear("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_clear(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_clear(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
enddef
def Test_prop_find()
- v9.CheckDefAndScriptFailure(['prop_find([1, 2])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_find([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_find({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list<string>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_find([1, 2])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_find([1, 2], "k")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_find({"a": 10}, ["a"])'], ['E1013: Argument 2: type mismatch, expected string but got list<string>', 'E1174: String required for argument 2'])
assert_fails("prop_find({}, '')", 'E474:')
enddef
def Test_prop_list()
- v9.CheckDefAndScriptFailure(['prop_list("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_list(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_list("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_list(1, [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_prop_remove()
- v9.CheckDefAndScriptFailure(['prop_remove([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_remove({}, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['prop_remove({}, 1, "b")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['prop_remove([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_remove({}, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_remove({}, 1, "b")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
enddef
def Test_prop_type_add()
- v9.CheckDefAndScriptFailure(['prop_type_add({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_type_add("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_add({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_add("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
assert_fails("prop_type_add('', {highlight: 'Search'})", 'E475:')
enddef
def Test_prop_type_change()
- v9.CheckDefAndScriptFailure(['prop_type_change({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_type_change("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_change({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_change("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
assert_fails("prop_type_change('', {highlight: 'Search'})", 'E475:')
enddef
def Test_prop_type_delete()
- v9.CheckDefAndScriptFailure(['prop_type_delete({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_type_delete({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_type_delete("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_delete({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_delete({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_delete("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
assert_fails("prop_type_delete('')", 'E475:')
enddef
def Test_prop_type_get()
- v9.CheckDefAndScriptFailure(['prop_type_get({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_type_get({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_type_get("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_get({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_get({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_get("a", "b")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
assert_fails("prop_type_get('')", 'E475:')
enddef
def Test_prop_type_list()
- v9.CheckDefAndScriptFailure(['prop_type_list(["a"])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['prop_type_list(2)'], ['E1013: Argument 1: type mismatch, expected dict<any> but got number', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_list(["a"])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['prop_type_list(2)'], ['E1013: Argument 1: type mismatch, expected dict<any> but got number', 'E1206: Dictionary required for argument 1'])
enddef
def Test_py3eval()
if !has('python3')
CheckFeature python3
endif
- v9.CheckDefAndScriptFailure(['py3eval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['py3eval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
enddef
def Test_pyeval()
if !has('python')
CheckFeature python
endif
- v9.CheckDefAndScriptFailure(['pyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['pyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
enddef
def Test_pyxeval()
if !has('python') && !has('python3')
CheckFeature python
endif
- v9.CheckDefAndScriptFailure(['pyxeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['pyxeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
enddef
def Test_rand()
- v9.CheckDefAndScriptFailure(['rand(10)'], ['E1013: Argument 1: type mismatch, expected list<number> but got number', 'E1211: List required for argument 1'])
- v9.CheckDefFailure(['rand(["a"])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<string>')
+ v9.CheckSourceDefAndScriptFailure(['rand(10)'], ['E1013: Argument 1: type mismatch, expected list<number> but got number', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefFailure(['rand(["a"])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<string>')
assert_true(rand() >= 0)
assert_true(rand(srand()) >= 0)
enddef
def Test_range()
- v9.CheckDefAndScriptFailure(['range("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['range(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['range(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['range("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['range(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['range(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
# returns a list<number> but it's not declared as such
assert_equal(['x', 'x'], range(2)->map((i, v) => 'x'))
@@ -3306,8 +3306,8 @@ enddef
def Test_readdir()
eval expand('sautest')->readdir((e) => e[0] !=# '.')
eval expand('sautest')->readdirex((e) => e.name[0] !=# '.')
- v9.CheckDefAndScriptFailure(['readdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['readdir("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['readdir(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['readdir("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
if has('unix')
# only fails on Unix-like systems
assert_fails('readdir("")', 'E484: Can''t open file')
@@ -3315,8 +3315,8 @@ def Test_readdir()
enddef
def Test_readdirex()
- v9.CheckDefAndScriptFailure(['readdirex(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['readdirex("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['readdirex(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['readdirex("a", "1", [3])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
if has('unix')
# only fails on Unix-like systems
assert_fails('readdirex("")', 'E484: Can''t open file')
@@ -3332,8 +3332,8 @@ def Test_readblob()
var lines =<< trim END
var read: list<string> = readblob('Xreadblob')
END
- v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<string> but got blob', 1)
- v9.CheckDefExecAndScriptFailure(['readblob("")'], 'E484: Can''t open file <empty>')
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<string> but got blob', 1)
+ v9.CheckSourceDefExecAndScriptFailure(['readblob("")'], 'E484: Can''t open file <empty>')
enddef
def Test_readfile()
@@ -3346,15 +3346,15 @@ def Test_readfile()
var lines =<< trim END
var read: dict<string> = readfile('Xreadfile')
END
- v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got list<string>', 1)
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1012: Type mismatch; expected dict<string> but got list<string>', 1)
- v9.CheckDefAndScriptFailure(['readfile("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['readfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['readfile("")'], 'E1175: Non-empty string required for argument 1')
+ v9.CheckSourceDefAndScriptFailure(['readfile("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['readfile("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['readfile("")'], 'E1175: Non-empty string required for argument 1')
enddef
def Test_reduce()
- v9.CheckDefAndScriptFailure(['reduce({a: 10}, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1252: String, List or Blob required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['reduce({a: 10}, "1")'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1252: String, List or Blob required for argument 1'])
assert_equal(6, [1, 2, 3]->reduce((r, c) => r + c, 0))
assert_equal(11, 0z0506->reduce((r, c) => r + c, 0))
enddef
@@ -3362,13 +3362,13 @@ enddef
def Test_reltime()
CheckFeature reltime
- v9.CheckDefExecAndScriptFailure(['[]->reltime()'], 'E474:')
- v9.CheckDefExecAndScriptFailure(['[]->reltime([])'], 'E474:')
+ v9.CheckSourceDefExecAndScriptFailure(['[]->reltime()'], 'E474:')
+ v9.CheckSourceDefExecAndScriptFailure(['[]->reltime([])'], 'E474:')
- v9.CheckDefAndScriptFailure(['reltime("x")'], ['E1013: Argument 1: type mismatch, expected list<number> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefFailure(['reltime(["x", "y"])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<string>')
- v9.CheckDefAndScriptFailure(['reltime([1, 2], 10)'], ['E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2'])
- v9.CheckDefFailure(['reltime([1, 2], ["a", "b"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
+ v9.CheckSourceDefAndScriptFailure(['reltime("x")'], ['E1013: Argument 1: type mismatch, expected list<number> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefFailure(['reltime(["x", "y"])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<string>')
+ v9.CheckSourceDefAndScriptFailure(['reltime([1, 2], 10)'], ['E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefFailure(['reltime([1, 2], ["a", "b"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
var start: list<any> = reltime()
assert_true(type(reltime(start)) == v:t_list)
var end: list<any> = reltime()
@@ -3378,31 +3378,31 @@ enddef
def Test_reltimefloat()
CheckFeature reltime
- v9.CheckDefExecAndScriptFailure(['[]->reltimefloat()'], 'E474:')
+ v9.CheckSourceDefExecAndScriptFailure(['[]->reltimefloat()'], 'E474:')
- v9.CheckDefAndScriptFailure(['reltimefloat("x")'], ['E1013: Argument 1: type mismatch, expected list<number> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefFailure(['reltimefloat([1.1])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<float>')
+ v9.CheckSourceDefAndScriptFailure(['reltimefloat("x")'], ['E1013: Argument 1: type mismatch, expected list<number> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefFailure(['reltimefloat([1.1])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<float>')
assert_true(type(reltimefloat(reltime())) == v:t_float)
enddef
def Test_reltimestr()
CheckFeature reltime
- v9.CheckDefExecAndScriptFailure(['[]->reltimestr()'], 'E474:')
+ v9.CheckSourceDefExecAndScriptFailure(['[]->reltimestr()'], 'E474:')
- v9.CheckDefAndScriptFailure(['reltimestr(true)'], ['E1013: Argument 1: type mismatch, expected list<number> but got bool', 'E1211: List required for argument 1'])
- v9.CheckDefFailure(['reltimestr([true])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<bool>')
+ v9.CheckSourceDefAndScriptFailure(['reltimestr(true)'], ['E1013: Argument 1: type mismatch, expected list<number> but got bool', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefFailure(['reltimestr([true])'], 'E1013: Argument 1: type mismatch, expected list<number> but got list<bool>')
assert_true(type(reltimestr(reltime())) == v:t_string)
enddef
def Test_remote_expr()
CheckFeature clientserver
CheckEnv DISPLAY
- v9.CheckDefAndScriptFailure(['remote_expr(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['remote_expr("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['remote_expr("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
- v9.CheckDefAndScriptFailure(['remote_expr("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
- v9.CheckDefExecAndScriptFailure(['remote_expr("", "")'], 'E241: Unable to send to ')
+ v9.CheckSourceDefAndScriptFailure(['remote_expr(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['remote_expr("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['remote_expr("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['remote_expr("a", "b", "c", "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefExecAndScriptFailure(['remote_expr("", "")'], 'E241: Unable to send to ')
enddef
def Test_remote_foreground()
@@ -3411,7 +3411,7 @@ def Test_remote_foreground()
CheckNotMSWindows
CheckX11
- v9.CheckDefAndScriptFailure(['remote_foreground(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['remote_foreground(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_fails('remote_foreground("NonExistingServer")', 'E241:')
assert_fails('remote_foreground("")', 'E241:')
enddef
@@ -3419,32 +3419,32 @@ enddef
def Test_remote_peek()
CheckFeature clientserver
CheckEnv DISPLAY
- v9.CheckDefAndScriptFailure(['remote_peek(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['remote_peek("a5b6c7", [1])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['remote_peek("")'], 'E573: Invalid server id used')
+ v9.CheckSourceDefAndScriptFailure(['remote_peek(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['remote_peek("a5b6c7", [1])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['remote_peek("")'], 'E573: Invalid server id used')
enddef
def Test_remote_read()
CheckFeature clientserver
CheckEnv DISPLAY
- v9.CheckDefAndScriptFailure(['remote_read(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['remote_read("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['remote_read("")'], 'E573: Invalid server id used')
+ v9.CheckSourceDefAndScriptFailure(['remote_read(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['remote_read("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['remote_read("")'], 'E573: Invalid server id used')
enddef
def Test_remote_send()
CheckFeature clientserver
CheckEnv DISPLAY
- v9.CheckDefAndScriptFailure(['remote_send(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['remote_send("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['remote_send("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['remote_send(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['remote_send("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['remote_send("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
assert_fails('remote_send("", "")', 'E241:')
enddef
def Test_remote_startserver()
CheckFeature clientserver
CheckEnv DISPLAY
- v9.CheckDefAndScriptFailure(['remote_startserver({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['remote_startserver({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
enddef
def Test_remove_literal_list()
@@ -3458,28 +3458,28 @@ def Test_remove_const()
const l = [1, 2, 3, 4]
remove(l, 1)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
lines =<< trim END
const d = {a: 1, b: 2}
remove(d, 'a')
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const dict<number>')
lines =<< trim END
const b = 0z010203
remove(b, 1)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const blob')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const blob')
enddef
def Test_remove()
- v9.CheckDefAndScriptFailure(['remove("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1228: List, Dictionary or Blob required for argument 1'])
- v9.CheckDefAndScriptFailure(['remove([], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['remove([], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['remove({}, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['remove(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['remove(0z20, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['remove("a", 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1228: List, Dictionary or Blob required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['remove([], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['remove([], 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['remove({}, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['remove(0z10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['remove(0z20, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
var l: any = [1, 2, 3, 4]
remove(l, 1)
assert_equal([1, 3, 4], l)
@@ -3511,14 +3511,14 @@ def Test_remove_return_type()
enddef
def Test_rename()
- v9.CheckDefAndScriptFailure(['rename(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['rename("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['rename(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['rename("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
rename('', '')->assert_equal(0)
enddef
def Test_repeat()
- v9.CheckDefAndScriptFailure(['repeat(1.1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1301: String, Number, List or Blob required for argument 1'])
- v9.CheckDefAndScriptFailure(['repeat({a: 10}, 2)'], ['E1013: Argument 1: type mismatch, expected string but got dict<', 'E1301: String, Number, List or Blob required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['repeat(1.1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1301: String, Number, List or Blob required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['repeat({a: 10}, 2)'], ['E1013: Argument 1: type mismatch, expected string but got dict<', 'E1301: String, Number, List or Blob required for argument 1'])
var lines =<< trim END
assert_equal('aaa', repeat('a', 3))
assert_equal('111', repeat(1, 3))
@@ -3529,17 +3529,17 @@ def Test_repeat()
s ..= repeat(5, 3)
assert_equal('-555', s)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
enddef
def Test_resolve()
- v9.CheckDefAndScriptFailure(['resolve([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['resolve([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
assert_equal('SomeFile', resolve('SomeFile'))
resolve('')->assert_equal('')
enddef
def Test_reverse()
- v9.CheckDefAndScriptFailure(['reverse(10)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1252: String, List or Blob required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['reverse(10)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1252: String, List or Blob required for argument 1'])
enddef
def Test_reverse_return_type()
@@ -3556,49 +3556,49 @@ def Test_reverse_const()
const l = [1, 2, 3, 4]
reverse(l)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
lines =<< trim END
const b = 0z010203
reverse(b)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const blob')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const blob')
enddef
def Test_rubyeval()
if !has('ruby')
CheckFeature ruby
endif
- v9.CheckDefAndScriptFailure(['rubyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['rubyeval([2])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
enddef
def Test_screenattr()
- v9.CheckDefAndScriptFailure(['screenattr("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['screenattr(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['screenattr("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['screenattr(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_screenchar()
- v9.CheckDefAndScriptFailure(['screenchar("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['screenchar(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['screenchar("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['screenchar(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_screenchars()
assert_equal(['x'], screenchars(1, 1)->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['screenchars("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['screenchars(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['screenchars("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['screenchars(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_screenpos()
- v9.CheckDefAndScriptFailure(['screenpos("a", 1, 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['screenpos(1, "b", 1)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['screenpos(1, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['screenpos("a", 1, 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['screenpos(1, "b", 1)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['screenpos(1, 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
assert_equal({col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(1, 1, 1))
enddef
def Test_screenstring()
- v9.CheckDefAndScriptFailure(['screenstring("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['screenstring(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['screenstring("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['screenstring(1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_search()
@@ -3630,13 +3630,13 @@ def Test_search()
normal 0
assert_equal([0, 0], searchpos('this', '', 0, 0, 'col(".") > col'))
bwipe!
- v9.CheckDefAndScriptFailure(['search(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['search("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['search("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['search("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['search(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['search("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['search("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['search("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
new
setline(1, "match this")
- v9.CheckDefAndScriptFailure(['search("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list<number>', 'E730: Using a List as a String'])
+ v9.CheckSourceDefAndScriptFailure(['search("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list<number>', 'E730: Using a List as a String'])
bwipe!
enddef
@@ -3652,14 +3652,14 @@ def Test_searchcount()
maxcount: 99,
incomplete: 0})
bwipe!
- v9.CheckDefAndScriptFailure(['searchcount([1])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['searchcount([1])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 1'])
enddef
def Test_searchdecl()
searchdecl('blah', true, true)->assert_equal(1)
- v9.CheckDefAndScriptFailure(['searchdecl(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['searchdecl("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
- v9.CheckDefAndScriptFailure(['searchdecl("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['searchdecl(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['searchdecl("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['searchdecl("a", true, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
# search for an empty string declaration
var lines: list<string> =<< trim END
@@ -3719,7 +3719,7 @@ def Test_searchpair()
enddef
Fail()
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
assert_equal('yes', g:caught)
unlet g:caught
bwipe!
@@ -3727,64 +3727,64 @@ def Test_searchpair()
lines =<< trim END
echo searchpair("a", "b", "c", "d", "f", 33)
END
- v9.CheckDefAndScriptFailure(lines, ['E1001: Variable not found: f', 'E475: Invalid argument: d'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1001: Variable not found: f', 'E475: Invalid argument: d'])
var errors = ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1']
- v9.CheckDefAndScriptFailure(['searchpair(1, "b", "c")'], errors)
- v9.CheckDefAndScriptFailure(['searchpairpos(1, "b", "c")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpair(1, "b", "c")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpairpos(1, "b", "c")'], errors)
errors = ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2']
- v9.CheckDefAndScriptFailure(['searchpair("a", 2, "c")'], errors)
- v9.CheckDefAndScriptFailure(['searchpairpos("a", 2, "c")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpair("a", 2, "c")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpairpos("a", 2, "c")'], errors)
errors = ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3']
- v9.CheckDefAndScriptFailure(['searchpair("a", "b", 3)'], errors)
- v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", 3)'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpair("a", "b", 3)'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpairpos("a", "b", 3)'], errors)
errors = ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4']
- v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", 4)'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpair("a", "b", "c", 4)'], errors)
new
setline(1, "match this")
errors = ['E1013: Argument 5: type mismatch, expected func(...): any but got list<number>', 'E730: Using a List as a String']
- v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", [0])'], errors)
- v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", [0])'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpair("a", "b", "c", "r", [0])'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", [0])'], errors)
bwipe!
errors = ['E1013: Argument 6: type mismatch, expected number but got string', 'E1210: Number required for argument 6']
- v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", "f")'], errors)
- v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", "f")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", "f")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", "f")'], errors)
errors = ['E1013: Argument 7: type mismatch, expected number but got string', 'E1210: Number required for argument 7']
- v9.CheckDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", 3, "g")'], errors)
- v9.CheckDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", 3, "g")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpair("a", "b", "c", "r", "1", 3, "g")'], errors)
+ v9.CheckSourceDefAndScriptFailure(['searchpairpos("a", "b", "c", "r", "1", 3, "g")'], errors)
enddef
def Test_searchpos()
assert_equal(['x', 'x'], searchpos('.')->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['searchpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['searchpos("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['searchpos("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['searchpos("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['searchpos(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['searchpos("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['searchpos("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['searchpos("a", "b", 3, "d")'], ['E1013: Argument 4: type mismatch, expected number but got string', 'E1210: Number required for argument 4'])
new
setline(1, "match this")
- v9.CheckDefAndScriptFailure(['searchpos("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list<number>', 'E730: Using a List as a String'])
+ v9.CheckSourceDefAndScriptFailure(['searchpos("a", "", 9, 0, [0])'], ['E1013: Argument 5: type mismatch, expected func(...): any but got list<number>', 'E730: Using a List as a String'])
bwipe!
enddef
def Test_server2client()
CheckFeature clientserver
CheckEnv DISPLAY
- v9.CheckDefAndScriptFailure(['server2client(10, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['server2client("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['server2client("", "a")'], 'E573: Invalid server id used')
- v9.CheckDefExecAndScriptFailure(['server2client("", "")'], 'E573: Invalid server id used')
+ v9.CheckSourceDefAndScriptFailure(['server2client(10, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['server2client("a", 10)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['server2client("", "a")'], 'E573: Invalid server id used')
+ v9.CheckSourceDefExecAndScriptFailure(['server2client("", "")'], 'E573: Invalid server id used')
enddef
def Test_shellescape()
- v9.CheckDefAndScriptFailure(['shellescape(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['shellescape("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['shellescape(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['shellescape("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
if has('unix')
assert_equal("''", shellescape(''))
endif
@@ -3837,7 +3837,7 @@ def Test_set_get_bufline()
exe 'bwipe! ' .. b
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
enddef
def Test_setbufvar()
@@ -3864,8 +3864,8 @@ def Test_setbufvar()
setbufvar('%', 'myvar', 123)
getbufvar('%', 'myvar')->assert_equal(123)
- v9.CheckDefAndScriptFailure(['setbufvar(true, "v", 3)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['setbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['setbufvar(true, "v", 3)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setbufvar(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
assert_fails('setbufvar("%", "", 10)', 'E461: Illegal variable name')
enddef
@@ -3878,10 +3878,10 @@ def Test_setbufline()
setbufline(bnum, 5, 10)
setbufline(bnum, 6, ['two', 11])
assert_equal(['1', '2', '3', 'one', '10', 'two', '11'], getbufline(bnum, 1, '$'))
- v9.CheckDefAndScriptFailure(['setbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['setbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['setbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1')
- v9.CheckDefAndScriptFailure(['setbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['setbufline([1], 1, "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setbufline(1, [1], "x")'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['setbufline(' .. bnum .. ', -1, "x")'], 'E966: Invalid line number: -1')
+ v9.CheckSourceDefAndScriptFailure(['setbufline(1, 1, {"a": 10})'], ['E1013: Argument 3: type mismatch, expected string but got dict<number>', 'E1224: String, Number or List required for argument 3'])
bnum->bufwinid()->win_gotoid()
setbufline('', 1, 'nombres')
getline(1)->assert_equal('nombres')
@@ -3889,53 +3889,53 @@ def Test_setbufline()
enddef
def Test_setcellwidths()
- v9.CheckDefAndScriptFailure(['setcellwidths(1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['setcellwidths({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setcellwidths(1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setcellwidths({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
enddef
def Test_setcharpos()
- v9.CheckDefAndScriptFailure(['setcharpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefFailure(['setcharpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
- v9.CheckDefAndScriptFailure(['setcharpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['setcharpos("", [0, 1, 1, 1])'], 'E474: Invalid argument')
+ v9.CheckSourceDefAndScriptFailure(['setcharpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefFailure(['setcharpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
+ v9.CheckSourceDefAndScriptFailure(['setcharpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['setcharpos("", [0, 1, 1, 1])'], 'E474: Invalid argument')
enddef
def Test_setcharsearch()
- v9.CheckDefAndScriptFailure(['setcharsearch("x")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 1'])
- v9.CheckDefAndScriptFailure(['setcharsearch([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setcharsearch("x")'], ['E1013: Argument 1: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setcharsearch([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
var d: dict<any> = {char: 'x', forward: 1, until: 1}
setcharsearch(d)
assert_equal(d, getcharsearch())
enddef
def Test_setcmdline()
- v9.CheckDefAndScriptSuccess(['setcmdline("ls", 2)'])
- v9.CheckDefAndScriptFailure(['setcmdline(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['setcmdline("ls", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptSuccess(['setcmdline("ls", 2)'])
+ v9.CheckSourceDefAndScriptFailure(['setcmdline(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setcmdline("ls", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_setcmdpos()
- v9.CheckDefAndScriptFailure(['setcmdpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setcmdpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_setcursorcharpos()
- v9.CheckDefAndScriptFailure(['setcursorcharpos(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['setcursorcharpos(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['setcursorcharpos(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['setcursorcharpos("", 10)'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['setcursorcharpos(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected number but got blob', 'E1224: String, Number or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setcursorcharpos(1, "2")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['setcursorcharpos(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['setcursorcharpos("", 10)'], 'E1209: Invalid value for a line number')
enddef
def Test_setenv()
- v9.CheckDefAndScriptFailure(['setenv(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setenv(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal(0, setenv('', ''))
assert_equal(0, setenv('', v:null))
enddef
def Test_setfperm()
- v9.CheckDefAndScriptFailure(['setfperm(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['setfperm("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['setfperm("Xfile", "")'], 'E475: Invalid argument')
- v9.CheckDefExecAndScriptFailure(['setfperm("", "")'], 'E475: Invalid argument')
+ v9.CheckSourceDefAndScriptFailure(['setfperm(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setfperm("a", 0z10)'], ['E1013: Argument 2: type mismatch, expected string but got blob', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['setfperm("Xfile", "")'], 'E475: Invalid argument')
+ v9.CheckSourceDefExecAndScriptFailure(['setfperm("", "")'], 'E475: Invalid argument')
assert_equal(0, setfperm('', 'rw-r--r--'))
enddef
@@ -3949,9 +3949,9 @@ def Test_setline()
assert_equal(['one', 'b', 'c', 'd'], getline(1, '$'))
setline(1, 10)
assert_equal(['10', 'b', 'c', 'd'], getline(1, '$'))
- v9.CheckDefAndScriptFailure(['setline([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['setline("", "x")'], 'E1209: Invalid value for a line number')
- v9.CheckDefExecAndScriptFailure(['setline(-1, "x")'], 'E966: Invalid line number: -1')
+ v9.CheckSourceDefAndScriptFailure(['setline([1], "x")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['setline("", "x")'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecAndScriptFailure(['setline(-1, "x")'], 'E966: Invalid line number: -1')
assert_fails('setline(".a", "x")', ['E1209:', 'E1209:'])
bw!
enddef
@@ -3961,28 +3961,28 @@ def Test_setloclist()
var what = {items: items}
setqflist([], ' ', what)
setloclist(0, [], ' ', what)
- v9.CheckDefAndScriptFailure(['setloclist("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['setloclist(1, 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
- v9.CheckDefAndScriptFailure(['setloclist(1, [], 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
- v9.CheckDefAndScriptFailure(['setloclist(1, [], "a", [])'], ['E1013: Argument 4: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['setloclist("1", [])'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setloclist(1, 2)'], ['E1013: Argument 2: type mismatch, expected list<any> but got number', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['setloclist(1, [], 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['setloclist(1, [], "a", [])'], ['E1013: Argument 4: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 4'])
enddef
def Test_setmatches()
- v9.CheckDefAndScriptFailure(['setmatches({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['setmatches([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['setmatches({})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setmatches([], "1")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_setpos()
- v9.CheckDefAndScriptFailure(['setpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefFailure(['setpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
- v9.CheckDefAndScriptFailure(['setpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['setpos("", [0, 1, 1, 1])'], 'E474: Invalid argument')
+ v9.CheckSourceDefAndScriptFailure(['setpos(1, [])'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefFailure(['setpos(".", ["a"])'], 'E1013: Argument 2: type mismatch, expected list<number> but got list<string>')
+ v9.CheckSourceDefAndScriptFailure(['setpos(".", 1)'], ['E1013: Argument 2: type mismatch, expected list<number> but got number', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['setpos("", [0, 1, 1, 1])'], 'E474: Invalid argument')
enddef
def Test_setqflist()
- v9.CheckDefAndScriptFailure(['setqflist(1, "")'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['setqflist([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['setqflist([], "", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['setqflist(1, "")'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setqflist([], 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['setqflist([], "", [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
enddef
def Test_setreg()
@@ -3991,111 +3991,111 @@ def Test_setreg()
setreg('a', reginfo)
getreginfo('a')->assert_equal(reginfo)
assert_fails('setreg("ab", 0)', 'E1162:')
- v9.CheckDefAndScriptFailure(['setreg(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['setreg("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['setreg(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setreg("a", "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
setreg('', '1a2b3c')
assert_equal('1a2b3c', @")
enddef
def Test_settabvar()
- v9.CheckDefAndScriptFailure(['settabvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['settabvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['settabvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['settabvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
assert_fails('settabvar(1, "", 10)', 'E461: Illegal variable name')
enddef
def Test_settabwinvar()
- v9.CheckDefAndScriptFailure(['settabwinvar("a", 2, "c", true)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['settabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['settabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['settabwinvar("a", 2, "c", true)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['settabwinvar(1, "b", "c", [])'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['settabwinvar(1, 1, 3, {})'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
assert_fails('settabwinvar(1, 1, "", 10)', 'E461: Illegal variable name')
enddef
def Test_settagstack()
- v9.CheckDefAndScriptFailure(['settagstack(true, {})'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['settagstack(1, [1])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
- v9.CheckDefAndScriptFailure(['settagstack(1, {}, 2)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['settagstack(true, {})'], ['E1013: Argument 1: type mismatch, expected number but got bool', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['settagstack(1, [1])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['settagstack(1, {}, 2)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
assert_fails('settagstack(1, {}, "")', 'E962: Invalid action')
enddef
def Test_setwinvar()
- v9.CheckDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['setwinvar("a", "b", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['setwinvar(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
assert_fails('setwinvar(1, "", 10)', 'E461: Illegal variable name')
assert_fails('setwinvar(0, "&rulerformat", true)', ['E928:', 'E928:'])
enddef
def Test_sha256()
- v9.CheckDefAndScriptFailure(['sha256(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['sha256(0zABCD)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sha256(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sha256(0zABCD)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
assert_equal('ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad', sha256('abc'))
assert_equal('e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855', sha256(''))
enddef
def Test_shiftwidth()
- v9.CheckDefAndScriptFailure(['shiftwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['shiftwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_sign_define()
- v9.CheckDefAndScriptFailure(['sign_define({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_define({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_define("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['sign_define({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_define({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_define("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_sign_getdefined()
- v9.CheckDefAndScriptFailure(['sign_getdefined(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_getdefined(2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_getdefined(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_getdefined(2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
sign_getdefined('')->assert_equal([])
enddef
def Test_sign_getplaced()
- v9.CheckDefAndScriptFailure(['sign_getplaced(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_getplaced(1, ["a"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
- v9.CheckDefAndScriptFailure(['sign_getplaced("a", 1.1)'], ['E1013: Argument 2: type mismatch, expected dict<any> but got float', 'E1206: Dictionary required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['sign_getplaced(bufnr(), {lnum: ""})'], 'E1030: Using a String as a Number:')
+ v9.CheckSourceDefAndScriptFailure(['sign_getplaced(["x"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_getplaced(1, ["a"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['sign_getplaced("a", 1.1)'], ['E1013: Argument 2: type mismatch, expected dict<any> but got float', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['sign_getplaced(bufnr(), {lnum: ""})'], 'E1030: Using a String as a Number:')
sign_getplaced('')->assert_equal([{signs: [], bufnr: bufnr()}])
enddef
def Test_sign_jump()
- v9.CheckDefAndScriptFailure(['sign_jump("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_jump(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['sign_jump(1, "b", true)'], ['E1013: Argument 3: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['sign_jump("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_jump(1, 2, 3)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['sign_jump(1, "b", true)'], ['E1013: Argument 3: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 3'])
enddef
def Test_sign_place()
- v9.CheckDefAndScriptFailure(['sign_place("a", "b", "c", "d")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_place(1, 2, "c", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['sign_place(1, "b", 3, "d")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
- v9.CheckDefAndScriptFailure(['sign_place(1, "b", "c", 1.1)'], ['E1013: Argument 4: type mismatch, expected string but got float', 'E1220: String or Number required for argument 4'])
- v9.CheckDefAndScriptFailure(['sign_place(1, "b", "c", "d", [1])'], ['E1013: Argument 5: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 5'])
- v9.CheckDefExecAndScriptFailure(['sign_place(0, "", "MySign", bufnr(), {lnum: ""})'], 'E1209: Invalid value for a line number: ""')
+ v9.CheckSourceDefAndScriptFailure(['sign_place("a", "b", "c", "d")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_place(1, 2, "c", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['sign_place(1, "b", 3, "d")'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['sign_place(1, "b", "c", 1.1)'], ['E1013: Argument 4: type mismatch, expected string but got float', 'E1220: String or Number required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['sign_place(1, "b", "c", "d", [1])'], ['E1013: Argument 5: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 5'])
+ v9.CheckSourceDefExecAndScriptFailure(['sign_place(0, "", "MySign", bufnr(), {lnum: ""})'], 'E1209: Invalid value for a line number: ""')
assert_fails("sign_place(0, '', '', '')", 'E155:')
enddef
def Test_sign_placelist()
- v9.CheckDefAndScriptFailure(['sign_placelist("x")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_placelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['sign_placelist([{"name": "MySign", "buffer": bufnr(), "lnum": ""}])'], 'E1209: Invalid value for a line number: ""')
+ v9.CheckSourceDefAndScriptFailure(['sign_placelist("x")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_placelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['sign_placelist([{"name": "MySign", "buffer": bufnr(), "lnum": ""}])'], 'E1209: Invalid value for a line number: ""')
assert_fails('sign_placelist([{name: "MySign", buffer: "", lnum: 1}])', 'E155:')
enddef
def Test_sign_undefine()
- v9.CheckDefAndScriptFailure(['sign_undefine({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_undefine([1])'], ['E1013: Argument 1: type mismatch, expected list<string> but got list<number>', 'E155: Unknown sign:'])
+ v9.CheckSourceDefAndScriptFailure(['sign_undefine({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_undefine([1])'], ['E1013: Argument 1: type mismatch, expected list<string> but got list<number>', 'E155: Unknown sign:'])
enddef
def Test_sign_unplace()
- v9.CheckDefAndScriptFailure(['sign_unplace({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_unplace({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_unplace("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['sign_unplace({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_unplace({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_unplace("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
enddef
def Test_sign_unplacelist()
- v9.CheckDefAndScriptFailure(['sign_unplacelist("x")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['sign_unplacelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_unplacelist("x")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sign_unplacelist({"a": 10})'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
enddef
def Test_simplify()
- v9.CheckDefAndScriptFailure(['simplify(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['simplify(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
call assert_equal('NonExistingFile', simplify('NonExistingFile'))
simplify('')->assert_equal('')
enddef
@@ -4105,9 +4105,9 @@ def Test_slice()
assert_equal(['val'], lds->slice(0, 1)->map((_, v) => 'val'))
assert_equal(['val'], lds[ : ]->map((_, v) => 'val'))
- v9.CheckDefAndScriptFailure(['slice({"a": 10}, 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['slice([1, 2, 3], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['slice("abc", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['slice({"a": 10}, 1)'], ['E1013: Argument 1: type mismatch, expected list<any> but got dict<number>', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['slice([1, 2, 3], "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['slice("abc", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
enddef
def Test_spellsuggest()
@@ -4116,29 +4116,29 @@ def Test_spellsuggest()
else
spellsuggest('marrch', 1, true)->assert_equal(['March'])
endif
- v9.CheckDefAndScriptFailure(['spellsuggest(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['spellsuggest("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['spellsuggest("a", 1, 0z01)'], ['E1013: Argument 3: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['spellsuggest(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['spellsuggest("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['spellsuggest("a", 1, 0z01)'], ['E1013: Argument 3: type mismatch, expected bool but got blob', 'E1212: Bool required for argument 3'])
spellsuggest('')->assert_equal([])
enddef
def Test_sound_playevent()
CheckFeature sound
- v9.CheckDefAndScriptFailure(['sound_playevent(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sound_playevent(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
enddef
def Test_sound_playfile()
CheckFeature sound
- v9.CheckDefAndScriptFailure(['sound_playfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sound_playfile(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
enddef
def Test_sound_stop()
CheckFeature sound
- v9.CheckDefAndScriptFailure(['sound_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sound_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_soundfold()
- v9.CheckDefAndScriptFailure(['soundfold(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['soundfold(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal('abc', soundfold('abc'))
assert_equal('', soundfold(''))
enddef
@@ -4160,12 +4160,12 @@ def Test_sort_argument()
sort(l, Compare)
assert_equal([1, 2, 3, 4, 5, 6, 7, 8], l)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
sort([1, 2, 3], (a: any, b: any) => 1)
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
vim9script
@@ -4176,7 +4176,7 @@ def Test_sort_argument()
enddef
SortedList()->assert_equal([1, 2, 3])
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
enddef
def Test_sort_const()
@@ -4184,12 +4184,12 @@ def Test_sort_const()
const l = [1, 2, 3, 4]
sort(l)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
enddef
def Test_sort_compare_func_fails()
- v9.CheckDefAndScriptFailure(['sort("a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['sort([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['sort("a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['sort([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
var lines =<< trim END
vim9script
@@ -4202,31 +4202,31 @@ def Test_sort_compare_func_fails()
var l = [1, 2, 3]
sort(l, (a: string, b: number) => 1)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(string, number): number', 'E1013: Argument 1: type mismatch, expected string but got number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(string, number): number', 'E1013: Argument 1: type mismatch, expected string but got number'])
lines =<< trim END
var l = ['a', 'b', 'c']
sort(l, (a: string, b: number) => 1)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?string): number but got func(string, number): number', 'E1013: Argument 2: type mismatch, expected number but got string'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?string, ?string): number but got func(string, number): number', 'E1013: Argument 2: type mismatch, expected number but got string'])
lines =<< trim END
sort([1, 2, 3], (a: number, b: number) => true)
END
- v9.CheckDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, number): bool', 'E1138: Using a Bool as a Number'])
+ v9.CheckSourceDefAndScriptFailure(lines, ['E1013: Argument 2: type mismatch, expected func(?number, ?number): number but got func(number, number): bool', 'E1138: Using a Bool as a Number'])
enddef
def Test_spellbadword()
- v9.CheckDefAndScriptFailure(['spellbadword(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['spellbadword(100)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
spellbadword('good')->assert_equal(['', ''])
spellbadword('')->assert_equal(['', ''])
enddef
def Test_split()
split(' aa bb ', '\W\+', true)->assert_equal(['', 'aa', 'bb', ''])
- v9.CheckDefAndScriptFailure(['split(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['split("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['split("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['split(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['split("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['split("a", "b", 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
split('')->assert_equal([])
split('', '')->assert_equal([])
enddef
@@ -4235,12 +4235,12 @@ def Test_srand()
var expected = srand()->len()->range()->map((_, _) => 'x')
assert_equal(expected, srand()->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['srand("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['srand("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
type(srand(100))->assert_equal(v:t_list)
enddef
def Test_state()
- v9.CheckDefAndScriptFailure(['state({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['state({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
assert_equal('', state('a'))
enddef
@@ -4249,14 +4249,14 @@ def Test_str2float()
str2float("2e-2")->assert_equal(0.02)
str2float('')->assert_equal(0.0)
- v9.CheckDefAndScriptFailure(['str2float(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['str2float(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
enddef
def Test_str2list()
assert_equal(['x', 'x', 'x'], str2list('abc')->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['str2list(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['str2list("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['str2list(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['str2list("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
assert_equal([97], str2list('a'))
assert_equal([97], str2list('a', 1))
assert_equal([97], str2list('a', true))
@@ -4267,29 +4267,29 @@ def Test_str2nr()
str2nr("1'000'000", 10, true)->assert_equal(1000000)
str2nr('')->assert_equal(0)
- v9.CheckDefAndScriptFailure(['str2nr(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['str2nr("123", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['str2nr("123", 10, "x")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['str2nr(123)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['str2nr("123", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['str2nr("123", 10, "x")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
enddef
def Test_strcharlen()
- v9.CheckDefAndScriptFailure(['strcharlen([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strcharlen([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
"abc"->strcharlen()->assert_equal(3)
strcharlen(99)->assert_equal(2)
enddef
def Test_strcharpart()
- v9.CheckDefAndScriptFailure(['strcharpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strcharpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['strcharpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['strcharpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['strcharpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strcharpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strcharpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['strcharpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
strcharpart('', 0)->assert_equal('')
enddef
def Test_strchars()
strchars("A\u20dd", true)->assert_equal(1)
- v9.CheckDefAndScriptFailure(['strchars(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strchars("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strchars(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strchars("a", 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
assert_equal(3, strchars('abc'))
assert_equal(3, strchars('abc', 1))
assert_equal(3, strchars('abc', true))
@@ -4297,46 +4297,46 @@ def Test_strchars()
enddef
def Test_strdisplaywidth()
- v9.CheckDefAndScriptFailure(['strdisplaywidth(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strdisplaywidth("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strdisplaywidth(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strdisplaywidth("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
strdisplaywidth('')->assert_equal(0)
enddef
def Test_strftime()
if exists('*strftime')
- v9.CheckDefAndScriptFailure(['strftime(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strftime("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strftime(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strftime("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
strftime('')->assert_equal('')
endif
enddef
def Test_strgetchar()
- v9.CheckDefAndScriptFailure(['strgetchar(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strgetchar("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strgetchar(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strgetchar("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
strgetchar('', 0)->assert_equal(-1)
strgetchar('', 1)->assert_equal(-1)
enddef
def Test_stridx()
- v9.CheckDefAndScriptFailure(['stridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['stridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['stridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['stridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['stridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['stridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
stridx('', '')->assert_equal(0)
stridx('', 'a')->assert_equal(-1)
stridx('a', '')->assert_equal(0)
enddef
def Test_strlen()
- v9.CheckDefAndScriptFailure(['strlen([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strlen([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
"abc"->strlen()->assert_equal(3)
strlen(99)->assert_equal(2)
enddef
def Test_strpart()
- v9.CheckDefAndScriptFailure(['strpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['strpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
- v9.CheckDefAndScriptFailure(['strpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['strpart(1, 2)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strpart("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strpart("a", 1, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['strpart("a", 1, 1, 2)'], ['E1013: Argument 4: type mismatch, expected bool but got number', 'E1212: Bool required for argument 4'])
strpart('', 0)->assert_equal('')
enddef
@@ -4344,8 +4344,8 @@ def Test_strptime()
CheckFunction strptime
CheckNotBSD
if exists_compiled('*strptime')
- v9.CheckDefAndScriptFailure(['strptime(10, "2021")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strptime("%Y", 2021)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strptime(10, "2021")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strptime("%Y", 2021)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
assert_notequal(0, strptime('%Y', '2021'))
# This fails on BSD 14 and returns
# -2209078800 instead of 0
@@ -4354,30 +4354,30 @@ def Test_strptime()
enddef
def Test_strridx()
- v9.CheckDefAndScriptFailure(['strridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['strridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['strridx([1], "b")'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strridx("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strridx("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
strridx('', '')->assert_equal(0)
strridx('', 'a')->assert_equal(-1)
strridx('a', '')->assert_equal(1)
enddef
def Test_strtrans()
- v9.CheckDefAndScriptFailure(['strtrans(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strtrans(20)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal('abc', strtrans('abc'))
strtrans('')->assert_equal('')
enddef
def Test_strutf16len()
- v9.CheckDefAndScriptFailure(['strutf16len([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['strutf16len("a", "")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['strutf16len([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strutf16len("a", "")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
""->strutf16len()->assert_equal(0)
'-ą́-ą́'->strutf16len(true)->assert_equal(8)
'-ą́-ą́'->strutf16len(false)->assert_equal(4)
enddef
def Test_strwidth()
- v9.CheckDefAndScriptFailure(['strwidth(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['strwidth(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal(4, strwidth('abcd'))
strwidth('')->assert_equal(0)
enddef
@@ -4388,8 +4388,8 @@ def Test_submatch()
var actual = substitute('A123456789', pat, Rep, '')
var expected = "[['A123456789'], ['1'], ['2'], ['3'], ['4'], ['5'], ['6'], ['7'], ['8'], ['9']]"
actual->assert_equal(expected)
- v9.CheckDefAndScriptFailure(['submatch("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['submatch(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['submatch("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['submatch(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
enddef
def Test_substitute()
@@ -4400,30 +4400,30 @@ def Test_substitute()
assert_fails('"text"->substitute(".*", () => test_null_job(), "")', 'E908: Using an invalid value as a String: job')
assert_fails('"text"->substitute(".*", () => test_null_channel(), "")', 'E908: Using an invalid value as a String: channel')
endif
- v9.CheckDefAndScriptFailure(['substitute(1, "b", "1", "d")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['substitute("a", 2, "1", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['substitute("a", "b", "1", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['substitute(1, "b", "1", "d")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['substitute("a", 2, "1", "d")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['substitute("a", "b", "1", 4)'], ['E1013: Argument 4: type mismatch, expected string but got number', 'E1174: String required for argument 4'])
substitute('', '', '', '')->assert_equal('')
var lines =<< trim END
assert_equal("4", substitute("3", '\d', '\=str2nr(submatch(0)) + 1', 'g'))
END
- v9.CheckDefAndScriptSuccess(lines)
+ v9.CheckSourceDefAndScriptSuccess(lines)
lines =<< trim END
assert_equal("4", substitute("3", '\d', '\="text" x', 'g'))
END
- v9.CheckDefAndScriptFailure(lines, 'E488: Trailing characters: x')
+ v9.CheckSourceDefAndScriptFailure(lines, 'E488: Trailing characters: x')
enddef
def Test_swapinfo()
- v9.CheckDefAndScriptFailure(['swapinfo({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['swapinfo({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1174: String required for argument 1'])
call swapinfo('x')->assert_equal({error: 'Cannot open file'})
call swapinfo('')->assert_equal({error: 'Cannot open file'})
enddef
def Test_swapname()
- v9.CheckDefAndScriptFailure(['swapname([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['swapname([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
assert_fails('swapname("NonExistingBuf")', 'E94:')
enddef
@@ -4432,46 +4432,46 @@ def Test_synID()
setline(1, "text")
synID(1, 1, true)->assert_equal(0)
bwipe!
- v9.CheckDefAndScriptFailure(['synID(0z10, 1, true)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['synID("a", true, false)'], ['E1013: Argument 2: type mismatch, expected number but got bool', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['synID(1, 1, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['synID("", 10, true)'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['synID(0z10, 1, true)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['synID("a", true, false)'], ['E1013: Argument 2: type mismatch, expected number but got bool', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['synID(1, 1, 2)'], ['E1013: Argument 3: type mismatch, expected bool but got number', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['synID("", 10, true)'], 'E1209: Invalid value for a line number')
enddef
def Test_synIDattr()
- v9.CheckDefAndScriptFailure(['synIDattr("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['synIDattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['synIDattr(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['synIDattr("a", "b")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['synIDattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['synIDattr(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
synIDattr(1, '', '')->assert_equal('')
enddef
def Test_synIDtrans()
- v9.CheckDefAndScriptFailure(['synIDtrans("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['synIDtrans("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_synconcealed()
- v9.CheckDefAndScriptFailure(['synconcealed(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['synconcealed(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['synconcealed(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['synconcealed(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
if has('conceal')
- v9.CheckDefExecAndScriptFailure(['synconcealed("", 4)'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefExecAndScriptFailure(['synconcealed("", 4)'], 'E1209: Invalid value for a line number')
endif
enddef
def Test_synstack()
- v9.CheckDefAndScriptFailure(['synstack(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['synstack(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['synstack("", 4)'], 'E1209: Invalid value for a line number')
+ v9.CheckSourceDefAndScriptFailure(['synstack(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['synstack(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['synstack("", 4)'], 'E1209: Invalid value for a line number')
enddef
def Test_system()
- v9.CheckDefAndScriptFailure(['system(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['system("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1224: String, Number or List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['system(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['system("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1224: String, Number or List required for argument 2'])
assert_equal("123\n", system('echo 123'))
enddef
def Test_systemlist()
- v9.CheckDefAndScriptFailure(['systemlist(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['systemlist("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1224: String, Number or List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['systemlist(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['systemlist("a", {})'], ['E1013: Argument 2: type mismatch, expected string but got dict<any>', 'E1224: String, Number or List required for argument 2'])
if has('win32')
call assert_equal(["123\r"], systemlist('echo 123'))
else
@@ -4480,106 +4480,106 @@ def Test_systemlist()
enddef
def Test_tabpagebuflist()
- v9.CheckDefAndScriptFailure(['tabpagebuflist("t")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['tabpagebuflist("t")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
assert_equal([bufnr('')], tabpagebuflist())
assert_equal([bufnr('')], tabpagebuflist(1))
assert_equal(['x'], tabpagebuflist()->map((_, _) => 'x'))
enddef
def Test_tabpagenr()
- v9.CheckDefAndScriptFailure(['tabpagenr(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['tabpagenr("")'], 'E15: Invalid expression')
+ v9.CheckSourceDefAndScriptFailure(['tabpagenr(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['tabpagenr("")'], 'E15: Invalid expression')
assert_equal(1, tabpagenr('$'))
assert_equal(1, tabpagenr())
enddef
def Test_tabpagewinnr()
- v9.CheckDefAndScriptFailure(['tabpagewinnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['tabpagewinnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['tabpagewinnr(1, "")'], 'E15: Invalid expression')
+ v9.CheckSourceDefAndScriptFailure(['tabpagewinnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['tabpagewinnr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['tabpagewinnr(1, "")'], 'E15: Invalid expression')
enddef
def Test_taglist()
- v9.CheckDefAndScriptFailure(['taglist([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['taglist("a", [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['taglist([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['taglist("a", [2])'], ['E1013: Argument 2: type mismatch, expected string but got list<number>', 'E1174: String required for argument 2'])
taglist('')->assert_equal(0)
taglist('', '')->assert_equal(0)
enddef
def Test_term_dumpload()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_dumpload({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_dumpload({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_dumpload("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['term_dumpload("")'], 'E485: Can''t read file')
+ v9.CheckSourceDefAndScriptFailure(['term_dumpload({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_dumpload({"a": 10}, "b")'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_dumpload("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<string>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['term_dumpload("")'], 'E485: Can''t read file')
enddef
def Test_term_dumpdiff()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_dumpdiff(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_dumpdiff("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['term_dumpdiff("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['term_dumpdiff("", "")'], 'E485: Can''t read file')
+ v9.CheckSourceDefAndScriptFailure(['term_dumpdiff(1, "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_dumpdiff("a", 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_dumpdiff("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['term_dumpdiff("", "")'], 'E485: Can''t read file')
enddef
def Test_term_dumpwrite()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_dumpwrite(true, "b")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_dumpwrite(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['term_dumpwrite("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['term_dumpwrite(true, "b")'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_dumpwrite(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_dumpwrite("a", "b", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
enddef
def Test_term_getaltscreen()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getaltscreen(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getaltscreen(true)'], ['E1013: Argument 1: type mismatch, expected string but got bool', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_getansicolors()
CheckRunVimInTerminal
CheckFeature termguicolors
- v9.CheckDefAndScriptFailure(['term_getansicolors(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getansicolors(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_getattr()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getattr("x", "a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_getattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_getattr("x", "a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getattr(1, 2)'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
enddef
def Test_term_getcursor()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getcursor({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getcursor({"a": 10})'], ['E1013: Argument 1: type mismatch, expected string but got dict<number>', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_getjob()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getjob(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getjob(0z10)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_getline()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getline(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_getline(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_getline(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getline(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2'])
enddef
def Test_term_getscrolled()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getscrolled(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getscrolled(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_getsize()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getsize(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getsize(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_getstatus()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_getstatus(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_getstatus(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_gettitle()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_gettitle(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_gettitle(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
enddef
def Test_term_gettty()
@@ -4590,28 +4590,28 @@ def Test_term_gettty()
term_gettty(buf, true)->assert_notequal('')
g:StopShellInTerminal(buf)
endif
- v9.CheckDefAndScriptFailure(['term_gettty([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_gettty(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_gettty([1])'], ['E1013: Argument 1: type mismatch, expected string but got list<number>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_gettty(1, 2)'], ['E1013: Argument 2: type mismatch, expected bool but got number', 'E1212: Bool required for argument 2'])
enddef
def Test_term_scrape()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_scrape(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_scrape(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_scrape(1.1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_scrape(1, 1.1)'], ['E1013: Argument 2: type mismatch, expected string but got float', 'E1220: String or Number required for argument 2'])
enddef
def Test_term_sendkeys()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_sendkeys([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_sendkeys(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_sendkeys([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_sendkeys(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
enddef
def Test_term_setansicolors()
CheckRunVimInTerminal
if has('termguicolors') || has('gui')
- v9.CheckDefAndScriptFailure(['term_setansicolors([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_setansicolors(10, {})'], ['E1013: Argument 2: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_setansicolors([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_setansicolors(10, {})'], ['E1013: Argument 2: type mismatch, expected list<any> but got dict<any>', 'E1211: List required for argument 2'])
else
throw 'Skipped: Only works with termguicolors or gui feature'
endif
@@ -4619,27 +4619,27 @@ enddef
def Test_term_setapi()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_setapi([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_setapi(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_setapi([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_setapi(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
enddef
def Test_term_setkill()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_setkill([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_setkill(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_setkill([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_setkill(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
enddef
def Test_term_setrestore()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_setrestore([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_setrestore(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_setrestore([], "p")'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_setrestore(1, [])'], ['E1013: Argument 2: type mismatch, expected string but got list<any>', 'E1174: String required for argument 2'])
enddef
def Test_term_setsize()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_setsize(1.1, 2, 3)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_setsize(1, "2", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['term_setsize(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['term_setsize(1.1, 2, 3)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_setsize(1, "2", 3)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_setsize(1, 2, "3")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
enddef
def Test_term_start()
@@ -4652,76 +4652,76 @@ def Test_term_start()
winnr()->assert_equal(winnr)
bwipe!
endif
- v9.CheckDefAndScriptFailure(['term_start({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_start([], [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
- v9.CheckDefAndScriptFailure(['term_start("", "")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
- v9.CheckDefExecAndScriptFailure(['term_start("")'], 'E474: Invalid argument')
+ v9.CheckSourceDefAndScriptFailure(['term_start({})'], ['E1013: Argument 1: type mismatch, expected string but got dict<any>', 'E1222: String or List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_start([], [])'], ['E1013: Argument 2: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_start("", "")'], ['E1013: Argument 2: type mismatch, expected dict<any> but got string', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefExecAndScriptFailure(['term_start("")'], 'E474: Invalid argument')
enddef
def Test_term_wait()
CheckRunVimInTerminal
- v9.CheckDefAndScriptFailure(['term_wait(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['term_wait(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['term_wait(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1220: String or Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['term_wait(1, "a")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_test_alloc_fail()
- v9.CheckDefAndScriptFailure(['test_alloc_fail("a", 10, 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['test_alloc_fail(10, "b", 20)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['test_alloc_fail(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['test_alloc_fail("a", 10, 20)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_alloc_fail(10, "b", 20)'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['test_alloc_fail(10, 20, "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
enddef
def Test_test_feedinput()
- v9.CheckDefAndScriptFailure(['test_feedinput(test_void())'], ['E1013: Argument 1: type mismatch, expected string but got void', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['test_feedinput(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_feedinput(test_void())'], ['E1013: Argument 1: type mismatch, expected string but got void', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_feedinput(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
enddef
def Test_test_getvalue()
- v9.CheckDefAndScriptFailure(['test_getvalue(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_getvalue(1.1)'], ['E1013: Argument 1: type mismatch, expected string but got float', 'E1174: String required for argument 1'])
enddef
def Test_test_gui_event()
CheckGui
- v9.CheckDefAndScriptFailure(['test_gui_event([], {})'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['test_gui_event("abc", 1)'], ['E1013: Argument 2: type mismatch, expected dict<any> but got number', 'E1206: Dictionary required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['test_gui_event([], {})'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_gui_event("abc", 1)'], ['E1013: Argument 2: type mismatch, expected dict<any> but got number', 'E1206: Dictionary required for argument 2'])
enddef
def Test_test_ignore_error()
- v9.CheckDefAndScriptFailure(['test_ignore_error([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_ignore_error([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
test_ignore_error('RESET')
enddef
def Test_test_option_not_set()
- v9.CheckDefAndScriptFailure(['test_option_not_set([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_option_not_set([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
enddef
def Test_test_override()
- v9.CheckDefAndScriptFailure(['test_override(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['test_override("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['test_override(1, 1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_override("a", "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_test_setmouse()
- v9.CheckDefAndScriptFailure(['test_setmouse("a", 10)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['test_setmouse(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['test_setmouse("a", 10)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_setmouse(10, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_test_settime()
- v9.CheckDefAndScriptFailure(['test_settime([1])'], ['E1013: Argument 1: type mismatch, expected number but got list<number>', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_settime([1])'], ['E1013: Argument 1: type mismatch, expected number but got list<number>', 'E1210: Number required for argument 1'])
enddef
def Test_test_srand_seed()
- v9.CheckDefAndScriptFailure(['test_srand_seed([1])'], ['E1013: Argument 1: type mismatch, expected number but got list<number>', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['test_srand_seed("10")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_srand_seed([1])'], ['E1013: Argument 1: type mismatch, expected number but got list<number>', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['test_srand_seed("10")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_timer_info()
- v9.CheckDefAndScriptFailure(['timer_info("id")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['timer_info("id")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
assert_equal([], timer_info(100))
assert_equal([], timer_info()->filter((_, t) => t.callback->string() !~ 'TestTimeout'))
enddef
def Test_timer_pause()
- v9.CheckDefAndScriptFailure(['timer_pause("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['timer_pause(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['timer_pause("x", 1)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['timer_pause(1, "a")'], ['E1013: Argument 2: type mismatch, expected bool but got string', 'E1212: Bool required for argument 2'])
enddef
def Test_timer_paused()
@@ -4733,31 +4733,31 @@ def Test_timer_paused()
enddef
def Test_timer_start()
- v9.CheckDefAndScriptFailure(['timer_start("a", "1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['timer_start(1, "1", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['timer_start(100, 0)'], 'E921:')
- v9.CheckDefExecAndScriptFailure(['timer_start(100, "")'], 'E921:')
+ v9.CheckSourceDefAndScriptFailure(['timer_start("a", "1")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['timer_start(1, "1", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefExecAndScriptFailure(['timer_start(100, 0)'], 'E921:')
+ v9.CheckSourceDefExecAndScriptFailure(['timer_start(100, "")'], 'E921:')
enddef
def Test_timer_stop()
- v9.CheckDefAndScriptFailure(['timer_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['timer_stop("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
assert_equal(0, timer_stop(100))
enddef
def Test_tolower()
- v9.CheckDefAndScriptFailure(['tolower(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['tolower(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
tolower('')->assert_equal('')
enddef
def Test_toupper()
- v9.CheckDefAndScriptFailure(['toupper(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['toupper(1)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
toupper('')->assert_equal('')
enddef
def Test_tr()
- v9.CheckDefAndScriptFailure(['tr(1, "a", "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['tr("a", 1, "b")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['tr("a", "a", 1)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['tr(1, "a", "b")'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['tr("a", 1, "b")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['tr("a", "a", 1)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
tr('', '', '')->assert_equal('')
tr('ab', '', '')->assert_equal('ab')
assert_fails("tr('ab', 'ab', '')", 'E475:')
@@ -4765,9 +4765,9 @@ def Test_tr()
enddef
def Test_trim()
- v9.CheckDefAndScriptFailure(['trim(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['trim("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected string but got list<string>', 'E1174: String required for argument 2'])
- v9.CheckDefAndScriptFailure(['trim("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['trim(["a"])'], ['E1013: Argument 1: type mismatch, expected string but got list<string>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['trim("a", ["b"])'], ['E1013: Argument 2: type mismatch, expected string but got list<string>', 'E1174: String required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['trim("a", "b", "c")'], ['E1013: Argument 3: type mismatch, expected number but got string', 'E1210: Number required for argument 3'])
trim('')->assert_equal('')
trim('', '')->assert_equal('')
enddef
@@ -4783,26 +4783,30 @@ def Test_typename()
if has('channel')
assert_equal('channel', test_null_channel()->typename())
endif
+ assert_equal('class<Unknown>', typename(null_class))
+ assert_equal('object<Unknown>', typename(null_object))
+ var l: list<func(list<number>): number> = [function('min')]
+ assert_equal('list<func(list<number>): number>', typename(l))
enddef
def Test_undofile()
- v9.CheckDefAndScriptFailure(['undofile(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['undofile(10)'], ['E1013: Argument 1: type mismatch, expected string but got number', 'E1174: String required for argument 1'])
assert_equal('.abc.un~', fnamemodify(undofile('abc'), ':t'))
undofile('')->assert_equal('')
enddef
def Test_uniq()
- v9.CheckDefAndScriptFailure(['uniq("a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
- v9.CheckDefAndScriptFailure(['uniq([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['uniq("a")'], ['E1013: Argument 1: type mismatch, expected list<any> but got string', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['uniq([1], "", [1])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<number>', 'E1206: Dictionary required for argument 3'])
- v9.CheckDefFailure(['var l: list<number> = uniq(["a", "b"])'], 'E1012: Type mismatch; expected list<number> but got list<string>')
+ v9.CheckSourceDefFailure(['var l: list<number> = uniq(["a", "b"])'], 'E1012: Type mismatch; expected list<number> but got list<string>')
enddef
def Test_utf16idx()
- v9.CheckDefAndScriptFailure(['utf16idx(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
- v9.CheckDefAndScriptFailure(['utf16idx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['utf16idx("a", 1, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
- v9.CheckDefAndScriptFailure(['utf16idx("a", 1, 0, "")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4'])
+ v9.CheckSourceDefAndScriptFailure(['utf16idx(0z10, 1)'], ['E1013: Argument 1: type mismatch, expected string but got blob', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['utf16idx("a", "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['utf16idx("a", 1, "")'], ['E1013: Argument 3: type mismatch, expected bool but got string', 'E1212: Bool required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['utf16idx("a", 1, 0, "")'], ['E1013: Argument 4: type mismatch, expected bool but got string', 'E1212: Bool required for argument 4'])
utf16idx('', 0)->assert_equal(0)
utf16idx('', 1)->assert_equal(-1)
enddef
@@ -4812,11 +4816,11 @@ def Test_uniq_const()
const l = [1, 2, 3, 4]
uniq(l)
END
- v9.CheckDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
+ v9.CheckSourceDefFailure(lines, 'E1307: Argument 1: Trying to modify a const list<number>')
enddef
def Test_values()
- v9.CheckDefAndScriptFailure(['values([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['values([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
assert_equal([], {}->values())
assert_equal(['sun'], {star: 'sun'}->values())
@@ -4843,20 +4847,20 @@ def Test_values()
Process(D)
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
enddef
def Test_virtcol()
- v9.CheckDefAndScriptFailure(['virtcol(1.1)'], [
+ v9.CheckSourceDefAndScriptFailure(['virtcol(1.1)'], [
'E1013: Argument 1: type mismatch, expected string but got float',
'E1222: String or List required for argument 1'])
- v9.CheckDefAndScriptFailure(['virtcol(".", "a")'], [
+ v9.CheckSourceDefAndScriptFailure(['virtcol(".", "a")'], [
'E1013: Argument 2: type mismatch, expected bool but got string',
'E1212: Bool required for argument 2'])
- v9.CheckDefAndScriptFailure(['virtcol(".", v:true, [])'], [
+ v9.CheckSourceDefAndScriptFailure(['virtcol(".", v:true, [])'], [
'E1013: Argument 3: type mismatch, expected number but got list',
'E1210: Number required for argument 3'])
- v9.CheckDefExecAndScriptFailure(['virtcol("")'],
+ v9.CheckSourceDefExecAndScriptFailure(['virtcol("")'],
'E1209: Invalid value for a line number')
new
setline(1, ['abcde和平fgh'])
@@ -4872,8 +4876,8 @@ def Test_virtcol()
enddef
def Test_visualmode()
- v9.CheckDefAndScriptFailure(['visualmode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
- v9.CheckDefAndScriptFailure(['visualmode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['visualmode("1")'], ['E1013: Argument 1: type mismatch, expected bool but got string', 'E1212: Bool required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['visualmode(2)'], ['E1013: Argument 1: type mismatch, expected bool but got number', 'E1212: Bool required for argument 1'])
enddef
def Test_win_execute()
@@ -4881,29 +4885,29 @@ def Test_win_execute()
assert_equal("\n" .. winnr(), 'echo winnr()'->win_execute(win_getid()))
assert_equal("\n" .. winnr(), win_execute(win_getid(), 'echo winnr()', 'silent'))
assert_equal('', win_execute(342343, 'echo winnr()'))
- v9.CheckDefAndScriptFailure(['win_execute("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['win_execute(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2'])
- v9.CheckDefAndScriptFailure(['win_execute(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['win_execute("a", "b", "c")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_execute(1, 2, "c")'], ['E1013: Argument 2: type mismatch, expected string but got number', 'E1222: String or List required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['win_execute(1, "b", 3)'], ['E1013: Argument 3: type mismatch, expected string but got number', 'E1174: String required for argument 3'])
enddef
def Test_win_findbuf()
- v9.CheckDefAndScriptFailure(['win_findbuf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_findbuf("a")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
assert_equal([], win_findbuf(1000))
assert_equal([win_getid()], win_findbuf(bufnr('')))
enddef
def Test_win_getid()
- v9.CheckDefAndScriptFailure(['win_getid(".")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['win_getid(1, ".")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['win_getid(".")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_getid(1, ".")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
assert_equal(win_getid(), win_getid(1, 1))
enddef
def Test_win_gettype()
- v9.CheckDefAndScriptFailure(['win_gettype("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_gettype("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_win_gotoid()
- v9.CheckDefAndScriptFailure(['win_gotoid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_gotoid("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
func Test_win_gotoid_in_mapping()
@@ -4948,43 +4952,43 @@ func Test_win_gotoid_in_mapping()
endfunc
def Test_win_id2tabwin()
- v9.CheckDefAndScriptFailure(['win_id2tabwin("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_id2tabwin("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_win_id2win()
- v9.CheckDefAndScriptFailure(['win_id2win("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_id2win("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_win_screenpos()
assert_equal(['x', 'x'], win_screenpos(1)->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['win_screenpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_screenpos("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_win_splitmove()
split
win_splitmove(1, 2, {vertical: true, rightbelow: true})
close
- v9.CheckDefAndScriptFailure(['win_splitmove("a", 2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['win_splitmove(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
- v9.CheckDefAndScriptFailure(['win_splitmove(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
+ v9.CheckSourceDefAndScriptFailure(['win_splitmove("a", 2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['win_splitmove(1, "b")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['win_splitmove(1, 2, [])'], ['E1013: Argument 3: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 3'])
enddef
def Test_winbufnr()
- v9.CheckDefAndScriptFailure(['winbufnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['winbufnr("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_winheight()
- v9.CheckDefAndScriptFailure(['winheight("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['winheight("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_winlayout()
- v9.CheckDefAndScriptFailure(['winlayout("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['winlayout("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_winnr()
- v9.CheckDefAndScriptFailure(['winnr([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
- v9.CheckDefExecAndScriptFailure(['winnr("")'], 'E15: Invalid expression')
+ v9.CheckSourceDefAndScriptFailure(['winnr([])'], ['E1013: Argument 1: type mismatch, expected string but got list<any>', 'E1174: String required for argument 1'])
+ v9.CheckSourceDefExecAndScriptFailure(['winnr("")'], 'E15: Invalid expression')
assert_equal(1, winnr())
assert_equal(1, winnr('$'))
enddef
@@ -4999,7 +5003,7 @@ def Test_winrestcmd()
enddef
def Test_winrestview()
- v9.CheckDefAndScriptFailure(['winrestview([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['winrestview([])'], ['E1013: Argument 1: type mismatch, expected dict<any> but got list<any>', 'E1206: Dictionary required for argument 1'])
:%d _
setline(1, 'Hello World')
winrestview({lnum: 1, col: 6})
@@ -5012,20 +5016,20 @@ def Test_winsaveview()
var lines =<< trim END
var view: list<number> = winsaveview()
END
- v9.CheckDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<number> but got dict<number>', 1)
+ v9.CheckSourceDefAndScriptFailure(lines, 'E1012: Type mismatch; expected list<number> but got dict<number>', 1)
enddef
def Test_winwidth()
- v9.CheckDefAndScriptFailure(['winwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['winwidth("x")'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
enddef
def Test_xor()
- v9.CheckDefAndScriptFailure(['xor("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
- v9.CheckDefAndScriptFailure(['xor(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
+ v9.CheckSourceDefAndScriptFailure(['xor("x", 0x2)'], ['E1013: Argument 1: type mismatch, expected number but got string', 'E1210: Number required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['xor(0x1, "x")'], ['E1013: Argument 2: type mismatch, expected number but got string', 'E1210: Number required for argument 2'])
enddef
def Test_writefile()
- v9.CheckDefExecAndScriptFailure(['writefile(["a"], "")'], 'E482: Can''t create file <empty>')
+ v9.CheckSourceDefExecAndScriptFailure(['writefile(["a"], "")'], 'E482: Can''t create file <empty>')
enddef
def Test_passing_type_to_builtin()
@@ -5045,7 +5049,7 @@ def Test_passing_type_to_builtin()
x = string(T)
x = instanceof(C.new(), U, C)
END
- v9.CheckScriptSuccess(lines)
+ v9.CheckSourceScriptSuccess(lines)
# check argument to add at script level
# Note: add() is special cased in compile_call in vim9expr
@@ -5055,7 +5059,7 @@ def Test_passing_type_to_builtin()
endclass
add([], C)
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check argument to add in :def
lines =<< trim END
@@ -5067,7 +5071,7 @@ def Test_passing_type_to_builtin()
enddef
F()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check member call argument to add at script level
lines =<< trim END
@@ -5076,7 +5080,7 @@ def Test_passing_type_to_builtin()
endclass
[]->add(C)
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check member call argument to add in :def
lines =<< trim END
@@ -5088,7 +5092,7 @@ def Test_passing_type_to_builtin()
enddef
F()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# Try "empty()" builtin
# check argument to empty at script level
@@ -5098,7 +5102,7 @@ def Test_passing_type_to_builtin()
endclass
empty(C)
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check argument to empty in :def
lines =<< trim END
@@ -5110,7 +5114,7 @@ def Test_passing_type_to_builtin()
enddef
F()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check member call argument to empty at script level
lines =<< trim END
@@ -5119,7 +5123,7 @@ def Test_passing_type_to_builtin()
endclass
C->empty()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check member call argument to empty in :def
lines =<< trim END
@@ -5131,7 +5135,7 @@ def Test_passing_type_to_builtin()
enddef
F()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# Try "abs()" builtin
# check argument to abs at script level
@@ -5141,7 +5145,7 @@ def Test_passing_type_to_builtin()
endclass
abs(C)
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check argument to abs in :def
lines =<< trim END
@@ -5153,7 +5157,7 @@ def Test_passing_type_to_builtin()
enddef
F()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check member call argument to abs at script level
lines =<< trim END
@@ -5162,7 +5166,7 @@ def Test_passing_type_to_builtin()
endclass
C->abs()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
# check member call argument to abs in :def
lines =<< trim END
@@ -5174,15 +5178,15 @@ def Test_passing_type_to_builtin()
enddef
F()
END
- v9.CheckScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
+ v9.CheckSourceScriptFailure(lines, 'E1405: Class "C" cannot be used as a value')
enddef
def Test_getregion()
assert_equal(['x'], getregion(getpos('.'), getpos('.'))->map((_, _) => 'x'))
- v9.CheckDefAndScriptFailure(['getregion(10, getpos("."))'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1'])
+ v9.CheckSourceDefAndScriptFailure(['getregion(10, getpos("."))'], ['E1013: Argument 1: type mismatch, expected list<any> but got number', 'E1211: List required for argument 1'])
assert_equal([''], getregion(getpos('.'), getpos('.')))
- v9.CheckDefExecFailure(['getregion(getpos("a"), getpos("."))'], 'E1209:')
+ v9.CheckSourceDefExecFailure(['getregion(getpos("a"), getpos("."))'], 'E1209:')
enddef
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index d6c55bf..5957f57 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -400,7 +400,7 @@ def Test_class_def_method()
enddef
endclass
END
- v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "var" or "static"', 3)
+ v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3)
# Using the "public" keyword when defining a class method
lines =<< trim END
@@ -410,7 +410,7 @@ def Test_class_def_method()
enddef
endclass
END
- v9.CheckSourceFailure(lines, 'E1388: Public keyword not supported for a method', 3)
+ v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3)
# Using the "public" keyword when defining an object protected method
lines =<< trim END
@@ -420,7 +420,7 @@ def Test_class_def_method()
enddef
endclass
END
- v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "var" or "static"', 3)
+ v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3)
# Using the "public" keyword when defining a class protected method
lines =<< trim END
@@ -430,7 +430,7 @@ def Test_class_def_method()
enddef
endclass
END
- v9.CheckSourceFailure(lines, 'E1388: Public keyword not supported for a method', 3)
+ v9.CheckSourceFailure(lines, 'E1388: public keyword not supported for a method', 3)
# Using a "def" keyword without an object method name
lines =<< trim END
@@ -1191,7 +1191,7 @@ def Test_instance_variable_access()
public var _val = 10
endclass
END
- v9.CheckSourceFailure(lines, 'E1332: Public variable name cannot start with underscore: public var _val = 10', 3)
+ v9.CheckSourceFailure(lines, 'E1332: public variable name cannot start with underscore: public var _val = 10', 3)
lines =<< trim END
vim9script
@@ -1287,7 +1287,7 @@ def Test_instance_variable_access()
public val = 1
endclass
END
- v9.CheckSourceFailure(lines, 'E1331: Public must be followed by "var" or "static"', 3)
+ v9.CheckSourceFailure(lines, 'E1331: public must be followed by "var" or "static"', 3)
# Modify a instance variable using the class name in the script context
lines =<< trim END
@@ -2275,6 +2275,18 @@ def Test_interface_basics()
v9.CheckScriptSuccess(lines)
enddef
+" Test for using string() with an interface
+def Test_interface_to_string()
+ var lines =<< trim END
+ vim9script
+ interface Intf
+ def Method(nr: number)
+ endinterface
+ assert_equal("interface Intf", string(Intf))
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
def Test_class_implements_interface()
var lines =<< trim END
vim9script
@@ -3109,6 +3121,28 @@ def Test_class_import()
v9.CheckScriptSuccess(lines)
enddef
+" Test for importing a class into a legacy script and calling the class method
+def Test_class_method_from_legacy_script()
+ var lines =<< trim END
+ vim9script
+ export class A
+ static var name: string = 'a'
+ static def SetName(n: string)
+ name = n
+ enddef
+ endclass
+ END
+ writefile(lines, 'Xvim9export.vim', 'D')
+
+ lines =<< trim END
+ import './Xvim9export.vim' as vim9
+
+ call s:vim9.A.SetName('b')
+ call assert_equal('b', s:vim9.A.name)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
" Test for implementing an imported interface
def Test_implement_imported_interface()
var lines =<< trim END
@@ -3208,6 +3242,23 @@ def Test_abstract_class()
endclass
END
v9.CheckSourceFailure(lines, 'E1359: Cannot define a "new" method in an abstract class', 4)
+
+ # extending an abstract class with class methods and variables
+ lines =<< trim END
+ vim9script
+ abstract class A
+ static var s: string = 'vim'
+ static def Fn(): list<number>
+ return [10]
+ enddef
+ endclass
+ class B extends A
+ endclass
+ var b = B.new()
+ assert_equal('vim', A.s)
+ assert_equal([10], A.Fn())
+ END
+ v9.CheckScriptSuccess(lines)
enddef
def Test_closure_in_class()
@@ -3729,7 +3780,7 @@ def Test_stack_expansion_with_methods()
endclass
def F0()
- assert_match('<SNR>\d\+_F\[1\]\.\.C\.M1\[1\]\.\.<SNR>\d\+_F0\[1\]$', expand('<stack>'))
+ assert_match('<SNR>\d\+_F\[1\]\.\.<SNR>\d\+_C\.M1\[1\]\.\.<SNR>\d\+_F0\[1\]$', expand('<stack>'))
enddef
def F()
@@ -6486,7 +6537,7 @@ def Test_interface_with_unsupported_members()
public static var num: number
endinterface
END
- v9.CheckSourceFailure(lines, 'E1387: Public variable not supported in an interface', 3)
+ v9.CheckSourceFailure(lines, 'E1387: public variable not supported in an interface', 3)
lines =<< trim END
vim9script
@@ -6494,7 +6545,7 @@ def Test_interface_with_unsupported_members()
public static var num: number
endinterface
END
- v9.CheckSourceFailure(lines, 'E1387: Public variable not supported in an interface', 3)
+ v9.CheckSourceFailure(lines, 'E1387: public variable not supported in an interface', 3)
lines =<< trim END
vim9script
@@ -10391,6 +10442,23 @@ def Test_compound_op_in_objmethod_lambda()
v9.CheckScriptSuccess(lines)
enddef
+" Test for using test_refcount() with a class and an object
+def Test_class_object_refcount()
+ var lines =<< trim END
+ vim9script
+ class A
+ endclass
+ var a: A = A.new()
+ assert_equal(2, test_refcount(A))
+ assert_equal(1, test_refcount(a))
+ var b = a
+ assert_equal(2, test_refcount(A))
+ assert_equal(2, test_refcount(a))
+ assert_equal(2, test_refcount(b))
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
" call a lambda function in one object from another object
def Test_lambda_invocation_across_classes()
var lines =<< trim END
@@ -10420,4 +10488,154 @@ def Test_lambda_invocation_across_classes()
v9.CheckScriptSuccess(lines)
enddef
+" Test for using a class member which is an object of the current class
+def Test_current_class_object_class_member()
+ var lines =<< trim END
+ vim9script
+ class A
+ public static var obj1: A = A.new(10)
+ var n: number
+ endclass
+ defcompile
+ assert_equal(10, A.obj1.n)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
+" Test for updating a base class variable from a base class method without the
+" class name. This used to crash Vim (Github issue #14352).
+def Test_use_base_class_variable_from_base_class_method()
+ var lines =<< trim END
+ vim9script
+
+ class DictKeyClass
+ static var _obj_id_count = 1
+ def _GenerateKey()
+ _obj_id_count += 1
+ enddef
+ static def GetIdCount(): number
+ return _obj_id_count
+ enddef
+ endclass
+
+ class C extends DictKeyClass
+ def F()
+ this._GenerateKey()
+ enddef
+ endclass
+
+ C.new().F()
+ assert_equal(2, DictKeyClass.GetIdCount())
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
+" Test for accessing protected funcref object and class variables
+def Test_protected_funcref()
+ # protected funcref object variable
+ var lines =<< trim END
+ vim9script
+ class Test1
+ const _Id: func(any): any = (v) => v
+ endclass
+ var n = Test1.new()._Id(1)
+ END
+ v9.CheckScriptFailure(lines, 'E1333: Cannot access protected variable "_Id" in class "Test1"', 5)
+
+ # protected funcref class variable
+ lines =<< trim END
+ vim9script
+ class Test2
+ static const _Id: func(any): any = (v) => v
+ endclass
+ var n = Test2._Id(2)
+ END
+ v9.CheckScriptFailure(lines, 'E1333: Cannot access protected variable "_Id" in class "Test2"', 5)
+enddef
+
+" Test for using lambda block in classes
+def Test_lambda_block_in_class()
+ # This used to crash Vim
+ var lines =<< trim END
+ vim9script
+ class IdClass1
+ const Id: func(number): number = (num: number): number => {
+ # Return a ID
+ return num * 10
+ }
+ endclass
+ var id = IdClass1.new()
+ assert_equal(20, id.Id(2))
+ END
+ v9.CheckScriptSuccess(lines)
+
+ # This used to crash Vim
+ lines =<< trim END
+ vim9script
+ class IdClass2
+ static const Id: func(number): number = (num: number): number => {
+ # Return a ID
+ return num * 2
+ }
+ endclass
+ assert_equal(16, IdClass2.Id(8))
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
+" Test for defcompiling an abstract method
+def Test_abstract_method_defcompile()
+ # Compile an abstract class with abstract object methods
+ var lines =<< trim END
+ vim9script
+ abstract class A
+ abstract def Foo(): string
+ abstract def Bar(): list<string>
+ endclass
+ defcompile
+ END
+ v9.CheckScriptSuccess(lines)
+
+ # Compile a concrete object method in an abstract class
+ lines =<< trim END
+ vim9script
+ abstract class A
+ abstract def Foo(): string
+ abstract def Bar(): list<string>
+ def Baz(): string
+ pass
+ enddef
+ endclass
+ defcompile
+ END
+ v9.CheckScriptFailure(lines, 'E476: Invalid command: pass', 1)
+
+ # Compile a concrete class method in an abstract class
+ lines =<< trim END
+ vim9script
+ abstract class A
+ abstract def Foo(): string
+ abstract def Bar(): list<string>
+ static def Baz(): string
+ pass
+ enddef
+ endclass
+ defcompile
+ END
+ v9.CheckScriptFailure(lines, 'E476: Invalid command: pass', 1)
+enddef
+
+" Test for defining a class in a function
+def Test_class_definition_in_a_function()
+ var lines =<< trim END
+ vim9script
+ def Foo()
+ class A
+ endclass
+ enddef
+ defcompile
+ END
+ v9.CheckScriptFailure(lines, 'E1429: Class can only be used in a script', 1)
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/testdir/test_vim9_disassemble.vim b/src/testdir/test_vim9_disassemble.vim
index 1daef22..c74cce4 100644
--- a/src/testdir/test_vim9_disassemble.vim
+++ b/src/testdir/test_vim9_disassemble.vim
@@ -381,6 +381,34 @@ def Test_disassemble_import_autoload()
v9.CheckScriptSuccess(lines)
enddef
+def Test_disassemble_import_autoload_autoload()
+ mkdir('Xauto_auto/autoload', 'pR')
+ var lines =<< trim END
+ vim9script
+ export const val = 11
+ END
+ writefile(lines, 'Xauto_auto/autoload/Xauto_vars_f1.vim')
+
+ lines =<< trim END
+ vim9script
+
+ import autoload './Xauto_auto/autoload/Xauto_vars_f1.vim' as f1
+ def F()
+ f1.val = 13
+ enddef
+ var res = execute('disass F')
+
+ assert_match('<SNR>\d*_F.*' ..
+ 'f1.val = 13\_s*' ..
+ '\d PUSHNR 13\_s*' ..
+ '\d SOURCE .*/Xauto_auto/autoload/Xauto_vars_f1.vim\_s*' ..
+ '\d STOREEXPORT val in .*/Xauto_auto/autoload/Xauto_vars_f1.vim\_s*' ..
+ '\d RETURN void',
+ res)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
def s:ScriptFuncStore()
var localnr = 1
localnr = 2
@@ -1030,7 +1058,7 @@ def Test_disassemble_closure_in_loop()
'endif\_s*' ..
'g:Ref = () => ii\_s*' ..
- '\d\+ FUNCREF <lambda>4 vars $3-$3\_s*' ..
+ '\d\+ FUNCREF <lambda>\d\+ vars $3-$3\_s*' ..
'\d\+ STOREG g:Ref\_s*' ..
'continue\_s*' ..
diff --git a/src/testdir/test_vim9_enum.vim b/src/testdir/test_vim9_enum.vim
new file mode 100644
index 0000000..274b556
--- /dev/null
+++ b/src/testdir/test_vim9_enum.vim
@@ -0,0 +1,1537 @@
+" Test Vim9 enums
+
+source check.vim
+import './vim9.vim' as v9
+
+" Test for parsing an enum definition
+def Test_enum_parse()
+ # enum supported only in a Vim9 script
+ var lines =<< trim END
+ enum Foo
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1414: Enum can only be defined in Vim9 script', 1)
+
+ # First character in an enum name should be capitalized.
+ lines =<< trim END
+ vim9script
+ enum foo
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1415: Enum name must start with an uppercase letter: foo', 2)
+
+ # Only alphanumeric characters are supported in an enum name
+ lines =<< trim END
+ vim9script
+ enum Foo@bar
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1315: White space required after name: Foo@bar', 2)
+
+ # Unsupported keyword (instead of enum)
+ lines =<< trim END
+ vim9script
+ noenum Something
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E492: Not an editor command: noenum Something', 2)
+
+ # Only the complete word "enum" should be recognized
+ lines =<< trim END
+ vim9script
+ enums Something
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E492: Not an editor command: enums Something', 2)
+
+ # The complete "endenum" should be specified.
+ lines =<< trim END
+ vim9script
+ enum Something
+ enden
+ END
+ v9.CheckSourceFailure(lines, 'E1065: Command cannot be shortened: enden', 3)
+
+ # Only the complete word "endenum" should be recognized
+ lines =<< trim END
+ vim9script
+ enum Something
+ endenums
+ END
+ v9.CheckSourceFailure(lines, 'E1420: Missing :endenum', 4)
+
+ # all lower case should be used for "enum"
+ lines =<< trim END
+ vim9script
+ Enum Something
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E492: Not an editor command: Enum Something', 2)
+
+ # all lower case should be used for "endenum"
+ lines =<< trim END
+ vim9script
+ enum Something
+ Endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1420: Missing :endenum', 4)
+
+ # Additional words after "endenum"
+ lines =<< trim END
+ vim9script
+ enum Something
+ endenum school's out
+ END
+ v9.CheckSourceFailure(lines, "E488: Trailing characters: school's out", 3)
+
+ # Additional commands after "endenum"
+ lines =<< trim END
+ vim9script
+ enum Something
+ endenum | echo 'done'
+ END
+ v9.CheckSourceFailure(lines, "E488: Trailing characters: | echo 'done'", 3)
+
+ # Try to define enum in a single command
+ lines =<< trim END
+ vim9script
+ enum Something | endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1420: Missing :endenum', 3)
+
+ # Try to define an enum with the same name as an existing variable
+ lines =<< trim END
+ vim9script
+ var Something: list<number> = [1]
+ enum Something
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1041: Redefining script item: "Something"', 3)
+
+ # Unsupported special character following enum name
+ lines =<< trim END
+ vim9script
+ enum Foo
+ first,
+ second : 20
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1123: Missing comma before argument: : 20', 4)
+
+ # Try initializing an enum item with a number
+ lines =<< trim END
+ vim9script
+ enum Foo
+ first,
+ second = 2
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1123: Missing comma before argument: = 2', 4)
+
+ # Try initializing an enum item with a String
+ lines =<< trim END
+ vim9script
+ enum Foo
+ first,
+ second = 'second'
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, "E1123: Missing comma before argument: = 'second'", 4)
+
+ # Try initializing an enum item with a List
+ lines =<< trim END
+ vim9script
+ enum Foo
+ first,
+ second = []
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1123: Missing comma before argument: = []', 4)
+
+ # Use a colon after name
+ lines =<< trim END
+ vim9script
+ enum Foo
+
+ # first
+ first:
+ second
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1123: Missing comma before argument: :', 5)
+
+ # Use a '=='
+ lines =<< trim END
+ vim9script
+ enum Foo
+ first == 1
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1123: Missing comma before argument: == 1', 3)
+
+ # Missing comma after an enum item
+ lines =<< trim END
+ vim9script
+ enum Planet
+ mercury
+ venus
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1419: Not a valid command in an Enum: venus', 4)
+
+ # Comma at the beginning of an item
+ lines =<< trim END
+ vim9script
+ enum Planet
+ mercury
+ ,venus
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1419: Not a valid command in an Enum: ,venus', 4)
+ # Space before comma
+ lines =<< trim END
+ vim9script
+ enum Planet
+ mercury ,
+ venus
+ endenum
+ END
+ v9.CheckSourceFailure(lines, "E1068: No white space allowed before ','", 3)
+
+ # No space after comma
+ lines =<< trim END
+ vim9script
+ enum Planet
+ mercury,venus
+ endenum
+ END
+ v9.CheckSourceFailure(lines, "E1069: White space required after ',': mercury,venus", 3)
+
+ # no comma between items in the same line
+ lines =<< trim END
+ vim9script
+ enum Planet
+ mercury venus earth
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1123: Missing comma before argument: venus earth', 3)
+
+ # No space after an item and comment between items
+ lines =<< trim END
+ vim9script
+ enum Planet
+ mercury
+
+ # Venus
+ venus
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1419: Not a valid command in an Enum: venus', 6)
+
+ # Comma is supported for the last item
+ lines =<< trim END
+ vim9script
+ enum Planet
+ mercury,
+ venus,
+ endenum
+ var p: Planet
+ p = Planet.mercury
+ p = Planet.venus
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # invalid enum value declaration
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ $%@
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1418: Invalid enum value declaration: $%@', 4)
+
+ # Duplicate enum value
+ lines =<< trim END
+ vim9script
+ enum A
+ Foo,
+ Bar,
+ Foo
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1428: Duplicate enum value: Foo', 5)
+
+ # Duplicate enum value in the same line
+ lines =<< trim END
+ vim9script
+ enum A
+ Foo, Bar, Foo,
+ Bar
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1428: Duplicate enum value: Foo', 3)
+
+ # Try extending a class when defining an enum
+ lines =<< trim END
+ vim9script
+ class Foo
+ endclass
+ enum Bar extends Foo
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1416: Enum cannot extend a class or enum', 4)
+
+ # Try extending an enum
+ lines =<< trim END
+ vim9script
+ enum Foo
+ endenum
+ enum Bar extends Foo
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1416: Enum cannot extend a class or enum', 4)
+
+ # Try extending an enum using a class
+ lines =<< trim END
+ vim9script
+ enum Foo
+ endenum
+ class Bar extends Foo
+ endclass
+ END
+ v9.CheckSourceFailure(lines, 'E1354: Cannot extend Foo', 5)
+
+ # Try implementing an enum using a class
+ lines =<< trim END
+ vim9script
+ enum Foo
+ endenum
+ class Bar implements Foo
+ endclass
+ END
+ v9.CheckSourceFailure(lines, 'E1347: Not a valid interface: Foo', 5)
+
+ # abstract method is not supported in an enum
+ lines =<< trim END
+ vim9script
+ enum Foo
+ Apple
+ abstract def Bar()
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1417: Abstract cannot be used in an Enum', 4)
+
+ # Define an enum without any enum values but only with an object variable
+ lines =<< trim END
+ vim9script
+ enum Foo
+ final n: number = 10
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1123: Missing comma before argument: n: number = 10', 3)
+enddef
+
+def Test_basic_enum()
+ # Declare a simple enum
+ var lines =<< trim END
+ vim9script
+ enum Foo
+ apple,
+ orange
+ endenum
+ var a: Foo = Foo.apple
+ var b: Foo = Foo.orange
+ assert_equal(a, Foo.apple)
+ assert_equal(b, Foo.orange)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Multiple enums in a single line
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple, orange
+ endenum
+ assert_equal('enum<Foo>', typename(Foo.apple))
+ assert_equal('enum<Foo>', typename(Foo.orange))
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Comments and empty lines are supported between enum items
+ lines =<< trim END
+ vim9script
+ enum Foo
+ # Apple
+ apple,
+
+ # Orange
+ orange
+ endenum
+ def Fn()
+ var a: Foo = Foo.apple
+ var b: Foo = Foo.orange
+ assert_equal(a, Foo.apple)
+ assert_equal(b, Foo.orange)
+ enddef
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Try using a non-existing enum value
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple,
+ orange
+ endenum
+ var a: Foo = Foo.pear
+ END
+ v9.CheckSourceFailure(lines, 'E1422: Enum value "pear" not found in enum "Foo"', 6)
+
+ # Enum function argument
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple,
+ orange
+ endenum
+ def Fn(a: Foo): Foo
+ return a
+ enddef
+ assert_equal(Foo.apple, Fn(Foo.apple))
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Enum function argument
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple,
+ orange
+ endenum
+ def Fn(a: Foo): Foo
+ return a
+ enddef
+ Fn({})
+ END
+ v9.CheckSourceFailure(lines, 'E1013: Argument 1: type mismatch, expected enum<Foo> but got dict<any>', 9)
+
+ # Returning an enum in a function returning number
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple,
+ orange
+ endenum
+ def Fn(): number
+ return Foo.orange
+ enddef
+ Fn()
+ END
+ v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected number but got enum<Foo>', 1)
+
+ # Returning a number in a function returning enum
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple,
+ orange
+ endenum
+ def Fn(): Foo
+ return 20
+ enddef
+ Fn()
+ END
+ v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected enum<Foo> but got number', 1)
+
+ # Use a List of enums
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury,
+ Venus,
+ Earth
+ endenum
+ var l1: list<Planet> = [Planet.Mercury, Planet.Venus]
+ assert_equal(Planet.Venus, l1[1])
+ def Fn()
+ var l2: list<Planet> = [Planet.Mercury, Planet.Venus]
+ assert_equal(Planet.Venus, l2[1])
+ enddef
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Try using an enum as a value
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+ endenum
+ var a = Fruit
+ END
+ v9.CheckSourceFailure(lines, 'E1421: Enum "Fruit" cannot be used as a value', 6)
+enddef
+
+" Test for type() and typename() of an enum
+def Test_enum_type()
+ var lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+ endenum
+ assert_equal('enum<Fruit>', typename(Fruit))
+ assert_equal('enum<Fruit>', typename(Fruit.Apple))
+ assert_equal(v:t_enum, type(Fruit))
+ assert_equal(v:t_enumvalue, type(Fruit.Apple))
+ assert_equal(15, type(Fruit))
+ assert_equal(16, type(Fruit.Apple))
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Assign an enum to a variable with any type
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+ endenum
+ var a = Fruit.Apple
+ var b: any = Fruit.Orange
+ assert_equal('enum<Fruit>', typename(a))
+ assert_equal('enum<Fruit>', typename(b))
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Try modifying an enum or an enum item
+def Test_enum_modify()
+ # Try assigning an unsupported value to an enum
+ var lines =<< trim END
+ vim9script
+ enum Foo
+ apple
+ endenum
+ var a: Foo = 30
+ END
+ v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected enum<Foo> but got number', 5)
+
+ # Try assigning an unsupported value to an enum in a function
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple
+ endenum
+ def Fn()
+ var a: Foo = 30
+ enddef
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected enum<Foo> but got number', 1)
+
+ # Try assigning a number to an enum
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple,
+ orange
+ endenum
+ Foo = 10
+ END
+ v9.CheckSourceFailure(lines, 'E1421: Enum "Foo" cannot be used as a value', 6)
+
+ # Try assigning a number to an enum in a function
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple
+ endenum
+ def Fn()
+ Foo = 10
+ enddef
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1012: Type mismatch; expected enum<Foo> but got number', 1)
+
+ # Try assigning a number to an enum value
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple
+ endenum
+ Foo.apple = 20
+ END
+ v9.CheckSourceFailure(lines, 'E1423: Enum value "Foo.apple" cannot be modified', 5)
+
+ # Try assigning a number to an enum value in a function
+ lines =<< trim END
+ vim9script
+ enum Foo
+ apple
+ endenum
+ def Fn()
+ Foo.apple = 20
+ enddef
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1423: Enum value "Foo.apple" cannot be modified', 1)
+
+ # Try assigning one enum to another
+ lines =<< trim END
+ vim9script
+ enum Foo
+ endenum
+ enum Bar
+ endenum
+ Foo = Bar
+ END
+ v9.CheckSourceFailure(lines, 'E1421: Enum "Bar" cannot be used as a value', 6)
+
+ # Try assigning one enum to another in a function
+ lines =<< trim END
+ vim9script
+ enum Foo
+ endenum
+ enum Bar
+ endenum
+ def Fn()
+ Foo = Bar
+ enddef
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1421: Enum "Bar" cannot be used as a value', 1)
+
+ # Try assigning one enum item to another enum item
+ lines =<< trim END
+ vim9script
+ enum Foo
+ Apple
+ endenum
+ enum Bar
+ Orange
+ endenum
+ Foo.Apple = Bar.Orange
+ END
+ v9.CheckSourceFailure(lines, 'E1423: Enum value "Foo.Apple" cannot be modified', 8)
+
+ # Try assigning one enum item to another enum item in a function
+ lines =<< trim END
+ vim9script
+ enum Foo
+ Apple
+ endenum
+ enum Bar
+ Orange
+ endenum
+ def Fn()
+ Foo.Apple = Bar.Orange
+ enddef
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1423: Enum value "Foo.Apple" cannot be modified', 1)
+enddef
+
+" Test for using enum in an expression
+def Test_enum_expr()
+ var lines =<< trim END
+ vim9script
+ enum Color
+ Red, Blue, Green
+ endenum
+ var a: number = 1 + Color
+ END
+ v9.CheckSourceFailure(lines, 'E1421: Enum "Color" cannot be used as a value', 5)
+
+ lines =<< trim END
+ vim9script
+ enum Color
+ Red, Blue, Green
+ endenum
+ var a: number = 1 + Color.Red
+ END
+ v9.CheckSourceFailure(lines, 'E1424: Using an Enum "Color" as a Number', 5)
+
+ lines =<< trim END
+ vim9script
+ enum Color
+ Red, Blue, Green
+ endenum
+ var s: string = "abc" .. Color
+ END
+ v9.CheckSourceFailure(lines, 'E1421: Enum "Color" cannot be used as a value', 5)
+
+ lines =<< trim END
+ vim9script
+ enum Color
+ Red, Blue, Green
+ endenum
+ var s: string = "abc" .. Color.Red
+ END
+ v9.CheckSourceFailure(lines, 'E1425: Using an Enum "Color" as a String', 5)
+enddef
+
+" Using an enum in a lambda function
+def Test_enum_lambda()
+ var lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury,
+ Venus,
+ Earth,
+ endenum
+ var Fn = (p: Planet): Planet => p
+ for [idx, v] in items([Planet.Mercury, Planet.Venus, Planet.Earth])
+ assert_equal(idx, Fn(v).ordinal)
+ endfor
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Comparison using enums
+def Test_enum_compare()
+ var lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury,
+ Venus,
+ Earth,
+ endenum
+ enum Fruit
+ Apple,
+ Orange
+ endenum
+
+ var p: Planet = Planet.Venus
+ var f: Fruit = Fruit.Orange
+ assert_equal(true, p == Planet.Venus)
+ assert_equal(false, p == Planet.Earth)
+ assert_equal(false, p == f)
+ assert_equal(true, Planet.Mercury == Planet.Mercury)
+ assert_equal(true, Planet.Venus != Planet.Earth)
+ assert_equal(true, Planet.Mercury != Fruit.Apple)
+
+ def Fn1()
+ var p2: Planet = Planet.Venus
+ var f2: Fruit = Fruit.Orange
+ assert_equal(true, p2 == Planet.Venus)
+ assert_equal(false, p2 == Planet.Earth)
+ assert_equal(false, p2 == f2)
+ enddef
+ Fn1()
+
+ # comparison using "is" and "isnot"
+ assert_equal(true, p is Planet.Venus)
+ assert_equal(true, p isnot Planet.Earth)
+ assert_equal(false, p is Fruit.Orange)
+ assert_equal(true, p isnot Fruit.Orange)
+ def Fn2(arg: Planet)
+ assert_equal(true, arg is Planet.Venus)
+ assert_equal(true, arg isnot Planet.Earth)
+ assert_equal(false, arg is Fruit.Orange)
+ assert_equal(true, arg isnot Fruit.Orange)
+ enddef
+ Fn2(p)
+
+ class A
+ endclass
+ var o: A = A.new()
+ assert_equal(false, p == o)
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for using an enum as a default argument to a function
+def Test_enum_default_arg()
+ var lines =<< trim END
+ vim9script
+ enum Day
+ Monday, Tuesday, Wednesday
+ endenum
+ def Fn(d: Day = Day.Tuesday): Day
+ return d
+ enddef
+ assert_equal(Day.Tuesday, Fn())
+ assert_equal(Day.Wednesday, Fn(Day.Wednesday))
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for enum garbage collection
+func Test_enum_garbagecollect()
+ let lines =<< trim END
+ vim9script
+ enum Car
+ Honda, Ford, Tesla
+ endenum
+ assert_equal(1, Car.Ford.ordinal)
+ call test_garbagecollect_now()
+ assert_equal(1, Car.Ford.ordinal)
+ var c: Car = Car.Tesla
+ assert_equal(2, c.ordinal)
+ call test_garbagecollect_now()
+ assert_equal(2, c.ordinal)
+ END
+ call v9.CheckSourceSuccess(lines)
+
+ " garbage collection with a variable of type any
+ let lines =<< trim END
+ vim9script
+ enum Car
+ Honda, Ford, Tesla
+ endenum
+ call test_garbagecollect_now()
+ var c: any = Car.Tesla
+ call test_garbagecollect_now()
+ assert_equal(Car.Tesla, c)
+ END
+ call v9.CheckSourceSuccess(lines)
+
+ " garbage collection with function arguments and return types
+ let lines =<< trim END
+ vim9script
+ enum Car
+ Honda, Ford, Tesla
+ endenum
+ def Fn(a: Car): Car
+ assert_equal(Car.Ford, a)
+ return Car.Tesla
+ enddef
+ call test_garbagecollect_now()
+ var b: Car = Car.Ford
+ call test_garbagecollect_now()
+ assert_equal(Car.Tesla, Fn(b))
+ call test_garbagecollect_now()
+ END
+ call v9.CheckSourceSuccess(lines)
+endfunc
+
+" Test for the enum values class variable
+def Test_enum_values()
+ var lines =<< trim END
+ vim9script
+ enum Car
+ Honda, Ford, Tesla
+ endenum
+ var l: list<Car> = Car.values
+ assert_equal(Car.Ford, l[1])
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # empty enum
+ lines =<< trim END
+ vim9script
+ enum Car
+ endenum
+ assert_equal([], Car.values)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # single value
+ lines =<< trim END
+ vim9script
+ enum Car
+ Honda
+ endenum
+ assert_equal([Car.Honda], Car.values)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ lines =<< trim END
+ vim9script
+ enum A
+ Red,
+ Blue
+ static def GetValues(): list<A>
+ return values
+ enddef
+ endenum
+ assert_equal([A.Red, A.Blue], A.GetValues())
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Other class variables in an enum should not be added to 'values'
+ lines =<< trim END
+ vim9script
+ enum LogLevel
+ Error, Warn
+ static const x: number = 22
+ endenum
+ assert_equal([LogLevel.Error, LogLevel.Warn], LogLevel.values)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Other class variable of enum type should not be added to 'values'
+ lines =<< trim END
+ vim9script
+ enum LogLevel
+ Error, Warn
+ static const x: LogLevel = LogLevel.Warn
+ endenum
+ assert_equal([LogLevel.Error, LogLevel.Warn], LogLevel.values)
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test comments in enums
+def Test_enum_comments()
+ var lines =<< trim END
+ vim9script
+ enum Car # cars
+ # before enum
+ Honda, # honda
+ # before enum
+ Ford # ford
+ endenum
+ assert_equal(1, Car.Ford.ordinal)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Test for using an unsupported comment
+ lines =<< trim END
+ vim9script
+ enum Car
+ Honda,
+ Ford,
+ #{
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1170: Cannot use #{ to start a comment', 4)
+enddef
+
+" Test string() with enums
+def Test_enum_string()
+ var lines =<< trim END
+ vim9script
+ enum Car
+ Honda,
+ Ford
+ endenum
+ assert_equal("enum Car", string(Car))
+ assert_equal("enum Car.Honda {name: 'Honda', ordinal: 0}", string(Car.Honda))
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # customized string function
+ lines =<< trim END
+ vim9script
+ enum Dir
+ North,
+ South
+
+ def string(): string
+ return $'Dir.{this.name}'
+ enddef
+ endenum
+ assert_equal('Dir.North', string(Dir.North))
+ assert_equal('Dir.South', string(Dir.South))
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for importing an enum
+def Test_enum_import()
+ var lines =<< trim END
+ vim9script
+ export enum Star
+ Gemini,
+ Orion,
+ Pisces
+ endenum
+ END
+ writefile(lines, 'Xenumexport.vim', 'D')
+
+ lines =<< trim END
+ vim9script
+ import './Xenumexport.vim' as mod
+
+ var s1: mod.Star = mod.Star.Orion
+ assert_equal(true, s1 == mod.Star.Orion)
+ assert_equal(2, mod.Star.Pisces.ordinal)
+ var l1: list<mod.Star> = mod.Star.values
+ assert_equal("enum Star.Orion {name: 'Orion', ordinal: 1}", string(l1[1]))
+ assert_equal(s1, l1[1])
+
+ def Fn()
+ var s2: mod.Star = mod.Star.Orion
+ assert_equal(true, s2 == mod.Star.Orion)
+ assert_equal(2, mod.Star.Pisces.ordinal)
+ var l2: list<mod.Star> = mod.Star.values
+ assert_equal("enum Star.Orion {name: 'Orion', ordinal: 1}", string(l2[1]))
+ assert_equal(s2, l2[1])
+ enddef
+ Fn()
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
+" Test for using test_refcount() with enum
+def Test_enum_refcount()
+ var lines =<< trim END
+ vim9script
+ enum Foo
+ endenum
+ assert_equal(1, test_refcount(Foo))
+
+ enum Star
+ Gemini,
+ Orion
+ endenum
+ assert_equal(3, test_refcount(Star))
+ assert_equal(2, test_refcount(Star.Gemini))
+ assert_equal(2, test_refcount(Star.Orion))
+
+ var s: Star
+ assert_equal(3, test_refcount(Star))
+ assert_equal(-1, test_refcount(s))
+ s = Star.Orion
+ assert_equal(3, test_refcount(Star))
+ assert_equal(3, test_refcount(s))
+ assert_equal(2, test_refcount(Star.Gemini))
+ var t = s
+ assert_equal(3, test_refcount(Star))
+ assert_equal(4, test_refcount(s))
+ assert_equal(4, test_refcount(Star.Orion))
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for defining an enum with additional object variables and methods
+def Test_enum_enhanced()
+ var lines =<< trim END
+ vim9script
+ enum Vehicle
+ car(4, 5, 400),
+ bus(6, 50, 800),
+ bicycle(2, 1, 0)
+
+ final tires: number
+ final passengers: number
+ final carbonPerKilometer: number
+
+ def new(t: number, p: number, cpk: number)
+ this.tires = t
+ this.passengers = p
+ this.carbonPerKilometer = cpk
+ enddef
+
+ def CarbonFootprint(): float
+ return round(this.carbonPerKilometer / this.passengers)
+ enddef
+
+ def IsTwoWheeled(): bool
+ return this == Vehicle.bicycle
+ enddef
+
+ def CompareTo(other: Vehicle): float
+ return this.CarbonFootprint() - other.CarbonFootprint()
+ enddef
+ endenum
+
+ var v: Vehicle = Vehicle.bus
+ assert_equal([6, 50, 800], [v.tires, v.passengers, v.carbonPerKilometer])
+ assert_equal(true, Vehicle.bicycle.IsTwoWheeled())
+ assert_equal(false, Vehicle.car.IsTwoWheeled())
+ assert_equal(16.0, Vehicle.bus.CarbonFootprint())
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for the enum value 'name' variable
+def Test_enum_name()
+ # Check the names of enum values
+ var lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury,
+ Venus,
+ Earth
+ endenum
+ assert_equal('Mercury', Planet.Mercury.name)
+ assert_equal('Venus', Planet.Venus.name)
+ assert_equal('Earth', Planet.Earth.name)
+ assert_equal('string', typename(Planet.Earth.name))
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Check the name of enum items in the constructor
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury("Mercury"),
+ Venus("Venus"),
+ Earth("Earth")
+
+ def new(s: string)
+ assert_equal(s, this.name)
+ enddef
+ endenum
+ defcompile
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Try assigning to the name of an enum
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple
+ endenum
+ Fruit.Apple.name = 'foo'
+ END
+ v9.CheckSourceFailure(lines, 'E1335: Variable "name" in class "Fruit" is not writable', 5)
+
+ # Try assigning to the name of an enum in a function
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple
+ endenum
+ def Fn()
+ Fruit.Apple.name = 'bar'
+ enddef
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1423: Enum value "Fruit.name" cannot be modified', 1)
+
+ # Try to overwrite an enum value name in the enum constructor
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury,
+ Venus
+
+ def new()
+ this.name = 'foo'
+ enddef
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1427: Enum "Planet" name cannot be modified', 1)
+
+ # Try to declare an object variable named 'name'
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury
+ var name: string
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: name', 4)
+enddef
+
+" Test for the enum value 'ordinal' variable
+def Test_enum_ordinal()
+ # Check the ordinal values of enum items
+ var lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury,
+ Venus,
+ Earth
+ endenum
+ assert_equal(0, Planet.Mercury.ordinal)
+ assert_equal(1, Planet.Venus.ordinal)
+ assert_equal(2, Planet.Earth.ordinal)
+ assert_equal('number', typename(Planet.Earth.ordinal))
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Check the ordinal value of enum items in the constructor
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury(0),
+ Venus(1),
+ Earth(2)
+
+ def new(v: number)
+ assert_equal(v, this.ordinal)
+ enddef
+ endenum
+ defcompile
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Try assigning to the ordinal value of an enum
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple
+ endenum
+ Fruit.Apple.ordinal = 20
+ END
+ v9.CheckSourceFailure(lines, 'E1335: Variable "ordinal" in class "Fruit" is not writable', 5)
+
+ # Try assigning to the ordinal value of an enum in a function
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple
+ endenum
+ def Fn()
+ Fruit.Apple.ordinal = 20
+ enddef
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E1423: Enum value "Fruit.ordinal" cannot be modified', 1)
+
+ # Try to overwrite an enum value ordinal in the enum constructor
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury,
+ Venus
+
+ def new()
+ this.ordinal = 20
+ enddef
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1426: Enum "Planet" ordinal value cannot be modified', 1)
+
+ # Try to declare an object variable named 'ordinal'
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mercury
+ var ordinal: number
+ endenum
+ END
+ v9.CheckSourceFailure(lines, 'E1369: Duplicate variable: ordinal', 4)
+enddef
+
+" Test for trying to create a new enum object using the constructor
+def Test_enum_invoke_constructor()
+ var lines =<< trim END
+ vim9script
+ enum Foo
+ endenum
+ var f: Foo = Foo.new()
+ END
+ v9.CheckSourceFailure(lines, 'E1325: Method "new" not found in class "Foo"', 4)
+
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+ endenum
+ var f: Fruit = Fruit.new()
+ END
+ v9.CheckSourceFailure(lines, 'E1325: Method "new" not found in class "Fruit"', 6)
+
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+ def newFruit()
+ enddef
+ endenum
+ var f: Fruit = Fruit.newFruit()
+ END
+ v9.CheckSourceFailure(lines, 'E1325: Method "newFruit" not found in class "Fruit"', 8)
+
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+ endenum
+ def Fn()
+ var f: Fruit = Fruit.new()
+ enddef
+ Fn()
+ END
+ v9.CheckSourceFailure(lines, 'E1325: Method "new" not found in class "Fruit"', 1)
+
+ # error in the enum constructor
+ lines =<< trim END
+ vim9script
+ enum Planet
+ earth
+ def new()
+ x = 123
+ enddef
+ endenum
+ END
+ v9.CheckSourceFailureList(lines, ['E1100:', 'E1100:'], 1)
+enddef
+
+" Test for checking "this" in an enum constructor
+def Test_enum_this_in_constructor()
+ var lines =<< trim END
+ vim9script
+ enum A
+ Red("enum A.Red {name: 'Red', ordinal: 0}"),
+ Blue("enum A.Blue {name: 'Blue', ordinal: 1}"),
+ Green("enum A.Green {name: 'Green', ordinal: 2}")
+
+ def new(s: string)
+ assert_equal(s, string(this))
+ enddef
+ endenum
+ defcompile
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for using member variables in an enum object
+def Test_enum_object_variable()
+ var lines =<< trim END
+ vim9script
+ enum Planet
+ Jupiter(95),
+ Saturn(146)
+
+ var moons: number
+ endenum
+ assert_equal(95, Planet.Jupiter.moons)
+ assert_equal(146, Planet.Saturn.moons)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Use a final object variable
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Jupiter(95),
+ Saturn(146)
+
+ final moons: number
+ def new(n: number)
+ this.moons = n
+ enddef
+ endenum
+ assert_equal(95, Planet.Jupiter.moons)
+ assert_equal(146, Planet.Saturn.moons)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Use a const object variable
+ lines =<< trim END
+ vim9script
+ enum Planet
+ Mars(false),
+ Jupiter(true)
+
+ const has_ring: bool
+ def new(r: bool)
+ this.has_ring = r
+ enddef
+ endenum
+ assert_equal(false, Planet.Mars.has_ring)
+ assert_equal(true, Planet.Jupiter.has_ring)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Use a regular object variable
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+
+ final farm: string = 'SunValley'
+ endenum
+ assert_equal('SunValley', Fruit.Apple.farm)
+ assert_equal('SunValley', Fruit.Apple.farm)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Invoke the default constructor with an object variable
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple('foo'),
+ Orange('bar')
+
+ final t: string
+ endenum
+ assert_equal('foo', Fruit.Apple.t)
+ assert_equal('bar', Fruit.Orange.t)
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # Invoke the default constructor with an argument but without the object
+ # variable
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange('bar')
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E118: Too many arguments for function: new', 5)
+
+ # Define a default constructor with an argument, but don't pass it in when
+ # defining the enum value
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple(5),
+ Orange
+
+ def new(t: number)
+ enddef
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, 'E119: Not enough arguments for function: new', 8)
+enddef
+
+" Test for using a custom constructor with an enum
+def Test_enum_custom_constructor()
+ # space before "("
+ var lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple(10),
+ Orange (20)
+
+ def new(t: number)
+ enddef
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, "E1068: No white space allowed before '(': Orange (20)", 4)
+
+ # no closing ")"
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple(10),
+ Orange (20
+
+ def new(t: number)
+ enddef
+ endenum
+ defcompile
+ END
+ v9.CheckSourceFailure(lines, "E1068: No white space allowed before '(': Orange (20", 4)
+
+ # Specify constructor arguments split across multiple lines
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple(10,
+ 'foo'), Orange(20,
+ 'bar'),
+ Pear(30,
+ 'baz'), Mango(40,
+ 'qux')
+
+ final n: number
+ final s: string
+ def new(t: number, str: string)
+ this.n = t
+ this.s = str
+ enddef
+ endenum
+ defcompile
+ assert_equal([10, 'foo'], [Fruit.Apple.n, Fruit.Apple.s])
+ assert_equal([20, 'bar'], [Fruit.Orange.n, Fruit.Orange.s])
+ assert_equal([30, 'baz'], [Fruit.Pear.n, Fruit.Pear.s])
+ assert_equal([40, 'qux'], [Fruit.Mango.n, Fruit.Mango.s])
+ END
+ v9.CheckSourceSuccess(lines)
+
+ # specify multiple enums with constructor arguments in a single line
+ lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple(10, 'foo'), Orange(20, 'bar'), Pear(30, 'baz'), Mango(40, 'qux')
+ const n: number
+ const s: string
+ endenum
+ defcompile
+ assert_equal([10, 'foo'], [Fruit.Apple.n, Fruit.Apple.s])
+ assert_equal([20, 'bar'], [Fruit.Orange.n, Fruit.Orange.s])
+ assert_equal([30, 'baz'], [Fruit.Pear.n, Fruit.Pear.s])
+ assert_equal([40, 'qux'], [Fruit.Mango.n, Fruit.Mango.s])
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for using class variables in an enum class
+def Test_enum_class_variable()
+ var lines =<< trim END
+ vim9script
+ enum Fruit
+ Apple,
+ Orange
+
+ static var farm: string = 'SunValley'
+ endenum
+ assert_equal('SunValley', Fruit.farm)
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for converting a string to an enum value
+def Test_enum_eval()
+ var lines =<< trim END
+ vim9script
+ enum Color
+ Red,
+ Blue
+ endenum
+ var e = eval('Color.Blue')
+ assert_equal(Color.Blue, e)
+ assert_equal(1, e.ordinal)
+ assert_fails("eval('Color.Green')", 'E1422: Enum value "Green" not found in enum "Color"')
+ assert_fails("var x = eval('Color')", 'E1421: Enum "Color" cannot be used as a value')
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for using "values" in an enum class variable
+def Test_use_enum_values_in_class_variable()
+ var lines =<< trim END
+ vim9script
+ enum Dir
+ North, South
+ static const dirs: list<Dir> = Dir.values
+ endenum
+ assert_equal([Dir.North, Dir.South], Dir.dirs)
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
+" Test for using lambda block in enums
+def Test_lambda_block_in_enum()
+ # This used to crash Vim
+ var lines =<< trim END
+ vim9script
+ enum IdEnum1
+ ID1
+ const Id: func(number): number = (num: number): number => {
+ # Return a ID
+ return num / 2
+ }
+ endenum
+ assert_equal(5, IdEnum1.ID1.Id(10))
+ END
+ v9.CheckScriptSuccess(lines)
+
+ # This used to crash Vim
+ lines =<< trim END
+ vim9script
+ enum IdEnum2
+ ID1
+ static const Id: func(number): number = (num: number): number => {
+ # Return a ID
+ return num + 2
+ }
+ endenum
+ assert_equal(12, IdEnum2.Id(10))
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
+" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/testdir/test_vim9_func.vim b/src/testdir/test_vim9_func.vim
index 27585a9..b008929 100644
--- a/src/testdir/test_vim9_func.vim
+++ b/src/testdir/test_vim9_func.vim
@@ -166,6 +166,37 @@ def Test_wrong_function_name()
delfunc g:Define
enddef
+" Check that in a legacy script a :def accesses the correct script variables.
+" Github issue: #14615.
+def Test_access_var_from_legacy_def()
+ # Access a script variable by name WITH "s:" prefix.
+ var lines =<< trim END
+ let s:foo = 'init'
+ let s:xxfoo = 'init'
+ def! AccessVarFromLegacyDef()
+ s:xxfoo = 'CHANGED'
+ enddef
+ call AccessVarFromLegacyDef()
+ call assert_equal('init', s:foo)
+ call assert_equal('CHANGED', s:xxfoo)
+ END
+ v9.CheckScriptSuccess(lines)
+
+ # Access a script variable by name WITHOUT "s:" prefix;
+ # previously this accessed "foo" and not "xxfoo"
+ lines =<< trim END
+ let s:foo = 'init'
+ let s:xxfoo = 'init'
+ def! AccessVarFromLegacyDef()
+ xxfoo = 'CHANGED'
+ enddef
+ call AccessVarFromLegacyDef()
+ call assert_equal('init', s:foo)
+ call assert_equal('CHANGED', s:xxfoo)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
def Test_listing_function_error()
var lines =<< trim END
var filler = 123
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim
index fa1aeb1..581925d 100644
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -1140,6 +1140,182 @@ def Test_autoload_import_relative()
v9.CheckScriptFailure(lines, 'E484:')
enddef
+" autoload relative, access from compiled function.
+" Github issues: #14565, #14579
+def Test_autoload_import_relative_compiled_buffer()
+ var lines =<< trim END
+ vim9script
+
+ export def F1(): string
+ return 'InFile.vim'
+ enddef
+ END
+ writefile(lines, 'Ximportrelativebuffer.vim', 'D')
+ lines =<< trim END
+ vim9script
+
+ import autoload './Ximportrelativebuffer.vim' as xfile
+
+ def F(): string
+ return xfile.F1()
+ enddef
+ assert_equal('InFile.vim', F())
+ END
+ new
+ setline(1, lines)
+ :source
+ # source one more time to detect issues with clearing the script state and
+ # variables
+ :source
+ :bw!
+enddef
+
+" Test for relative import when sourcing a buffer in another directory
+def Test_autoload_import_relative_from_buffer_in_dir()
+ mkdir('Ximportrelative/dir1/dir2', 'pR')
+ var lines =<< trim END
+ vim9script
+
+ export def F1(): string
+ return 'InFile.vim'
+ enddef
+ END
+ writefile(lines, 'Ximportrelative/dir1/dir2/Ximport.vim')
+ lines =<< trim END
+ vim9script
+
+ import autoload './Ximport.vim' as xfile
+
+ def F(): string
+ return xfile.F1()
+ enddef
+ assert_equal('InFile.vim', F())
+ END
+ writefile(lines, 'Ximportrelative/dir1/dir2/Xrelative.vim')
+
+ split Ximportrelative/dir1/dir2/Xrelative.vim
+ :source
+ # source one more time to detect issues with clearing the script state and
+ # variables
+ :source
+ :bw!
+enddef
+
+" Test modifying exported autoload variable. Github issue: #14591
+def Test_autoload_export_variables()
+ mkdir('Xautoload_vars/autoload', 'pR')
+ var lines =<< trim END
+ vim9script
+ g:Xautoload_vars_autoload = true
+ export var val = 11
+ val = 42
+ END
+
+ # Test that the imported script, above, can modify the exported variable;
+ # and test that the importing script, below, can modify the variable.
+ writefile(lines, 'Xautoload_vars/autoload/Xauto_vars_f2.vim', 'D')
+ lines =<< trim END
+ vim9script
+ g:Xautoload_vars_autoload = false
+
+ import autoload './Xautoload_vars/autoload/Xauto_vars_f2.vim' as f2
+ # Verify that the import statement does not load the file.
+ assert_equal(false, g:Xautoload_vars_autoload)
+
+ def F(): number
+ return f2.val
+ enddef
+ # Verify compile does not load the file.
+ defcompile F
+ assert_equal(false, g:Xautoload_vars_autoload)
+
+ # load the file by accessing the exported variable
+ assert_equal(42, F())
+ assert_equal(true, g:Xautoload_vars_autoload)
+ unlet g:Xautoload_vars_autoload
+
+ assert_equal(42, f2.val)
+ f2.val = 17
+ assert_equal(17, f2.val)
+
+ def G()
+ f2.val = 19
+ enddef
+ G()
+ assert_equal(19, f2.val)
+ END
+ v9.CheckScriptSuccess(lines)
+
+ # Test const var is not modifiable.
+ lines =<< trim END
+ vim9script
+ export const val = 11
+ val = 42
+ END
+ writefile(lines, 'Xautoload_vars/autoload/Xauto_vars_f3.vim', 'D')
+ lines =<< trim END
+ vim9script
+
+ import autoload './Xautoload_vars/autoload/Xauto_vars_f3.vim' as f3
+
+ var x = f3.val
+ END
+ v9.CheckScriptFailure(lines, 'E46:')
+
+ # Test const var is not modifiable from importing script.
+ lines =<< trim END
+ vim9script
+ export const val = 11
+ END
+ writefile(lines, 'Xautoload_vars/autoload/Xauto_vars_f4.vim', 'D')
+ lines =<< trim END
+ vim9script
+
+ import autoload './Xautoload_vars/autoload/Xauto_vars_f4.vim' as f4
+
+ f4.val = 13
+ END
+ v9.CheckScriptFailure(lines, 'E46:')
+
+ # Test const var is not modifiable from importing script from :def.
+ # Github issue: #14606
+ lines =<< trim END
+ vim9script
+ export const val = 11
+ END
+ writefile(lines, 'Xautoload_vars/autoload/Xauto_vars_f5.vim', 'D')
+ lines =<< trim END
+ vim9script
+
+ import autoload './Xautoload_vars/autoload/Xauto_vars_f5.vim' as f5
+
+ def F()
+ f5.val = 13
+ enddef
+ F()
+ END
+ v9.CheckScriptFailure(lines, 'E741:')
+
+ # Still part of Github issue: #14606
+ lines =<< trim END
+ vim9script
+ export var val = 11
+ END
+ writefile(lines, 'Xautoload_vars/autoload/Xauto_vars_f6.vim', 'D')
+ lines =<< trim END
+ vim9script
+
+ import autoload './Xautoload_vars/autoload/Xauto_vars_f6.vim' as f6
+
+ def F()
+ f6.val = 13
+ enddef
+ F()
+ assert_equal(13, f6.val)
+ END
+ v9.CheckScriptSuccess(lines)
+enddef
+
def Test_autoload_import_relative_autoload_dir()
mkdir('autoload', 'pR')
var lines =<< trim END
@@ -2054,6 +2230,13 @@ def Test_import_vim9_from_legacy()
export def GetText(): string
return 'text'
enddef
+ export var exported_nr: number = 22
+ def AddNum(n: number)
+ exported_nr += n
+ enddef
+ export var exportedDict: dict<func> = {Fn: AddNum}
+ export const CONST = 10
+ export final finalVar = 'abc'
END
writefile(vim9_lines, 'Xvim9_export.vim', 'D')
@@ -2072,6 +2255,13 @@ def Test_import_vim9_from_legacy()
" imported symbol is script-local
call assert_equal('exported', s:vim9.exported)
call assert_equal('text', s:vim9.GetText())
+ call s:vim9.exportedDict.Fn(5)
+ call assert_equal(27, s:vim9.exported_nr)
+ call call(s:vim9.exportedDict.Fn, [3])
+ call assert_equal(30, s:vim9.exported_nr)
+ call assert_fails('let s:vim9.CONST = 20', 'E46: Cannot change read-only variable "CONST"')
+ call assert_fails('let s:vim9.finalVar = ""', 'E46: Cannot change read-only variable "finalVar"')
+ call assert_fails('let s:vim9.non_existing_var = 20', 'E1048: Item not found in script: non_existing_var')
END
writefile(legacy_lines, 'Xlegacy_script.vim', 'D')
@@ -2916,6 +3106,33 @@ def Test_vim9_import_symlink()
unlet g:resultValue
&rtp = save_rtp
delete('Xfrom', 'rf')
+
+ # Access item from :def imported through symbolic linked directory. #14536
+ mkdir('Xto/real_dir', 'pR')
+ lines =<< trim END
+ vim9script
+ export const val = 17
+ export def F(): number
+ return 23
+ enddef
+ END
+ writefile(lines, 'Xto/real_dir/real_file.vim')
+ system('ln -s real_dir Xto/syml_dir')
+ defer delete('Xto/syml_dir')
+ lines =<< trim END
+ vim9script
+ import autoload './Xto/syml_dir/real_file.vim'
+
+ def Fmain()
+ assert_equal(17, real_file.val)
+ enddef
+ def F2()
+ assert_equal(23, real_file.F())
+ enddef
+ Fmain()
+ F2()
+ END
+ v9.CheckScriptSuccess(lines)
endif
enddef
@@ -2979,4 +3196,30 @@ def Test_import_autloaded_script()
&rtp = save_rtp
enddef
+" Test for autoloading an imported dict func
+def Test_autoload_import_dict_func()
+ mkdir('Xdir/autoload', 'pR')
+ var lines =<< trim END
+ vim9script
+ export var al_exported_nr: number = 33
+ def Al_AddNum(n: number)
+ al_exported_nr += n
+ enddef
+ export var al_exportedDict: dict<func> = {Fn: Al_AddNum}
+ END
+ writefile(lines, 'Xdir/autoload/Xdictfunc.vim')
+
+ var save_rtp = &rtp
+ exe 'set rtp^=' .. getcwd() .. '/Xdir'
+ lines =<< trim END
+ import './Xdir/autoload/Xdictfunc.vim'
+ call Xdictfunc#al_exportedDict.Fn(5)
+ call assert_equal(38, Xdictfunc#al_exported_nr)
+ call call(Xdictfunc#al_exportedDict.Fn, [3])
+ call assert_equal(41, Xdictfunc#al_exported_nr)
+ END
+ v9.CheckScriptSuccess(lines)
+ &rtp = save_rtp
+enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index 77b8831..a3f21be 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -458,7 +458,7 @@ func s:InvokeSomeCommand()
SomeCommand
endfunc
-def Test_autocommand_block()
+def Test_command_block()
com SomeCommand {
g:someVar = 'some'
}
@@ -469,7 +469,121 @@ def Test_autocommand_block()
unlet g:someVar
enddef
-def Test_command_block()
+" Test for using heredoc in a :command command block
+def Test_command_block_heredoc()
+ var lines =<< trim CODE
+ vim9script
+ com SomeCommand {
+ g:someVar =<< trim END
+ aaa
+ bbb
+ END
+ }
+ SomeCommand
+ assert_equal(['aaa', 'bbb'], g:someVar)
+ def Foo()
+ g:someVar = []
+ SomeCommand
+ assert_equal(['aaa', 'bbb'], g:someVar)
+ enddef
+ Foo()
+ delcommand SomeCommand
+ unlet g:someVar
+ CODE
+ v9.CheckSourceSuccess( lines)
+
+ # Execute a command with heredoc in a block
+ lines =<< trim CODE
+ vim9script
+ com SomeCommand {
+ g:someVar =<< trim END
+ aaa
+ bbb
+ END
+ }
+ execute('SomeCommand')
+ assert_equal(['aaa', 'bbb'], g:someVar)
+ delcommand SomeCommand
+ unlet g:someVar
+ CODE
+ v9.CheckSourceSuccess(lines)
+
+ # Heredoc with comment
+ lines =<< trim CODE
+ vim9script
+ com SomeCommand {
+ g:someVar =<< trim END # comment
+ aaa
+ bbb
+ END
+ }
+ execute('SomeCommand')
+ assert_equal(['aaa', 'bbb'], g:someVar)
+ delcommand SomeCommand
+ unlet g:someVar
+ CODE
+ v9.CheckSourceSuccess(lines)
+
+ # heredoc evaluation
+ lines =<< trim CODE
+ vim9script
+ com SomeCommand {
+ var suffix = '---'
+ g:someVar =<< trim eval END
+ ccc{suffix}
+ ddd
+ END
+ }
+ SomeCommand
+ assert_equal(['ccc---', 'ddd'], g:someVar)
+ def Foo()
+ g:someVar = []
+ SomeCommand
+ assert_equal(['ccc---', 'ddd'], g:someVar)
+ enddef
+ Foo()
+ delcommand SomeCommand
+ unlet g:someVar
+ CODE
+ v9.CheckSourceSuccess(lines)
+
+ # command following heredoc
+ lines =<< trim CODE
+ vim9script
+ com SomeCommand {
+ var l =<< trim END
+ eee
+ fff
+ END
+ g:someVar = l
+ }
+ SomeCommand
+ assert_equal(['eee', 'fff'], g:someVar)
+ delcommand SomeCommand
+ unlet g:someVar
+ CODE
+ v9.CheckSourceSuccess(lines)
+
+ # Error in heredoc
+ lines =<< trim CODE
+ vim9script
+ com SomeCommand {
+ g:someVar =<< trim END
+ eee
+ fff
+ }
+ try
+ SomeCommand
+ catch
+ assert_match("E990: Missing end marker 'END'", v:exception)
+ endtry
+ delcommand SomeCommand
+ unlet g:someVar
+ CODE
+ v9.CheckSourceSuccess(lines)
+enddef
+
+def Test_autocommand_block()
au BufNew *.xml {
g:otherVar = 'other'
}
@@ -4906,7 +5020,7 @@ def Test_for_stmt_space_before_type()
v9.CheckSourceFailure(lines, 'E1059: No white space allowed before colon: :number in range(10)', 2)
enddef
-" This test used to cause an use-after-free memory access
+" This test used to cause a use-after-free memory access
def Test_for_empty_line_after_lambda()
var lines =<< trim END
vim9script
@@ -4931,6 +5045,16 @@ def Test_for_empty_line_after_lambda()
v9.CheckSourceSuccess(lines)
enddef
+" Test for evaluating a lambda block from a string
+def Test_eval_lambda_block()
+ var lines =<< trim END
+ vim9script
+ var Fn = eval("(x: number): number => {\nreturn x * 2\n}")
+ assert_equal(6, Fn(3))
+ END
+ v9.CheckSourceSuccess(lines)
+enddef
+
" Keep this last, it messes up highlighting.
def Test_substitute_cmd()
new
diff --git a/src/testdir/test_visual.vim b/src/testdir/test_visual.vim
index fd174a9..adcc3e9 100644
--- a/src/testdir/test_visual.vim
+++ b/src/testdir/test_visual.vim
@@ -1149,7 +1149,7 @@ func Test_visual_inner_block()
" try to select non-existing inner block
call cursor(5, 1)
call assert_beeps('normal ViBiBiB')
- " try to select a unclosed inner block
+ " try to select an unclosed inner block
8,9d
call cursor(5, 1)
call assert_beeps('normal ViBiB')
diff --git a/src/testdir/test_winfixbuf.vim b/src/testdir/test_winfixbuf.vim
index 04043f8..f800338 100644
--- a/src/testdir/test_winfixbuf.vim
+++ b/src/testdir/test_winfixbuf.vim
@@ -1,6 +1,7 @@
" Test 'winfixbuf'
source check.vim
+source shared.vim
" Find the number of open windows in the current tab
func s:get_windows_count()
@@ -199,10 +200,7 @@ func s:reset_all_buffers()
set nowinfixbuf
call setqflist([])
-
- for l:window_info in getwininfo()
- call setloclist(l:window_info["winid"], [])
- endfor
+ call setloclist(0, [], 'f')
delmarks A-Z0-9
endfunc
@@ -641,7 +639,7 @@ func Test_caddexpr()
call s:reset_all_buffers()
let l:file_path = tempname()
- call writefile(["Error - bad-thing-found"], l:file_path)
+ call writefile(["Error - bad-thing-found"], l:file_path, 'D')
execute "edit " . l:file_path
let l:file_buffer = bufnr()
let l:current = bufnr()
@@ -657,8 +655,6 @@ func Test_caddexpr()
execute 'caddexpr expand("%") .. ":" .. line(".") .. ":" .. getline(".")'
call assert_equal(l:current, bufnr())
-
- call delete(l:file_path)
endfunc
" Fail :cbuffer but :cbuffer! is allowed
@@ -667,7 +663,7 @@ func Test_cbuffer()
call s:reset_all_buffers()
let l:file_path = tempname()
- call writefile(["first.unittest:1:Error - bad-thing-found"], l:file_path)
+ call writefile(["first.unittest:1:Error - bad-thing-found"], l:file_path, 'D')
execute "edit " . l:file_path
let l:file_buffer = bufnr()
let l:current = bufnr()
@@ -686,8 +682,6 @@ func Test_cbuffer()
execute "cbuffer! " . l:file_buffer
call assert_equal("first.unittest", expand("%:t"))
-
- call delete(l:file_path)
endfunc
" Allow :cc but the 'nowinfixbuf' window is selected, instead
@@ -1125,6 +1119,150 @@ func Test_edit()
call assert_equal(l:other, bufnr())
endfunc
+" Fail :e when selecting a buffer from a relative path if in a different folder
+"
+" In this tests there's 2 buffers
+"
+" foo - lives on disk, in some folder. e.g. /tmp/foo
+" foo - an in-memory buffer that has not been saved to disk. If saved, it
+" would live in a different folder, /other/foo.
+"
+" The 'winfixbuf' is looking at the in-memory buffer and trying to switch to
+" the buffer on-disk (and fails, because it's a different buffer)
+func Test_edit_different_buffer_on_disk_and_relative_path_to_disk()
+ call s:reset_all_buffers()
+
+ let l:file_on_disk = tempname()
+ let l:directory_on_disk1 = fnamemodify(l:file_on_disk, ":p:h")
+ let l:name = fnamemodify(l:file_on_disk, ":t")
+ execute "edit " . l:file_on_disk
+ write!
+
+ let l:directory_on_disk2 = l:directory_on_disk1 . "_something_else"
+
+ if !isdirectory(l:directory_on_disk2)
+ call mkdir(l:directory_on_disk2)
+ endif
+
+ execute "cd " . l:directory_on_disk2
+ execute "edit " l:name
+
+ let l:current = bufnr()
+
+ call assert_equal(l:current, bufnr())
+ set winfixbuf
+ call assert_fails("edit " . l:file_on_disk, "E1513:")
+ call assert_equal(l:current, bufnr())
+
+ call delete(l:directory_on_disk1)
+ call delete(l:directory_on_disk2)
+endfunc
+
+" Fail :e when selecting a buffer from a relative path if in a different folder
+"
+" In this tests there's 2 buffers
+"
+" foo - lives on disk, in some folder. e.g. /tmp/foo
+" foo - an in-memory buffer that has not been saved to disk. If saved, it
+" would live in a different folder, /other/foo.
+"
+" The 'winfixbuf' is looking at the on-disk buffer and trying to switch to
+" the in-memory buffer (and fails, because it's a different buffer)
+func Test_edit_different_buffer_on_disk_and_relative_path_to_memory()
+ call s:reset_all_buffers()
+
+ let l:file_on_disk = tempname()
+ let l:directory_on_disk1 = fnamemodify(l:file_on_disk, ":p:h")
+ let l:name = fnamemodify(l:file_on_disk, ":t")
+ execute "edit " . l:file_on_disk
+ write!
+
+ let l:directory_on_disk2 = l:directory_on_disk1 . "_something_else"
+
+ if !isdirectory(l:directory_on_disk2)
+ call mkdir(l:directory_on_disk2)
+ endif
+
+ execute "cd " . l:directory_on_disk2
+ execute "edit " l:name
+ execute "cd " . l:directory_on_disk1
+ execute "edit " l:file_on_disk
+ execute "cd " . l:directory_on_disk2
+
+ let l:current = bufnr()
+
+ call assert_equal(l:current, bufnr())
+ set winfixbuf
+ call assert_fails("edit " . l:name, "E1513:")
+ call assert_equal(l:current, bufnr())
+
+ call delete(l:directory_on_disk1)
+ call delete(l:directory_on_disk2)
+endfunc
+
+" Fail to call `:e first` if called from a starting, in-memory buffer
+func Test_edit_first_buffer()
+ call s:reset_all_buffers()
+
+ set winfixbuf
+ let l:current = bufnr()
+
+ call assert_fails("edit first", "E1513:")
+ call assert_equal(l:current, bufnr())
+
+ edit! first
+ call assert_equal(l:current, bufnr())
+ edit! somewhere_else
+ call assert_notequal(l:current, bufnr())
+endfunc
+
+" Allow reloading a buffer using :e
+func Test_edit_no_arguments()
+ call s:reset_all_buffers()
+
+ let l:current = bufnr()
+ file some_buffer
+
+ call assert_equal(l:current, bufnr())
+ set winfixbuf
+ edit
+ call assert_equal(l:current, bufnr())
+endfunc
+
+" Allow :e selecting the current buffer
+func Test_edit_same_buffer_in_memory()
+ call s:reset_all_buffers()
+
+ let current = bufnr()
+ file same_buffer
+
+ call assert_equal(current, bufnr())
+ set winfixbuf
+ edit same_buffer
+ call assert_equal(current, bufnr())
+ set nowinfixbuf
+endfunc
+
+" Allow :e selecting the current buffer as a full path
+func Test_edit_same_buffer_on_disk_absolute_path()
+ call s:reset_all_buffers()
+
+ let file = tempname()
+ " file must exist for expansion of 8.3 paths to succeed
+ call writefile([], file, 'D')
+ let file = fnamemodify(file, ':p')
+ let current = bufnr()
+ execute "edit " . file
+ write!
+
+ call assert_equal(current, bufnr())
+ set winfixbuf
+ execute "edit " file
+ call assert_equal(current, bufnr())
+
+ set nowinfixbuf
+endfunc
+
" Fail :enew but :enew! is allowed
func Test_enew()
call s:reset_all_buffers()
@@ -1160,7 +1298,7 @@ func Test_find()
let l:current = bufnr()
let l:file = tempname()
- call writefile([], l:file)
+ call writefile([], l:file, 'D')
let l:file = fnamemodify(l:file, ':p') " In case it's Windows 8.3-style.
let l:directory = fnamemodify(l:file, ":p:h")
let l:name = fnamemodify(l:file, ":p:t")
@@ -1177,7 +1315,6 @@ func Test_find()
call assert_equal(l:file, expand("%:p"))
execute "set path=" . l:original_path
- call delete(l:file)
endfunc
" Fail :first but :first! is allowed
@@ -1238,8 +1375,8 @@ func Test_ijump()
call writefile([
\ '#include "' . l:include_file . '"'
\ ],
- \ "main.c")
- call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
+ \ "main.c", 'D')
+ call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file, 'D')
edit main.c
set winfixbuf
@@ -1261,8 +1398,6 @@ func Test_ijump()
set define&
set include&
set path&
- call delete("main.c")
- call delete(l:include_file)
endfunc
" Fail :lNext but :lNext! is allowed
@@ -1327,7 +1462,7 @@ func Test_laddexpr()
call s:reset_all_buffers()
let l:file_path = tempname()
- call writefile(["Error - bad-thing-found"], l:file_path)
+ call writefile(["Error - bad-thing-found"], l:file_path, 'D')
execute "edit " . l:file_path
let l:file_buffer = bufnr()
let l:current = bufnr()
@@ -1343,8 +1478,6 @@ func Test_laddexpr()
execute 'laddexpr expand("%") .. ":" .. line(".") .. ":" .. getline(".")'
call assert_equal(l:current, bufnr())
-
- call delete(l:file_path)
endfunc
" Fail :last but :last! is allowed
@@ -1367,7 +1500,7 @@ func Test_lbuffer()
call s:reset_all_buffers()
let l:file_path = tempname()
- call writefile(["first.unittest:1:Error - bad-thing-found"], l:file_path)
+ call writefile(["first.unittest:1:Error - bad-thing-found"], l:file_path, 'D')
execute "edit " . l:file_path
let l:file_buffer = bufnr()
let l:current = bufnr()
@@ -1386,8 +1519,6 @@ func Test_lbuffer()
execute "lbuffer! " . l:file_buffer
call assert_equal("first.unittest", expand("%:t"))
-
- call delete(l:file_path)
endfunc
" Fail :ldo but :ldo! is allowed
@@ -1451,7 +1582,7 @@ func Test_lfile()
write
let l:file = tempname()
- call writefile(["first.unittest:1:Error - bad-thing-found was detected"], l:file)
+ call writefile(["first.unittest:1:Error - bad-thing-found was detected"], l:file, 'D')
let l:current = bufnr()
@@ -1463,7 +1594,6 @@ func Test_lfile()
execute ":lfile! " . l:file
call assert_equal(l:first, bufnr())
- call delete(l:file)
call delete("first.unittest")
call delete("second.unittest")
endfunc
@@ -1603,9 +1733,9 @@ func Test_ltag()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
execute "normal \<C-]>"
@@ -1618,9 +1748,6 @@ func Test_ltag()
ltag! one
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail vim.command if we try to change buffers while 'winfixbuf' is set
@@ -1826,9 +1953,9 @@ func Test_normal_g_ctrl_square_bracket_right()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -1839,9 +1966,6 @@ func Test_normal_g_ctrl_square_bracket_right()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail to jump to a tag with g<RightMouse> if 'winfixbuf' is enabled
@@ -1854,9 +1978,9 @@ func Test_normal_g_rightmouse()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
execute "normal \<C-]>"
@@ -1869,9 +1993,6 @@ func Test_normal_g_rightmouse()
set tags&
set mouse&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail to jump to a tag with g] if 'winfixbuf' is enabled
@@ -1883,9 +2004,9 @@ func Test_normal_g_square_bracket_right()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -1896,9 +2017,6 @@ func Test_normal_g_square_bracket_right()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail to jump to a tag with <C-RightMouse> if 'winfixbuf' is enabled
@@ -1911,9 +2029,9 @@ func Test_normal_ctrl_rightmouse()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
execute "normal \<C-]>"
@@ -1926,9 +2044,6 @@ func Test_normal_ctrl_rightmouse()
set tags&
set mouse&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail to jump to a tag with <C-t> if 'winfixbuf' is enabled
@@ -1940,9 +2055,9 @@ func Test_normal_ctrl_t()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
execute "normal \<C-]>"
@@ -1954,9 +2069,6 @@ func Test_normal_ctrl_t()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Disallow <C-^> in 'winfixbuf' windows
@@ -2058,9 +2170,9 @@ func Test_normal_ctrl_square_bracket_right()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2071,9 +2183,6 @@ func Test_normal_ctrl_square_bracket_right()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Allow <C-w><C-]> with 'winfixbuf' enabled because it runs in a new, split window
@@ -2085,9 +2194,9 @@ func Test_normal_ctrl_w_ctrl_square_bracket_right()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2097,9 +2206,6 @@ func Test_normal_ctrl_w_ctrl_square_bracket_right()
call assert_equal(l:current_windows + 1, s:get_windows_count())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Allow <C-w>g<C-]> with 'winfixbuf' enabled because it runs in a new, split window
@@ -2111,9 +2217,9 @@ func Test_normal_ctrl_w_g_ctrl_square_bracket_right()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2123,9 +2229,6 @@ func Test_normal_ctrl_w_g_ctrl_square_bracket_right()
call assert_equal(l:current_windows + 1, s:get_windows_count())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail to jump to a tag with <C-]> if 'winfixbuf' is enabled
@@ -2137,9 +2240,9 @@ func Test_normal_gt()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one", "two", "three"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one", "two", "three"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2150,9 +2253,6 @@ func Test_normal_gt()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Prevent gF from switching a 'winfixbuf' window's buffer
@@ -2161,7 +2261,7 @@ func Test_normal_gF()
let l:file = tempname()
call append(0, [l:file])
- call writefile([], l:file)
+ call writefile([], l:file, 'D')
" Place the cursor onto the line that has `l:file`
normal gg
" Prevent Vim from erroring with "No write since last change @ command
@@ -2180,7 +2280,7 @@ func Test_normal_gF()
normal gF
call assert_notequal(l:buffer, bufnr())
- call delete(l:file)
+ set nohidden
endfunc
" Prevent gf from switching a 'winfixbuf' window's buffer
@@ -2189,7 +2289,7 @@ func Test_normal_gf()
let l:file = tempname()
call append(0, [l:file])
- call writefile([], l:file)
+ call writefile([], l:file, 'D')
" Place the cursor onto the line that has `l:file`
normal gg
" Prevent Vim from erroring with "No write since last change @ command
@@ -2208,7 +2308,7 @@ func Test_normal_gf()
normal gf
call assert_notequal(l:buffer, bufnr())
- call delete(l:file)
+ set nohidden
endfunc
" Fail "goto file under the cursor" (using [f, which is the same as `:normal gf`)
@@ -2217,7 +2317,7 @@ func Test_normal_square_bracket_left_f()
let l:file = tempname()
call append(0, [l:file])
- call writefile([], l:file)
+ call writefile([], l:file, 'D')
" Place the cursor onto the line that has `l:file`
normal gg
" Prevent Vim from erroring with "No write since last change @ command
@@ -2236,7 +2336,7 @@ func Test_normal_square_bracket_left_f()
normal [f
call assert_notequal(l:buffer, bufnr())
- call delete(l:file)
+ set nohidden
endfunc
" Fail to go to a C macro with [<C-d> if 'winfixbuf' is enabled
@@ -2247,8 +2347,8 @@ func Test_normal_square_bracket_left_ctrl_d()
call writefile(["min(1, 12);",
\ '#include "' . l:include_file . '"'
\ ],
- \ "main.c")
- call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
+ \ "main.c", 'D')
+ call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file, 'D')
edit main.c
normal ]\<C-d>
@@ -2263,9 +2363,6 @@ func Test_normal_square_bracket_left_ctrl_d()
execute "normal [\<C-d>"
call assert_notequal(l:current, bufnr())
-
- call delete("main.c")
- call delete(l:include_file)
endfunc
" Fail to go to a C macro with ]<C-d> if 'winfixbuf' is enabled
@@ -2276,8 +2373,8 @@ func Test_normal_square_bracket_right_ctrl_d()
call writefile(["min(1, 12);",
\ '#include "' . l:include_file . '"'
\ ],
- \ "main.c")
- call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
+ \ "main.c", 'D')
+ call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file, 'D')
edit main.c
set winfixbuf
@@ -2291,9 +2388,6 @@ func Test_normal_square_bracket_right_ctrl_d()
execute "normal ]\<C-d>"
call assert_notequal(l:current, bufnr())
-
- call delete("main.c")
- call delete(l:include_file)
endfunc
" Fail to go to a C macro with [<C-i> if 'winfixbuf' is enabled
@@ -2304,8 +2398,8 @@ func Test_normal_square_bracket_left_ctrl_i()
call writefile(['#include "' . l:include_file . '"',
\ "min(1, 12);",
\ ],
- \ "main.c")
- call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
+ \ "main.c", 'D')
+ call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file, 'D')
edit main.c
" Move to the line with `min(1, 12);` on it"
normal j
@@ -2328,8 +2422,6 @@ func Test_normal_square_bracket_left_ctrl_i()
set define&
set include&
set path&
- call delete("main.c")
- call delete(l:include_file)
endfunc
" Fail to go to a C macro with ]<C-i> if 'winfixbuf' is enabled
@@ -2340,8 +2432,8 @@ func Test_normal_square_bracket_right_ctrl_i()
call writefile(["min(1, 12);",
\ '#include "' . l:include_file . '"'
\ ],
- \ "main.c")
- call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file)
+ \ "main.c", 'D')
+ call writefile(["#define min(X, Y) ((X) < (Y) ? (X) : (Y))"], l:include_file, 'D')
edit main.c
set winfixbuf
@@ -2363,8 +2455,6 @@ func Test_normal_square_bracket_right_ctrl_i()
set define&
set include&
set path&
- call delete("main.c")
- call delete(l:include_file)
endfunc
" Fail "goto file under the cursor" (using ]f, which is the same as `:normal gf`)
@@ -2373,7 +2463,7 @@ func Test_normal_square_bracket_right_f()
let l:file = tempname()
call append(0, [l:file])
- call writefile([], l:file)
+ call writefile([], l:file, 'D')
" Place the cursor onto the line that has `l:file`
normal gg
" Prevent Vim from erroring with "No write since last change @ command
@@ -2392,7 +2482,7 @@ func Test_normal_square_bracket_right_f()
normal ]f
call assert_notequal(l:buffer, bufnr())
- call delete(l:file)
+ set nohidden
endfunc
" Fail to jump to a tag with v<C-]> if 'winfixbuf' is enabled
@@ -2404,9 +2494,9 @@ func Test_normal_v_ctrl_square_bracket_right()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2417,9 +2507,6 @@ func Test_normal_v_ctrl_square_bracket_right()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail to jump to a tag with vg<C-]> if 'winfixbuf' is enabled
@@ -2431,9 +2518,9 @@ func Test_normal_v_g_ctrl_square_bracket_right()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2444,9 +2531,6 @@ func Test_normal_v_g_ctrl_square_bracket_right()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Allow :pedit because, unlike :edit, it uses a separate window
@@ -2471,9 +2555,9 @@ func Test_pop()
\ "thesame\tXfile\t2;\"\td\tfile:",
\ "thesame\tXfile\t3;\"\td\tfile:",
\ ],
- \ "Xtags")
- call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
- call writefile(["thesame one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["thesame one", "thesame two", "thesame three"], "Xfile", 'D')
+ call writefile(["thesame one"], "Xother", 'D')
edit Xother
tag thesame
@@ -2489,9 +2573,6 @@ func Test_pop()
call assert_notequal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail :previous but :previous! is allowed
@@ -2559,7 +2640,7 @@ func Test_pythonx_pyxfile()
\ "buffer = vim.vars['_previous_buffer']",
\ "vim.current.buffer = vim.buffers[buffer]",
\ ],
- \ "file.py")
+ \ "file.py", 'D')
try
pyxfile file.py
@@ -2569,7 +2650,6 @@ func Test_pythonx_pyxfile()
call assert_equal(1, l:caught)
- call delete("file.py")
unlet g:_previous_buffer
endfunc
@@ -2696,11 +2776,11 @@ func Test_short_option()
call s:make_buffer_pairs()
set winfixbuf
- call assert_fails("edit something_else", "E1513")
+ call assert_fails("edit something_else", "E1513:")
set nowinfixbuf
set wfb
- call assert_fails("edit another_place", "E1513")
+ call assert_fails("edit another_place", "E1513:")
set nowfb
edit last_place
@@ -2747,9 +2827,9 @@ func Test_tNext()
\ "thesame\tXfile\t2;\"\td\tfile:",
\ "thesame\tXfile\t3;\"\td\tfile:",
\ ],
- \ "Xtags")
- call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
- call writefile(["thesame one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["thesame one", "thesame two", "thesame three"], "Xfile", 'D')
+ call writefile(["thesame one"], "Xother", 'D')
edit Xother
tag thesame
@@ -2766,9 +2846,6 @@ func Test_tNext()
tNext!
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Call :tabdo and choose the next available 'nowinfixbuf' window.
@@ -2826,9 +2903,9 @@ func Test_tag()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2842,9 +2919,6 @@ func Test_tag()
call assert_notequal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
@@ -2857,9 +2931,9 @@ func Test_tfirst()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2873,9 +2947,6 @@ func Test_tfirst()
call assert_notequal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail :tjump but :tjump! is allowed
@@ -2887,9 +2958,9 @@ func Test_tjump()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
- call writefile(["one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
+ call writefile(["one"], "Xother", 'D')
edit Xother
set winfixbuf
@@ -2903,9 +2974,6 @@ func Test_tjump()
call assert_notequal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail :tlast but :tlast! is allowed
@@ -2917,8 +2985,8 @@ func Test_tlast()
\ "one\tXfile\t1",
\ "three\tXfile\t3",
\ "two\tXfile\t2"],
- \ "Xtags")
- call writefile(["one", "two", "three"], "Xfile")
+ \ "Xtags", 'D')
+ call writefile(["one", "two", "three"], "Xfile", 'D')
edit Xfile
tjump one
edit Xfile
@@ -2934,8 +3002,6 @@ func Test_tlast()
call assert_equal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
endfunc
" Fail :tnext but :tnext! is allowed
@@ -2948,9 +3014,9 @@ func Test_tnext()
\ "thesame\tXfile\t2;\"\td\tfile:",
\ "thesame\tXfile\t3;\"\td\tfile:",
\ ],
- \ "Xtags")
- call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
- call writefile(["thesame one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["thesame one", "thesame two", "thesame three"], "Xfile", 'D')
+ call writefile(["thesame one"], "Xother", 'D')
edit Xother
tag thesame
@@ -2967,9 +3033,6 @@ func Test_tnext()
call assert_notequal(l:current, bufnr())
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail :tprevious but :tprevious! is allowed
@@ -2982,9 +3045,9 @@ func Test_tprevious()
\ "thesame\tXfile\t2;\"\td\tfile:",
\ "thesame\tXfile\t3;\"\td\tfile:",
\ ],
- \ "Xtags")
- call writefile(["thesame one", "thesame two", "thesame three"], "Xfile")
- call writefile(["thesame one"], "Xother")
+ \ "Xtags", 'D')
+ call writefile(["thesame one", "thesame two", "thesame three"], "Xfile", 'D')
+ call writefile(["thesame one"], "Xother", 'D')
edit Xother
tag thesame
@@ -3001,9 +3064,6 @@ func Test_tprevious()
tprevious!
set tags&
- call delete("Xtags")
- call delete("Xfile")
- call delete("Xother")
endfunc
" Fail :view but :view! is allowed
@@ -3283,4 +3343,15 @@ func Test_bufdo_cnext_splitwin_fails()
set winminheight&vim winheight&vim
endfunc
+" Test that exiting with 'winfixbuf' and EXITFREE doesn't cause an error.
+func Test_exitfree_no_error()
+ let lines =<< trim END
+ set winfixbuf
+ qall!
+ END
+ call writefile(lines, 'Xwfb_exitfree', 'D')
+ call assert_notmatch('E1513:',
+ \ system(GetVimCommandClean() .. ' --not-a-term -X -S Xwfb_exitfree'))
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/test_xdg.vim b/src/testdir/test_xdg.vim
new file mode 100644
index 0000000..6f35b72
--- /dev/null
+++ b/src/testdir/test_xdg.vim
@@ -0,0 +1,295 @@
+" Tests for the XDG feature
+
+source check.vim
+source shared.vim
+
+func s:get_rcs()
+ let rcs = {
+ \ 'file1': { 'path': '~/.vimrc' },
+ \ 'file2': { 'path': '~/.vim/vimrc' },
+ \ 'xdg': { 'path': exists('$XDG_CONFIG_HOME') ? '$XDG_CONFIG_HOME' : "~/.config" },
+ \}
+ for v in values(rcs)
+ let v.exists = filereadable(expand(v.path))
+ endfor
+ return rcs
+endfunc
+
+func Test_xdg_rc_detection()
+ CheckUnix
+ let rc = s:get_rcs()
+ let before =<< trim CODE
+ call writefile([expand('$MYVIMRC')], "XMY_VIMRC")
+ quit!
+ CODE
+ call RunVim(before, [], "")
+ let my_rc = readfile("XMY_VIMRC")
+ if rc.file1.exists
+ call assert_equal(rc.file1.path, my_rc)
+ elseif !rc.file1.exists && rc.file2.exists
+ call assert_equal(rc.file2.path, my_rc)
+ elseif !rc.file1.exists && !rc.file2.exists && rc.xdg.exists
+ call assert_equal(rc.xdg.path, my_rc)
+ endif
+ call delete("XMY_VIMRC")
+endfunc
+
+func Test_xdg_runtime_files()
+ " This tests, that the initialization file from
+ " ~/.vimrc, ~/.vim/vimrc and ~/.config/vim/vimrc (or
+ " $XDG_CONFIG_HOME/vim/vimrc) are sourced in that order
+ CheckUnix
+ call mkdir(expand('~/.vim/'), 'pD')
+ call mkdir(expand('~/.config/vim/'), 'pD')
+ call mkdir(expand('~/xdg/vim/'), 'pD')
+
+ let rc1=expand('~/.vimrc')
+ let rc2=expand('~/.vim/vimrc')
+ let rc3=expand('~/.config/vim/vimrc')
+ let rc4=expand('~/xdg/vim/vimrc')
+
+ " g:rc_one|two|three|four is to verify, that the other
+ " init files are not sourced
+ " g:rc is to verify which rc file has been loaded.
+ let file1 =<< trim CODE
+ let g:rc_one = 'one'
+ let g:rc = '.vimrc'
+ CODE
+ let file2 =<< trim CODE
+ let g:rc_two = 'two'
+ let g:rc = '.vim/vimrc'
+ CODE
+ let file3 =<< trim CODE
+ let g:rc_three = 'three'
+ let g:rc = '.config/vim/vimrc'
+ CODE
+ let file4 =<< trim CODE
+ let g:rc_four = 'four'
+ let g:rc = 'xdg/vim/vimrc'
+ CODE
+ call writefile(file1, rc1)
+ call writefile(file2, rc2)
+ call writefile(file3, rc3)
+ call writefile(file4, rc4)
+
+ " Get the Vim command to run without the '-u NONE' argument
+ let vimcmd = substitute(GetVimCommand(), '-u NONE', '', '')
+
+ " Test for ~/.vimrc
+ let lines =<< trim END
+ call assert_match('XfakeHOME/\.vimrc', $MYVIMRC)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_one: 'one', rc: '.vimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc1)
+
+ " Test for ~/.vim/vimrc
+ let lines =<< trim END
+ call assert_match('XfakeHOME/\.vim/vimrc', $MYVIMRC)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_two: 'two', rc: '.vim/vimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc2)
+
+ " XDG_CONFIG_HOME is set in Github CI runners
+ unlet $XDG_CONFIG_HOME
+
+ " Test for ~/.config/vim/vimrc
+ let lines =<< trim END
+ let msg = $'HOME="{$HOME}", ~="{expand("~")}"'
+ call assert_match('XfakeHOME/\.config/vim/vimrc', $MYVIMRC, msg)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_three: 'three', rc: '.config/vim/vimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc3)
+
+ " Test for ~/xdg/vim/vimrc
+ let $XDG_CONFIG_HOME=expand('~/xdg/')
+ let lines =<< trim END
+ let msg = $'HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"'
+ call assert_match('XfakeHOME/xdg/vim/vimrc', $MYVIMRC, msg)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/vimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc4)
+ unlet $XDG_CONFIG_HOME
+endfunc
+
+func Test_xdg_version()
+ CheckUnix
+ let $HOME = getcwd() .. '/XfakeHOME'
+ unlet $XDG_CONFIG_HOME
+ let a = execute(':version')->split('\n')
+ let a = filter(a, { _, val -> val =~ '\.config\|XDG_CONFIG_HOME' })
+ " There should be 1 entry for gvimrc and 1 entry for vimrc,
+ " but only if Vim was compiled with gui support
+ call assert_equal(1 + has("gui"), len(a))
+ call assert_match('\~/\.config/vim/vimrc', a[0])
+ if has("gui")
+ call assert_match('\~/\.config/vim/gvimrc', a[1])
+ endif
+
+ let $XDG_CONFIG_HOME = expand('~/.xdg')
+ let a = execute(':version')->split('\n')
+ let a = filter(a, { _, val -> val =~ '\.config\|XDG_CONFIG_HOME' })
+ call assert_equal(1 + has("gui"), len(a))
+ call assert_match('XDG_CONFIG_HOME/vim/vimrc', a[0])
+ if has("gui")
+ call assert_match('XDG_CONFIG_HOME/vim/gvimrc', a[1])
+ endif
+ unlet $XDG_CONFIG_HOME
+endfunc
+
+" Test for gvimrc, must be last, since it starts the GUI
+" and sources a few extra test files
+func Test_zzz_xdg_runtime_files()
+ CheckCanRunGui
+ CheckUnix
+
+ " Is setup in Github Runner
+ unlet $XDG_CONFIG_HOME
+ source setup_gui.vim
+ call GUISetUpCommon()
+
+ " This tests, that the GUI initialization file from
+ " ~/.gvimrc, ~/.vim/gvimrc, ~/.config/vim/gvimrc
+ " and ~/XDG_CONFIG_HOME/vim/gvimrc is sourced
+ " when starting GUI mode
+ call mkdir(expand('~/.vim/'), 'pD')
+ call mkdir(expand('~/.config/vim/'), 'pD')
+ call mkdir(expand('~/xdg/vim/'), 'pD')
+
+ let rc1=expand('~/.gvimrc')
+ let rc2=expand('~/.vim/gvimrc')
+ let rc3=expand('~/.config/vim/gvimrc')
+ let rc4=expand('~/xdg/vim/gvimrc')
+
+ " g:rc_one|two|three|four is to verify, that the other
+ " init files are not sourced
+ " g:rc is to verify which rc file has been loaded.
+ let file1 =<< trim CODE
+ let g:rc_one = 'one'
+ let g:rc = '.gvimrc'
+ CODE
+ let file2 =<< trim CODE
+ let g:rc_two = 'two'
+ let g:rc = '.vim/gvimrc'
+ CODE
+ let file3 =<< trim CODE
+ let g:rc_three = 'three'
+ let g:rc = '.config/vim/gvimrc'
+ CODE
+ let file4 =<< trim CODE
+ let g:rc_four = 'four'
+ let g:rc = 'xdg/vim/gvimrc'
+ CODE
+ call writefile(file1, rc1)
+ call writefile(file2, rc2)
+ call writefile(file3, rc3)
+ call writefile(file4, rc4)
+
+ " Get the Vim command to run without the '-u NONE' argument
+ let vimcmd = substitute(GetVimCommand(), '-u NONE', '', '')
+
+ " Test for ~/.gvimrc
+ let lines =<< trim END
+ " Ignore the "failed to create input context" error.
+ call test_ignore_error('E285')
+ gui -f
+ call assert_match('Xhome/\.gvimrc', $MYGVIMRC)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_one: 'one', rc: '.gvimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc1)
+
+ " Test for ~/.vim/gvimrc
+ let lines =<< trim END
+ " Ignore the "failed to create input context" error.
+ call test_ignore_error('E285')
+ gui -f
+ call assert_match('Xhome/\.vim/gvimrc', $MYGVIMRC)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_two: 'two', rc: '.vim/gvimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc2)
+
+ " Test for ~/.config/vim/gvimrc
+ let lines =<< trim END
+ " Ignore the "failed to create input context" error.
+ call test_ignore_error('E285')
+ gui -f
+ let msg = $'HOME="{$HOME}", ~="{expand("~")}"'
+ call assert_match('Xhome/\.config/vim/gvimrc', $MYGVIMRC, msg)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_three: 'three', rc: '.config/vim/gvimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc3)
+
+ " Test for ~/xdg/vim/gvimrc
+ let $XDG_CONFIG_HOME=expand('~/xdg/')
+ let lines =<< trim END
+ " Ignore the "failed to create input context" error.
+ call test_ignore_error('E285')
+ gui -f
+ let msg = $'HOME="{$HOME}", XDG_CONFIG_HOME="{$XDG_CONFIG_HOME}"'
+ call assert_match('Xhome/xdg/vim/gvimrc', $MYGVIMRC, msg)
+ call filter(g:, {idx, _ -> idx =~ '^rc'})
+ call assert_equal(#{rc_four: 'four', rc: 'xdg/vim/gvimrc'}, g:)
+ call writefile(v:errors, 'Xresult')
+ quit
+ END
+ call writefile(lines, 'Xscript', 'D')
+ call system($'{vimcmd} -S Xscript')
+ call assert_equal([], readfile('Xresult'))
+
+ call delete(rc4)
+
+ " Clean up
+ unlet $XDG_CONFIG_HOME
+ call GUITearDownCommon()
+ call delete('Xhome', 'rf')
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/testdir/vim9.vim b/src/testdir/vim9.vim
index 782809b..ff4db7b 100644
--- a/src/testdir/vim9.vim
+++ b/src/testdir/vim9.vim
@@ -110,40 +110,6 @@ export def CheckScriptSuccess(lines: list<string>)
endtry
enddef
-# :source a list of "lines" and check whether it fails with "error"
-export def CheckSourceFailure(lines: list<string>, error: string, lnum = -3)
- new
- setline(1, lines)
- try
- assert_fails('source', error, lines, lnum)
- finally
- bw!
- endtry
-enddef
-
-# :source a list of "lines" and check whether it fails with the list of
-# "errors"
-export def CheckSourceFailureList(lines: list<string>, errors: list<string>, lnum = -3)
- new
- setline(1, lines)
- try
- assert_fails('source', errors, lines, lnum)
- finally
- bw!
- endtry
-enddef
-
-# :source a list of "lines" and check whether it succeeds
-export def CheckSourceSuccess(lines: list<string>)
- new
- setline(1, lines)
- try
- :source
- finally
- bw!
- endtry
-enddef
-
export def CheckDefAndScriptSuccess(lines: list<string>)
CheckDefSuccess(lines)
CheckScriptSuccess(['vim9script'] + lines)
@@ -307,3 +273,177 @@ export def CheckLegacyAndVim9Failure(lines: list<string>, error: any)
CheckDefExecFailure(vim9lines, defError)
CheckScriptFailure(['vim9script'] + vim9lines, scriptError)
enddef
+
+# :source a list of "lines" and check whether it fails with "error"
+export def CheckSourceScriptFailure(lines: list<string>, error: string, lnum = -3)
+ var cwd = getcwd()
+ new
+ setline(1, lines)
+ var bnr = bufnr()
+ try
+ assert_fails('source', error, lines, lnum)
+ finally
+ chdir(cwd)
+ exe $':bw! {bnr}'
+ endtry
+enddef
+
+# :source a list of "lines" and check whether it fails with the list of
+# "errors"
+export def CheckSourceScriptFailureList(lines: list<string>, errors: list<string>, lnum = -3)
+ var cwd = getcwd()
+ new
+ var bnr = bufnr()
+ setline(1, lines)
+ try
+ assert_fails('source', errors, lines, lnum)
+ finally
+ chdir(cwd)
+ exe $':bw! {bnr}'
+ endtry
+enddef
+
+# :source a list of "lines" and check whether it succeeds
+export def CheckSourceScriptSuccess(lines: list<string>)
+ var cwd = getcwd()
+ new
+ var bnr = bufnr()
+ setline(1, lines)
+ try
+ :source
+ finally
+ chdir(cwd)
+ exe $':bw! {bnr}'
+ endtry
+enddef
+
+export def CheckSourceSuccess(lines: list<string>)
+ CheckSourceScriptSuccess(lines)
+enddef
+
+export def CheckSourceFailure(lines: list<string>, error: string, lnum = -3)
+ CheckSourceScriptFailure(lines, error, lnum)
+enddef
+
+export def CheckSourceFailureList(lines: list<string>, errors: list<string>, lnum = -3)
+ CheckSourceScriptFailureList(lines, errors, lnum)
+enddef
+
+# :source a List of "lines" inside a ":def" function and check that no error
+# occurs when called.
+export func CheckSourceDefSuccess(lines)
+ let cwd = getcwd()
+ new
+ let bnr = bufnr()
+ call setline(1, ['def Func()'] + a:lines + ['enddef', 'defcompile'])
+ try
+ source
+ call Func()
+ finally
+ call chdir(cwd)
+ delfunc! Func
+ exe $'bw! {bnr}'
+ endtry
+endfunc
+
+export def CheckSourceDefAndScriptSuccess(lines: list<string>)
+ CheckSourceDefSuccess(lines)
+ CheckSourceScriptSuccess(['vim9script'] + lines)
+enddef
+
+# Check that "lines" inside a ":def" function has no error when compiled.
+export func CheckSourceDefCompileSuccess(lines)
+ let cwd = getcwd()
+ new
+ let bnr = bufnr()
+ call setline(1, ['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'])
+ try
+ source
+ finally
+ call chdir(cwd)
+ delfunc! Func
+ exe $':bw! {bnr}'
+ endtry
+endfunc
+
+# Check that "lines" inside ":def" results in an "error" message.
+# If "lnum" is given check that the error is reported for this line.
+# Add a line before and after to make it less likely that the line number is
+# accidentally correct.
+export func CheckSourceDefFailure(lines, error, lnum = -3)
+ let cwd = getcwd()
+ new
+ let bnr = bufnr()
+ call setline(1, ['def Func()', '# comment'] + a:lines + ['#comment', 'enddef', 'defcompile'])
+ try
+ call assert_fails('source', a:error, a:lines, a:lnum + 1)
+ finally
+ call chdir(cwd)
+ delfunc! Func
+ exe $':bw! {bnr}'
+ endtry
+endfunc
+
+# Check that "lines" inside ":def" results in an "error" message when executed.
+# If "lnum" is given check that the error is reported for this line.
+# Add a line before and after to make it less likely that the line number is
+# accidentally correct.
+export func CheckSourceDefExecFailure(lines, error, lnum = -3)
+ let cwd = getcwd()
+ new
+ let bnr = bufnr()
+ call setline(1, ['def Func()', '# comment'] + a:lines + ['#comment', 'enddef'])
+ try
+ source
+ call assert_fails('call Func()', a:error, a:lines, a:lnum + 1)
+ finally
+ call chdir(cwd)
+ delfunc! Func
+ exe $':bw! {bnr}'
+ endtry
+endfunc
+
+# Check that a command fails when used in a :def function and when used in
+# Vim9 script.
+# When "error" is a string, both with the same error.
+# When "error" is a list, the :def function fails with "error[0]" , the script
+# fails with "error[1]".
+export def CheckSourceDefAndScriptFailure(lines: list<string>, error: any, lnum = -3)
+ var errorDef: string
+ var errorScript: string
+ if type(error) == v:t_string
+ errorDef = error
+ errorScript = error
+ elseif type(error) == v:t_list && len(error) == 2
+ errorDef = error[0]
+ errorScript = error[1]
+ else
+ echoerr 'error argument must be a string or a list with two items'
+ return
+ endif
+ CheckSourceDefFailure(lines, errorDef, lnum)
+ CheckSourceScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
+enddef
+
+# Check that a command fails when executed in a :def function and when used in
+# Vim9 script.
+# When "error" is a string, both with the same error.
+# When "error" is a list, the :def function fails with "error[0]" , the script
+# fails with "error[1]".
+export def CheckSourceDefExecAndScriptFailure(lines: list<string>, error: any, lnum = -3)
+ var errorDef: string
+ var errorScript: string
+ if type(error) == v:t_string
+ errorDef = error
+ errorScript = error
+ elseif type(error) == v:t_list && len(error) == 2
+ errorDef = error[0]
+ errorScript = error[1]
+ else
+ echoerr 'error argument must be a string or a list with two items'
+ return
+ endif
+ CheckSourceDefExecFailure(lines, errorDef, lnum)
+ CheckSourceScriptFailure(['vim9script'] + lines, errorScript, lnum + 1)
+enddef
+