diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-29 21:45:34 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-29 21:45:34 +0000 |
commit | 62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d (patch) | |
tree | 8f2962626c458f5ac5fa1f2ec46e79248683c81d /src/testdir/test_expr.vim | |
parent | 135e15251efd96c960e51e8ab31333c2d6887983 (diff) | |
download | vim-git-62aec93bfdb9e1b40d03a6d2e8e9511f8b1bdb2d.tar.gz |
patch 8.2.4257: Vim9: finding global function without g: prefix inconsistentv8.2.4257
Problem: Vim9: finding global function without g: prefix but not finding
global variable is inconsistent.
Solution: Require using g: for a global function. Change the vim9.vim
script into a Vim9 script with exports. Fix that import in legacy
script does not work.
Diffstat (limited to 'src/testdir/test_expr.vim')
-rw-r--r-- | src/testdir/test_expr.vim | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim index 8a65a8990..4d085de1d 100644 --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -1,7 +1,7 @@ " Tests for expressions. source check.vim -source vim9.vim +import './vim9.vim' as v9 func Test_equal() let base = {} @@ -51,12 +51,12 @@ func Test_op_trinary() call assert_fails('echo [1] ? "yes" : "no"', 'E745:') call assert_fails('echo {} ? "yes" : "no"', 'E728:') END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_equal('no', 'x' ? 'yes' : 'no') - call CheckDefAndScriptFailure(["'x' ? 'yes' : 'no'"], 'E1135:') + call v9.CheckDefAndScriptFailure(["'x' ? 'yes' : 'no'"], 'E1135:') call assert_equal('yes', '1x' ? 'yes' : 'no') - call CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:') + call v9.CheckDefAndScriptFailure(["'1x' ? 'yes' : 'no'"], 'E1135:') endfunc func Test_op_falsy() @@ -81,7 +81,7 @@ func Test_op_falsy() call assert_equal(456, 0.0 ?? 456) endif END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_dict() @@ -101,9 +101,9 @@ func Test_dict() LET d[ 'b' ] = 'bbb' call assert_equal('bbb', d[ 'b' ]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E715:', 'E1013:', 'E1206:']) + call v9.CheckLegacyAndVim9Failure(["VAR i = has_key([], 'a')"], ['E715:', 'E1013:', 'E1206:']) endfunc func Test_strgetchar() @@ -116,10 +116,10 @@ func Test_strgetchar() call assert_equal(-1, strgetchar('axb', 3)) call assert_equal(-1, strgetchar('', 0)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:']) - call CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar([], 1)"], ['E730:', 'E1013:', 'E1174:']) + call v9.CheckLegacyAndVim9Failure(["VAR c = strgetchar('axb', [])"], ['E745:', 'E1013:', 'E1210:']) endfunc func Test_strcharpart() @@ -138,7 +138,7 @@ func Test_strcharpart() call assert_equal('edit', "editor"[-10 : 3]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_getreg_empty_list() @@ -150,9 +150,9 @@ func Test_getreg_empty_list() call add(x, 'foo') call assert_equal(['foo'], y) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:']) + call v9.CheckLegacyAndVim9Failure(['call getreg([])'], ['E730:', 'E1013:', 'E1174:']) endfunc func Test_loop_over_null_list() @@ -162,19 +162,19 @@ func Test_loop_over_null_list() call assert_report('should not get here') endfor END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_setreg_null_list() let lines =<< trim END call setreg('x', test_null_list()) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_special_char() " The failure is only visible using valgrind. - call CheckLegacyAndVim9Failure(['echo "\<C-">'], ['E15:', 'E1004:', 'E1004:']) + call v9.CheckLegacyAndVim9Failure(['echo "\<C-">'], ['E15:', 'E1004:', 'E1004:']) endfunc func Test_method_with_prefix() @@ -182,13 +182,13 @@ func Test_method_with_prefix() call assert_equal(TRUE, !range(5)->empty()) call assert_equal(FALSE, !-3) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) call assert_equal([0, 1, 2], --3->range()) - call CheckDefAndScriptFailure(['eval --3->range()'], 'E15') + call v9.CheckDefAndScriptFailure(['eval --3->range()'], 'E15') call assert_equal(1, !+-+0) - call CheckDefAndScriptFailure(['eval !+-+0'], 'E15') + call v9.CheckDefAndScriptFailure(['eval !+-+0'], 'E15') endfunc func Test_option_value() @@ -214,7 +214,7 @@ func Test_option_value() call assert_equal("abcdefgi", &cpo) set cpo&vim END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_printf_misc() @@ -407,9 +407,9 @@ func Test_printf_misc() call assert_equal('1%', printf('%d%%', 1)) call assert_notequal('', printf('%p', "abc")) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:") + call v9.CheckLegacyAndVim9Failure(["call printf('123', 3)"], "E767:") endfunc func Test_printf_float() @@ -519,21 +519,21 @@ func Test_printf_float() call assert_equal('nan', printf('%S', 0.0 / 0.0)) call assert_equal('nan', printf('%S', -0.0 / 0.0)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%f", "a")'], 'E807:') endif endfunc func Test_printf_errors() - call CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:') - call CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:') - call CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:') - call CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:') - call CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", {})'], 'E728:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", [])'], 'E745:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1, 2)'], 'E767:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%*d", 1)'], 'E766:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%s")'], 'E766:') if has('float') - call CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:') - call CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%d", 1.2)'], 'E805:') + call v9.CheckLegacyAndVim9Failure(['echo printf("%f")'], 'E766:') endif endfunc @@ -541,7 +541,7 @@ func Test_printf_64bit() let lines =<< trim END call assert_equal("123456789012345", printf('%d', 123456789012345)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_printf_spec_s() @@ -571,7 +571,7 @@ func Test_printf_spec_s() #" partial call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s']))) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_printf_spec_b() @@ -587,14 +587,14 @@ func Test_printf_spec_b() call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345)) call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_max_min_errors() - call CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:']) - call CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:']) - call CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:']) - call CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['E712:', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call max(v:true)'], ['max()', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['E712:', 'E1013:', 'E1227:']) + call v9.CheckLegacyAndVim9Failure(['call min(v:true)'], ['min()', 'E1013:', 'E1227:']) endfunc func Test_function_with_funcref() @@ -615,9 +615,9 @@ func Test_function_with_funcref() call execute('VAR Ref = ' .. name) call assert_equal(4, Ref('text')) END - call CheckTransLegacySuccess(lines) + call v9.CheckTransLegacySuccess(lines) " cannot create s: variable in :def function - call CheckTransVim9Success(lines) + call v9.CheckTransVim9Success(lines) endfunc func Test_funcref() @@ -668,9 +668,9 @@ func Test_setmatches() eval set->setmatches() call assert_equal(exp, getmatches()) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) - call CheckLegacyAndVim9Failure(['VAR m = setmatches([], [])'], ['E745:', 'E1013:', 'E1210:']) + call v9.CheckLegacyAndVim9Failure(['VAR m = setmatches([], [])'], ['E745:', 'E1013:', 'E1210:']) endfunc func Test_empty_concatenate() @@ -678,19 +678,19 @@ func Test_empty_concatenate() call assert_equal('b', 'a'[4 : 0] .. 'b') call assert_equal('b', 'b' .. 'a'[4 : 0]) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc func Test_broken_number() - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:') - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:') - call CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:') - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:') - call CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 011X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 1X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0b1X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['echo 0b12'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 0x1X'], 'E15:') + call v9.CheckLegacyAndVim9Failure(['VAR X = "bad"', 'echo 011X'], 'E15:') - call CheckLegacyAndVim9Success(['call assert_equal(2, str2nr("2a"))']) + call v9.CheckLegacyAndVim9Success(['call assert_equal(2, str2nr("2a"))']) - call CheckLegacyAndVim9Failure(['inoremap <Char-0b1z> b'], 'E474:') + call v9.CheckLegacyAndVim9Failure(['inoremap <Char-0b1z> b'], 'E474:') endfunc func Test_eval_after_if() @@ -783,11 +783,11 @@ endfunc " Test for errors in expression evaluation func Test_expr_eval_error() - call CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:']) - call CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745']) - call CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:']) - call CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:']) - call CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:']) + call v9.CheckLegacyAndVim9Failure(["VAR i = 'abc' .. []"], ['E730:', 'E1105:', 'E730:']) + call v9.CheckLegacyAndVim9Failure(["VAR l = [] + 10"], ['E745:', 'E1051:', 'E745']) + call v9.CheckLegacyAndVim9Failure(["VAR v = 10 + []"], ['E745:', 'E1051:', 'E745:']) + call v9.CheckLegacyAndVim9Failure(["VAR v = 10 / []"], ['E745:', 'E1036:', 'E745:']) + call v9.CheckLegacyAndVim9Failure(["VAR v = -{}"], ['E728:', 'E1012:', 'E728:']) endfunc func Test_white_in_function_call() @@ -795,13 +795,13 @@ func Test_white_in_function_call() VAR text = substitute ( 'some text' , 't' , 'T' , 'g' ) call assert_equal('some TexT', text) END - call CheckTransLegacySuccess(lines) + call v9.CheckTransLegacySuccess(lines) let lines =<< trim END var text = substitute ( 'some text' , 't' , 'T' , 'g' ) call assert_equal('some TexT', text) END - call CheckDefAndScriptFailure(lines, ['E1001:', 'E121:']) + call v9.CheckDefAndScriptFailure(lines, ['E1001:', 'E121:']) endfunc " Test for float value comparison @@ -825,7 +825,7 @@ func Test_float_compare() #" +infinity != -infinity call assert_true((1.0 / 0) != -(2.0 / 0)) END - call CheckLegacyAndVim9Success(lines) + call v9.CheckLegacyAndVim9Success(lines) endfunc " vim: shiftwidth=2 sts=2 expandtab |