# HG changeset patch # User Bram Moolenaar # Date 1580405404 -3600 # Node ID 2a017e9dc6dafdb169655b413429e9528163229b # Parent 5e803caf5e9cc369edda74be5c9421d788736f03 patch 8.2.0183: tests fail when the float feature is disabled Commit: https://github.com/vim/vim/commit/5feabe00c47fa66d5f4c95213f150488433f78e3 Author: Bram Moolenaar Date: Thu Jan 30 18:24:53 2020 +0100 patch 8.2.0183: tests fail when the float feature is disabled Problem: Tests fail when the float feature is disabled. Solution: Skip tests that don't work without float support. diff --git a/src/testdir/shared.vim b/src/testdir/shared.vim --- a/src/testdir/shared.vim +++ b/src/testdir/shared.vim @@ -156,7 +156,7 @@ endfunc func s:WaitForCommon(expr, assert, timeout) " using reltime() is more accurate, but not always available let slept = 0 - if has('reltime') + if exists('*reltimefloat') let start = reltime() endif @@ -181,7 +181,7 @@ func s:WaitForCommon(expr, assert, timeo endif sleep 10m - if has('reltime') + if exists('*reltimefloat') let slept = float2nr(reltimefloat(reltime(start)) * 1000) else let slept += 10 @@ -197,7 +197,7 @@ endfunc " feeds key-input and resumes process. Return time waited in milliseconds. " Without +timers it uses simply :sleep. func Standby(msec) - if has('timers') + if has('timers') && exists('*reltimefloat') let start = reltime() let g:_standby_timer = timer_start(a:msec, function('s:feedkeys')) call getchar() diff --git a/src/testdir/test_blob.vim b/src/testdir/test_blob.vim --- a/src/testdir/test_blob.vim +++ b/src/testdir/test_blob.vim @@ -324,5 +324,5 @@ func Test_blob_lock() endfunc func Test_blob_sort() - call assert_fails('call sort([1.0, 0z11], "f")', 'E975:') + call assert_fails('call sort(["abc", 0z11], "f")', 'E702:') endfunc diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -202,10 +202,12 @@ func Ch_communicate(port) " Reading while there is nothing available. call assert_equal(v:none, ch_read(handle, {'timeout': 0})) - let start = reltime() - call assert_equal(v:none, ch_read(handle, {'timeout': 333})) - let elapsed = reltime(start) - call assert_inrange(0.3, 0.6, reltimefloat(reltime(start))) + if exists('*reltimefloat') + let start = reltime() + call assert_equal(v:none, ch_read(handle, {'timeout': 333})) + let elapsed = reltime(start) + call assert_inrange(0.3, 0.6, reltimefloat(reltime(start))) + endif " Send without waiting for a response, then wait for a response. call ch_sendexpr(handle, 'wait a bit') @@ -412,6 +414,8 @@ endfunc " Test that trying to connect to a non-existing port fails quickly. func Test_connect_waittime() + CheckFunction reltimefloat + call ch_log('Test_connect_waittime()') let start = reltime() let handle = ch_open('localhost:9876', s:chopt) @@ -927,6 +931,8 @@ func Test_pipe_to_nameless_buffer() endfunc func Test_pipe_to_buffer_json() + CheckFunction reltimefloat + let job = job_start(s:python . " test_channel_pipe.py", \ {'out_io': 'buffer', 'out_mode': 'json'}) call assert_equal("run", job_status(job)) @@ -1423,6 +1429,8 @@ function MyExitTimeCb(job, status) endfunction func Test_exit_callback_interval() + CheckFunction reltimefloat + let g:exit_cb_val = {'start': reltime(), 'end': 0, 'process': 0} let job = [s:python, '-c', 'import time;time.sleep(0.5)']->job_start({'exit_cb': 'MyExitTimeCb'}) let g:exit_cb_val.process = job_info(job).process @@ -1768,6 +1776,7 @@ endfunc func Test_job_start_in_timer() CheckFeature timers + CheckFeature reltimefloat func OutCb(chan, msg) let g:val += 1 diff --git a/src/testdir/test_cscope.vim b/src/testdir/test_cscope.vim --- a/src/testdir/test_cscope.vim +++ b/src/testdir/test_cscope.vim @@ -116,23 +116,25 @@ func Test_cscopeWithCscopeConnections() " Test 10: Invalid find command call assert_fails('cs find x', 'E560:') - " Test 11: Find places where this symbol is assigned a value - " this needs a cscope >= 15.8 - " unfortunately, Travis has cscope version 15.7 - let cscope_version = systemlist('cscope --version')[0] - let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) - if cs_version >= 15.8 - for cmd in ['cs find a item', 'cs find 9 item'] - let a = execute(cmd) - call assert_equal(['', '(1 of 4): <> item = LALLOC_CLEAR_ONE(mf_hashitem_T);'], split(a, '\n', 1)) - call assert_equal(' item = LALLOC_CLEAR_ONE(mf_hashitem_T);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - cnext - call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) - endfor + if has('float') + " Test 11: Find places where this symbol is assigned a value + " this needs a cscope >= 15.8 + " unfortunately, Travis has cscope version 15.7 + let cscope_version = systemlist('cscope --version')[0] + let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) + if cs_version >= 15.8 + for cmd in ['cs find a item', 'cs find 9 item'] + let a = execute(cmd) + call assert_equal(['', '(1 of 4): <> item = LALLOC_CLEAR_ONE(mf_hashitem_T);'], split(a, '\n', 1)) + call assert_equal(' item = LALLOC_CLEAR_ONE(mf_hashitem_T);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + cnext + call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) + endfor + endif endif " Test 12: leading whitespace is not removed for cscope find text diff --git a/src/testdir/test_execute_func.vim b/src/testdir/test_execute_func.vim --- a/src/testdir/test_execute_func.vim +++ b/src/testdir/test_execute_func.vim @@ -30,14 +30,16 @@ func Test_execute_string() call assert_equal("\nthat", evaled) call assert_fails('call execute("doesnotexist")', 'E492:') - call assert_fails('call execute(3.4)', 'E806:') call assert_fails('call execute("call NestedRedir()")', 'E930:') call assert_equal("\nsomething", execute('echo "something"', '')) call assert_equal("\nsomething", execute('echo "something"', 'silent')) call assert_equal("\nsomething", execute('echo "something"', 'silent!')) call assert_equal("", execute('burp', 'silent!')) - call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:') + if has('float') + call assert_fails('call execute(3.4)', 'E806:') + call assert_fails('call execute("echo \"x\"", 3.4)', 'E806:') + endif endfunc func Test_execute_list() diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim --- a/src/testdir/test_expr.vim +++ b/src/testdir/test_expr.vim @@ -369,7 +369,9 @@ function Test_printf_errors() call assert_fails('echo printf("%d", [])', 'E745:') call assert_fails('echo printf("%d", 1, 2)', 'E767:') call assert_fails('echo printf("%*d", 1)', 'E766:') - call assert_fails('echo printf("%d", 1.2)', 'E805:') + if has('float') + call assert_fails('echo printf("%d", 1.2)', 'E805:') + endif endfunc function Test_max_min_errors() diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim --- a/src/testdir/test_functions.vim +++ b/src/testdir/test_functions.vim @@ -28,12 +28,14 @@ func Test_empty() call assert_equal(0, empty(1)) call assert_equal(0, empty(-1)) - call assert_equal(1, empty(0.0)) - call assert_equal(1, empty(-0.0)) - call assert_equal(0, empty(1.0)) - call assert_equal(0, empty(-1.0)) - call assert_equal(0, empty(1.0/0.0)) - call assert_equal(0, empty(0.0/0.0)) + if has('float') + call assert_equal(1, empty(0.0)) + call assert_equal(1, empty(-0.0)) + call assert_equal(0, empty(1.0)) + call assert_equal(0, empty(-1.0)) + call assert_equal(0, empty(1.0/0.0)) + call assert_equal(0, empty(0.0/0.0)) + endif call assert_equal(1, empty([])) call assert_equal(0, empty(['a'])) @@ -116,7 +118,9 @@ func Test_strwidth() call assert_fails('call strwidth({->0})', 'E729:') call assert_fails('call strwidth([])', 'E730:') call assert_fails('call strwidth({})', 'E731:') - call assert_fails('call strwidth(1.2)', 'E806:') + if has('float') + call assert_fails('call strwidth(1.2)', 'E806:') + endif endfor set ambiwidth& @@ -176,7 +180,9 @@ func Test_str2nr() call assert_fails('call str2nr([])', 'E730:') call assert_fails('call str2nr({->2})', 'E729:') - call assert_fails('call str2nr(1.2)', 'E806:') + if has('float') + call assert_fails('call str2nr(1.2)', 'E806:') + endif call assert_fails('call str2nr(10, [])', 'E474:') endfunc @@ -422,7 +428,9 @@ func Test_simplify() call assert_fails('call simplify({->0})', 'E729:') call assert_fails('call simplify([])', 'E730:') call assert_fails('call simplify({})', 'E731:') - call assert_fails('call simplify(1.2)', 'E806:') + if has('float') + call assert_fails('call simplify(1.2)', 'E806:') + endif endfunc func Test_pathshorten() diff --git a/src/testdir/test_glob2regpat.vim b/src/testdir/test_glob2regpat.vim --- a/src/testdir/test_glob2regpat.vim +++ b/src/testdir/test_glob2regpat.vim @@ -1,7 +1,9 @@ " Test glob2regpat() func Test_glob2regpat_invalid() - call assert_fails('call glob2regpat(1.33)', 'E806:') + if has('float') + call assert_fails('call glob2regpat(1.33)', 'E806:') + endif call assert_fails('call glob2regpat("}")', 'E219:') call assert_fails('call glob2regpat("{")', 'E220:') endfunc diff --git a/src/testdir/test_lambda.vim b/src/testdir/test_lambda.vim --- a/src/testdir/test_lambda.vim +++ b/src/testdir/test_lambda.vim @@ -216,7 +216,9 @@ endfunc func Test_lambda_combination() call assert_equal(2, {x -> {x -> x}}(1)(2)) call assert_equal(10, {y -> {x -> x(y)(10)}({y -> y})}({z -> z})) - call assert_equal(5.0, {x -> {y -> x / y}}(10)(2.0)) + if has('float') + call assert_equal(5.0, {x -> {y -> x / y}}(10)(2.0)) + endif call assert_equal(6, {x -> {y -> {z -> x + y + z}}}(1)(2)(3)) call assert_equal(6, {x -> {f -> f(x)}}(3)({x -> x * 2})) diff --git a/src/testdir/test_listdict.vim b/src/testdir/test_listdict.vim --- a/src/testdir/test_listdict.vim +++ b/src/testdir/test_listdict.vim @@ -596,18 +596,20 @@ func Test_reverse_sort_uniq() call assert_equal(['-0', 'A11', 2, 'xaaa', 4, 'foo', 'foo6', 'foo', [0, 1, 2], 'x8', [0, 1, 2], 1.5], uniq(copy(l))) call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(l)) call assert_equal([1.5, [0, 1, 2], 'x8', [0, 1, 2], 'foo', 'foo6', 'foo', 4, 'xaaa', 2, 2, 'A11', '-0'], reverse(reverse(l))) - call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(l)) - call assert_equal([[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0'], reverse(sort(l))) - call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(reverse(sort(l)))) - call assert_equal(['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]], uniq(sort(l))) + if has('float') + call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(l)) + call assert_equal([[0, 1, 2], [0, 1, 2], 4, 2, 2, 1.5, 'xaaa', 'x8', 'foo6', 'foo', 'foo', 'A11', '-0'], reverse(sort(l))) + call assert_equal(['-0', 'A11', 'foo', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 2, 4, [0, 1, 2], [0, 1, 2]], sort(reverse(sort(l)))) + call assert_equal(['-0', 'A11', 'foo', 'foo6', 'x8', 'xaaa', 1.5, 2, 4, [0, 1, 2]], uniq(sort(l))) - let l=[7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four'] - call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n')) + let l = [7, 9, 'one', 18, 12, 22, 'two', 10.0e-16, -1, 'three', 0xff, 0.22, 'four'] + call assert_equal([-1, 'one', 'two', 'three', 'four', 1.0e-15, 0.22, 7, 9, 12, 18, 22, 255], sort(copy(l), 'n')) - let l=[7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []] - call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 1)) - call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) - call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l))) + let l = [7, 9, 18, 12, 22, 10.0e-16, -1, 0xff, 0, -0, 0.22, 'bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', {}, []] + call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 1)) + call assert_equal(['bar', 'BAR', 'Bar', 'Foo', 'FOO', 'foo', 'FOOBAR', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l), 'i')) + call assert_equal(['BAR', 'Bar', 'FOO', 'FOOBAR', 'Foo', 'bar', 'foo', -1, 0, 0, 0.22, 1.0e-15, 12, 18, 22, 255, 7, 9, [], {}], sort(copy(l))) + endif call assert_fails('call reverse("")', 'E899:') endfunc @@ -683,7 +685,9 @@ func Test_listdict_extend() let l = [1, 2, 3] call assert_fails("call extend(l, [4, 5, 6], 4)", 'E684:') call assert_fails("call extend(l, [4, 5, 6], -4)", 'E684:') - call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:') + if has('float') + call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:') + endif " Test extend() with dictionaries. @@ -707,7 +711,9 @@ func Test_listdict_extend() let d = {'a': 'A', 'b': 'B'} call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'error')", 'E737:') call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:') - call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E806:') + if has('float') + call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 1.2)", 'E806:') + endif call assert_equal({'a': 'A', 'b': 'B'}, d) call assert_fails("call extend([1, 2], 1)", 'E712:') diff --git a/src/testdir/test_lua.vim b/src/testdir/test_lua.vim --- a/src/testdir/test_lua.vim +++ b/src/testdir/test_lua.vim @@ -2,6 +2,7 @@ source check.vim CheckFeature lua +CheckFeature float func TearDown() " Run garbage collection after each test to exercise luaV_setref(). @@ -9,7 +10,7 @@ func TearDown() endfunc " Check that switching to another buffer does not trigger ml_get error. -func Test_command_new_no_ml_get_error() +func Test_lua_command_new_no_ml_get_error() new let wincount = winnr('$') call setline(1, ['one', 'two', 'three']) @@ -19,7 +20,7 @@ func Test_command_new_no_ml_get_error() endfunc " Test vim.command() -func Test_command() +func Test_lua_command() new call setline(1, ['one', 'two', 'three']) luado vim.command("1,2d_") @@ -28,7 +29,7 @@ func Test_command() endfunc " Test vim.eval() -func Test_eval() +func Test_lua_eval() " lua.eval with a number lua v = vim.eval('123') call assert_equal('number', luaeval('vim.type(v)')) @@ -69,7 +70,7 @@ func Test_eval() endfunc " Test vim.window() -func Test_window() +func Test_lua_window() e Xfoo2 new Xfoo1 @@ -85,7 +86,7 @@ func Test_window() endfunc " Test vim.window().height -func Test_window_height() +func Test_lua_window_height() new lua vim.window().height = 2 call assert_equal(2, winheight(0)) @@ -95,7 +96,7 @@ func Test_window_height() endfunc " Test vim.window().width -func Test_window_width() +func Test_lua_window_width() vert new lua vim.window().width = 2 call assert_equal(2, winwidth(0)) @@ -105,7 +106,7 @@ func Test_window_width() endfunc " Test vim.window().line and vim.window.col -func Test_window_line_col() +func Test_lua_window_line_col() new call setline(1, ['line1', 'line2', 'line3']) lua vim.window().line = 2 @@ -121,7 +122,7 @@ func Test_window_line_col() endfunc " Test setting the current window -func Test_window_set_current() +func Test_lua_window_set_current() new Xfoo1 lua w1 = vim.window() new Xfoo2 @@ -138,7 +139,7 @@ func Test_window_set_current() endfunc " Test vim.window().buffer -func Test_window_buffer() +func Test_lua_window_buffer() new Xfoo1 lua w1 = vim.window() lua b1 = w1.buffer() @@ -156,7 +157,7 @@ func Test_window_buffer() endfunc " Test vim.window():previous() and vim.window():next() -func Test_window_next_previous() +func Test_lua_window_next_previous() new Xfoo1 new Xfoo2 new Xfoo3 @@ -170,7 +171,7 @@ func Test_window_next_previous() endfunc " Test vim.window():isvalid() -func Test_window_isvalid() +func Test_lua_window_isvalid() new Xfoo lua w = vim.window() call assert_true(luaeval('w:isvalid()')) @@ -183,7 +184,7 @@ func Test_window_isvalid() endfunc " Test vim.buffer() with and without argument -func Test_buffer() +func Test_lua_buffer() new Xfoo1 let bn1 = bufnr('%') new Xfoo2 @@ -205,7 +206,7 @@ func Test_buffer() endfunc " Test vim.buffer().name and vim.buffer().fname -func Test_buffer_name() +func Test_lua_buffer_name() new call assert_equal('', luaeval('vim.buffer().name')) call assert_equal('', luaeval('vim.buffer().fname')) @@ -218,13 +219,13 @@ func Test_buffer_name() endfunc " Test vim.buffer().number -func Test_buffer_number() +func Test_lua_buffer_number() " All numbers in Lua are floating points number (no integers). call assert_equal(bufnr('%'), float2nr(luaeval('vim.buffer().number'))) endfunc " Test inserting lines in buffer. -func Test_buffer_insert() +func Test_lua_buffer_insert() new lua vim.buffer()[1] = '3' lua vim.buffer():insert('1', 0) @@ -236,7 +237,7 @@ func Test_buffer_insert() endfunc " Test deleting line in buffer -func Test_buffer_delete() +func Test_lua_buffer_delete() new call setline(1, ['1', '2', '3']) lua vim.buffer()[2] = nil @@ -248,7 +249,7 @@ func Test_buffer_delete() endfunc " Test #vim.buffer() i.e. number of lines in buffer -func Test_buffer_number_lines() +func Test_lua_buffer_number_lines() new call setline(1, ['a', 'b', 'c']) call assert_equal(3.0, luaeval('#vim.buffer()')) @@ -258,7 +259,7 @@ endfunc " Test vim.buffer():next() and vim.buffer():previous() " Note that these functions get the next or previous buffers " but do not switch buffer. -func Test_buffer_next_previous() +func Test_lua_buffer_next_previous() new Xfoo1 new Xfoo2 new Xfoo3 @@ -286,7 +287,7 @@ func Test_buffer_next_previous() endfunc " Test vim.buffer():isvalid() -func Test_buffer_isvalid() +func Test_lua_buffer_isvalid() new Xfoo lua b = vim.buffer() call assert_true(luaeval('b:isvalid()')) @@ -298,7 +299,7 @@ func Test_buffer_isvalid() bwipe! endfunc -func Test_list() +func Test_lua_list() call assert_equal([], luaeval('vim.list()')) let l = [] @@ -326,7 +327,7 @@ func Test_list() lua l = nil endfunc -func Test_list_table() +func Test_lua_list_table() " See :help lua-vim " Non-numeric keys should not be used to initialize the list " so say = 'hi' should be ignored. @@ -341,7 +342,7 @@ func Test_list_table() endfunc " Test l() i.e. iterator on list -func Test_list_iter() +func Test_lua_list_iter() lua l = vim.list():add('foo'):add('bar') lua str = '' lua for v in l() do str = str .. v end @@ -350,7 +351,7 @@ func Test_list_iter() lua str, l = nil endfunc -func Test_recursive_list() +func Test_lua_recursive_list() lua l = vim.list():add(1):add(2) lua l = l:add(l) @@ -374,7 +375,7 @@ func Test_recursive_list() lua l = nil endfunc -func Test_dict() +func Test_lua_dict() call assert_equal({}, luaeval('vim.dict()')) let d = {} @@ -401,7 +402,7 @@ func Test_dict() lua d = nil endfunc -func Test_dict_table() +func Test_lua_dict_table() lua t = {key1 = 'x', key2 = 3.14, key3 = true, key4 = false} call assert_equal({'key1': 'x', 'key2': 3.14, 'key3': v:true, 'key4': v:false}, \ luaeval('vim.dict(t)')) @@ -422,7 +423,7 @@ func Test_dict_table() endfunc " Test d() i.e. iterator on dictionary -func Test_dict_iter() +func Test_lua_dict_iter() let d = {'a': 1, 'b':2} lua d = vim.eval('d') lua str = '' @@ -432,7 +433,7 @@ func Test_dict_iter() lua str, d = nil endfunc -func Test_blob() +func Test_lua_blob() call assert_equal(0z, luaeval('vim.blob("")')) call assert_equal(0z31326162, luaeval('vim.blob("12ab")')) call assert_equal(0z00010203, luaeval('vim.blob("\x00\x01\x02\x03")')) @@ -456,7 +457,7 @@ func Test_blob() lua b = nil endfunc -func Test_funcref() +func Test_lua_funcref() function I(x) return a:x endfunction @@ -483,7 +484,7 @@ func Test_funcref() endfunc " Test vim.type() -func Test_type() +func Test_lua_type() " The following values are identical to Lua's type function. call assert_equal('string', luaeval('vim.type("foo")')) call assert_equal('number', luaeval('vim.type(1)')) @@ -503,7 +504,7 @@ func Test_type() endfunc " Test vim.open() -func Test_open() +func Test_lua_open() call assert_notmatch('XOpen', execute('ls')) " Open a buffer XOpen1, but do not jump to it. @@ -524,7 +525,7 @@ func Test_open() endfunc " Test vim.line() -func Test_line() +func Test_lua_line() new call setline(1, ['first line', 'second line']) 1 @@ -535,7 +536,7 @@ func Test_line() endfunc " Test vim.beep() -func Test_beep() +func Test_lua_beep() call assert_beeps('lua vim.beep()') endfunc @@ -591,7 +592,7 @@ func Test_luafile_error() bwipe! endfunc -func Test_set_cursor() +func Test_lua_set_cursor() " Check that setting the cursor position works. new call setline(1, ['first line', 'second line']) diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -615,9 +615,8 @@ func Test_local_scrolloff() endfunc func Test_writedelay() - if !has('reltime') - return - endif + CheckFunction reltimefloat + new call setline(1, 'empty') redraw diff --git a/src/testdir/test_partial.vim b/src/testdir/test_partial.vim --- a/src/testdir/test_partial.vim +++ b/src/testdir/test_partial.vim @@ -106,7 +106,7 @@ fun InnerCall(funcref) endfu fun OuterCall() - let opt = { 'func' : function('sin') } + let opt = { 'func' : function('max') } call InnerCall(opt.func) endfu diff --git a/src/testdir/test_regexp_latin.vim b/src/testdir/test_regexp_latin.vim --- a/src/testdir/test_regexp_latin.vim +++ b/src/testdir/test_regexp_latin.vim @@ -2,6 +2,8 @@ set encoding=latin1 scriptencoding latin1 +source check.vim + func s:equivalence_test() let str = "AÀÁÂÃÄÅ B C D EÈÉÊË F G H IÌÍÎÏ J K L M NÑ OÒÓÔÕÖØ P Q R S T UÙÚÛÜ V W X YÝ Z aàáâãäå b c d eèéêë f g h iìíîï j k l m nñ oòóôõöø p q r s t uùúûü v w x yýÿ z" let groups = split(str) @@ -132,9 +134,9 @@ func Test_range_with_newline() endfunc func Test_pattern_compile_speed() - if !exists('+spellcapcheck') || !has('reltime') - return - endif + CheckOption spellcapcheck + CheckFunction reltimefloat + let start = reltime() " this used to be very slow, not it should be about a second set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179} diff --git a/src/testdir/test_ruby.vim b/src/testdir/test_ruby.vim --- a/src/testdir/test_ruby.vim +++ b/src/testdir/test_ruby.vim @@ -34,7 +34,7 @@ func Test_rubyfile() call delete(tempfile) endfunc -func Test_set_cursor() +func Test_ruby_set_cursor() " Check that setting the cursor position works. new call setline(1, ['first line', 'second line']) @@ -54,7 +54,7 @@ func Test_set_cursor() endfunc " Test buffer.count and buffer.length (number of lines in buffer) -func Test_buffer_count() +func Test_ruby_buffer_count() new call setline(1, ['one', 'two', 'three']) call assert_equal(3, rubyeval('$curbuf.count')) @@ -63,7 +63,7 @@ func Test_buffer_count() endfunc " Test buffer.name (buffer name) -func Test_buffer_name() +func Test_ruby_buffer_name() new Xfoo call assert_equal(expand('%:p'), rubyeval('$curbuf.name')) bwipe @@ -71,7 +71,7 @@ func Test_buffer_name() endfunc " Test buffer.number (number of the buffer). -func Test_buffer_number() +func Test_ruby_buffer_number() new call assert_equal(bufnr('%'), rubyeval('$curbuf.number')) new @@ -81,7 +81,7 @@ func Test_buffer_number() endfunc " Test buffer.delete({n}) (delete line {n}) -func Test_buffer_delete() +func Test_ruby_buffer_delete() new call setline(1, ['one', 'two', 'three']) ruby $curbuf.delete(2) @@ -94,7 +94,7 @@ func Test_buffer_delete() endfunc " Test buffer.append({str}, str) (append line {str} after line {n}) -func Test_buffer_append() +func Test_ruby_buffer_append() new ruby $curbuf.append(0, 'one') ruby $curbuf.append(1, 'three') @@ -112,7 +112,7 @@ func Test_buffer_append() endfunc " Test buffer.line (get or set the current line) -func Test_buffer_line() +func Test_ruby_buffer_line() new call setline(1, ['one', 'two', 'three']) 2 @@ -125,7 +125,7 @@ func Test_buffer_line() endfunc " Test buffer.line_number (get current line number) -func Test_buffer_line_number() +func Test_ruby_buffer_line_number() new call setline(1, ['one', 'two', 'three']) 2 @@ -134,7 +134,7 @@ func Test_buffer_line_number() bwipe! endfunc -func Test_buffer_get() +func Test_ruby_buffer_get() new call setline(1, ['one', 'two']) call assert_equal('one', rubyeval('$curbuf[1]')) @@ -148,7 +148,7 @@ func Test_buffer_get() bwipe! endfunc -func Test_buffer_set() +func Test_ruby_buffer_set() new call setline(1, ['one', 'two']) ruby $curbuf[2] = 'TWO' @@ -162,7 +162,7 @@ func Test_buffer_set() endfunc " Test window.width (get or set window height). -func Test_window_height() +func Test_ruby_window_height() new " Test setting window height @@ -176,7 +176,7 @@ func Test_window_height() endfunc " Test window.width (get or set window width). -func Test_window_width() +func Test_ruby_window_width() vnew " Test setting window width @@ -190,7 +190,7 @@ func Test_window_width() endfunc " Test window.buffer (get buffer object of a window object). -func Test_window_buffer() +func Test_ruby_window_buffer() new Xfoo1 new Xfoo2 ruby $b2 = $curwin.buffer @@ -209,14 +209,14 @@ func Test_window_buffer() endfunc " Test Vim::Window.current (get current window object) -func Test_Vim_window_current() +func Test_ruby_Vim_window_current() let cw = rubyeval('$curwin') call assert_equal(cw, rubyeval('Vim::Window.current')) call assert_match('^#$', cw) endfunc " Test Vim::Window.count (number of windows) -func Test_Vim_window_count() +func Test_ruby_Vim_window_count() new Xfoo1 new Xfoo2 split @@ -226,7 +226,7 @@ func Test_Vim_window_count() endfunc " Test Vim::Window[n] (get window object of window n) -func Test_Vim_window_get() +func Test_ruby_Vim_window_get() new Xfoo1 new Xfoo2 call assert_match('Xfoo2$', rubyeval('Vim::Window[0].buffer.name')) @@ -238,14 +238,14 @@ func Test_Vim_window_get() endfunc " Test Vim::Buffer.current (return the buffer object of current buffer) -func Test_Vim_buffer_current() +func Test_ruby_Vim_buffer_current() let cb = rubyeval('$curbuf') call assert_equal(cb, rubyeval('Vim::Buffer.current')) call assert_match('^#$', cb) endfunc " Test Vim::Buffer:.count (return the number of buffers) -func Test_Vim_buffer_count() +func Test_ruby_Vim_buffer_count() new Xfoo1 new Xfoo2 call assert_equal(3, rubyeval('Vim::Buffer.count')) @@ -254,7 +254,7 @@ func Test_Vim_buffer_count() endfunc " Test Vim::buffer[n] (return the buffer object of buffer number n) -func Test_Vim_buffer_get() +func Test_ruby_Vim_buffer_get() new Xfoo1 new Xfoo2 @@ -269,7 +269,7 @@ endfunc " Test Vim::command({cmd}) (execute a Ex command)) " Test Vim::command({cmd}) -func Test_Vim_command() +func Test_ruby_Vim_command() new call setline(1, ['one', 'two', 'three', 'four']) ruby Vim::command('2,3d') @@ -278,7 +278,7 @@ func Test_Vim_command() endfunc " Test Vim::set_option (set a vim option) -func Test_Vim_set_option() +func Test_ruby_Vim_set_option() call assert_equal(0, &number) ruby Vim::set_option('number') call assert_equal(1, &number) @@ -286,14 +286,16 @@ func Test_Vim_set_option() call assert_equal(0, &number) endfunc -func Test_Vim_evaluate() +func Test_ruby_Vim_evaluate() call assert_equal(123, rubyeval('Vim::evaluate("123")')) " Vim::evaluate("123").class gives Integer or Fixnum depending " on versions of Ruby. call assert_match('^Integer\|Fixnum$', rubyeval('Vim::evaluate("123").class')) - call assert_equal(1.23, rubyeval('Vim::evaluate("1.23")')) - call assert_equal('Float', rubyeval('Vim::evaluate("1.23").class')) + if has('float') + call assert_equal(1.23, rubyeval('Vim::evaluate("1.23")')) + call assert_equal('Float', rubyeval('Vim::evaluate("1.23").class')) + endif call assert_equal('foo', rubyeval('Vim::evaluate("\"foo\"")')) call assert_equal('String', rubyeval('Vim::evaluate("\"foo\"").class')) @@ -319,14 +321,14 @@ func Test_Vim_evaluate() call assert_equal('FalseClass',rubyeval('Vim::evaluate("v:false").class')) endfunc -func Test_Vim_blob() +func Test_ruby_Vim_blob() call assert_equal('0z', rubyeval('Vim::blob("")')) call assert_equal('0z31326162', rubyeval('Vim::blob("12ab")')) call assert_equal('0z00010203', rubyeval('Vim::blob("\x00\x01\x02\x03")')) call assert_equal('0z8081FEFF', rubyeval('Vim::blob("\x80\x81\xfe\xff")')) endfunc -func Test_Vim_evaluate_list() +func Test_ruby_Vim_evaluate_list() call setline(line('$'), ['2 line 2']) ruby Vim.command("normal /^2\n") let l = ["abc", "def"] @@ -340,7 +342,7 @@ EOF call assert_equal('abc/def', getline('$')) endfunc -func Test_Vim_evaluate_dict() +func Test_ruby_Vim_evaluate_dict() let d = {'a': 'foo', 'b': 123} redir => l:out ruby d = Vim.evaluate("d"); print d @@ -349,13 +351,13 @@ func Test_Vim_evaluate_dict() endfunc " Test Vim::message({msg}) (display message {msg}) -func Test_Vim_message() +func Test_ruby_Vim_message() ruby Vim::message('A message') let messages = split(execute('message'), "\n") call assert_equal('A message', messages[-1]) endfunc -func Test_print() +func Test_ruby_print() func RubyPrint(expr) return trim(execute('ruby print ' . a:expr)) endfunc @@ -374,7 +376,7 @@ func Test_print() delfunc RubyPrint endfunc -func Test_p() +func Test_ruby_p() ruby p 'Just a test' let messages = split(execute('message'), "\n") call assert_equal('"Just a test"', messages[-1]) diff --git a/src/testdir/test_sort.vim b/src/testdir/test_sort.vim --- a/src/testdir/test_sort.vim +++ b/src/testdir/test_sort.vim @@ -1,5 +1,7 @@ " Tests for the "sort()" function and for the ":sort" command. +source check.vim + func Compare1(a, b) abort call sort(range(3), 'Compare2') return a:a - a:b @@ -28,6 +30,7 @@ func Test_sort_numbers() endfunc func Test_sort_float() + CheckFeature float call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f')) endfunc @@ -37,6 +40,8 @@ func Test_sort_nested() endfunc func Test_sort_default() + CheckFeature float + " docs say omitted, empty or zero argument sorts on string representation. call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"])) call assert_equal(['2', 'A', 'AA', 'a', 1, 3.3], sort([3.3, 1, "2", "A", "a", "AA"], '')) @@ -1145,30 +1150,6 @@ func Test_sort_cmd() \ ] \ }, \ { - \ 'name' : 'float', - \ 'cmd' : 'sort f', - \ 'input' : [ - \ '1.234', - \ '0.88', - \ ' + 123.456', - \ '1.15e-6', - \ '-1.1e3', - \ '-1.01e3', - \ '', - \ '' - \ ], - \ 'expected' : [ - \ '', - \ '', - \ '-1.1e3', - \ '-1.01e3', - \ '1.15e-6', - \ '0.88', - \ '1.234', - \ ' + 123.456' - \ ] - \ }, - \ { \ 'name' : 'alphabetical, sorted input', \ 'cmd' : 'sort', \ 'input' : [ @@ -1223,6 +1204,35 @@ func Test_sort_cmd() \ }, \ ] + if has('float') + let tests += [ + \ { + \ 'name' : 'float', + \ 'cmd' : 'sort f', + \ 'input' : [ + \ '1.234', + \ '0.88', + \ ' + 123.456', + \ '1.15e-6', + \ '-1.1e3', + \ '-1.01e3', + \ '', + \ '' + \ ], + \ 'expected' : [ + \ '', + \ '', + \ '-1.1e3', + \ '-1.01e3', + \ '1.15e-6', + \ '0.88', + \ '1.234', + \ ' + 123.456' + \ ] + \ }, + \ ] + endif + for t in tests enew! call append(0, t.input) diff --git a/src/testdir/test_timers.vim b/src/testdir/test_timers.vim --- a/src/testdir/test_timers.vim +++ b/src/testdir/test_timers.vim @@ -290,6 +290,7 @@ func Test_timer_getchar_zero() if has('win32') && !has('gui_running') throw 'Skipped: cannot get low-level input' endif + CheckFunction reltimefloat " Measure the elapsed time to avoid a hang when it fails. let start = reltime() diff --git a/src/testdir/test_true_false.vim b/src/testdir/test_true_false.vim --- a/src/testdir/test_true_false.vim +++ b/src/testdir/test_true_false.vim @@ -1,5 +1,7 @@ " Test behavior of boolean-like values. +source check.vim + " Test what is explained at ":help TRUE" and ":help FALSE". func Test_if() if v:false @@ -41,7 +43,9 @@ func Test_if() call assert_fails('if [1]', 'E745') call assert_fails('if {1: 1}', 'E728') call assert_fails('if function("string")', 'E703') - call assert_fails('if 1.3")', 'E805') + if has('float') + call assert_fails('if 1.3")', 'E805') + endif endfunc function Try_arg_true_false(expr, false_val, true_val) @@ -113,6 +117,7 @@ func Test_true_false_arg() endfunc function Try_arg_non_zero(expr, false_val, true_val) + CheckFeature float for v in ['v:false', '0', '[1]', '{2:3}', '3.4'] let r = eval(substitute(a:expr, '%v%', v, '')) call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r) diff --git a/src/testdir/test_user_func.vim b/src/testdir/test_user_func.vim --- a/src/testdir/test_user_func.vim +++ b/src/testdir/test_user_func.vim @@ -121,9 +121,11 @@ func MakeBadFunc() endfunc func Test_default_arg() - call assert_equal(1.0, Log(10)) - call assert_equal(log(10), Log(10, exp(1))) - call assert_fails("call Log(1,2,3)", 'E118') + if has('float') + call assert_equal(1.0, Log(10)) + call assert_equal(log(10), Log(10, exp(1))) + call assert_fails("call Log(1,2,3)", 'E118') + endif let res = Args(1) call assert_equal(res.mandatory, 1) diff --git a/src/testdir/test_vim9_expr.vim b/src/testdir/test_vim9_expr.vim --- a/src/testdir/test_vim9_expr.vim +++ b/src/testdir/test_vim9_expr.vim @@ -19,7 +19,9 @@ endfunc def Test_expr1() assert_equal('one', true ? 'one' : 'two') assert_equal('one', 1 ? 'one' : 'two') - assert_equal('one', 0.1 ? 'one' : 'two') + if has('float') + assert_equal('one', 0.1 ? 'one' : 'two') + endif assert_equal('one', 'x' ? 'one' : 'two') " assert_equal('one', 0z1234 ? 'one' : 'two') assert_equal('one', [0] ? 'one' : 'two') diff --git a/src/testdir/test_vimscript.vim b/src/testdir/test_vimscript.vim --- a/src/testdir/test_vimscript.vim +++ b/src/testdir/test_vimscript.vim @@ -1142,7 +1142,9 @@ func Test_type() call assert_equal(2, type(function("tr", [8]))) call assert_equal(3, type([])) call assert_equal(4, type({})) - call assert_equal(5, type(0.0)) + if has('float') + call assert_equal(5, type(0.0)) + endif call assert_equal(6, type(v:false)) call assert_equal(6, type(v:true)) call assert_equal(7, type(v:none)) @@ -1155,7 +1157,9 @@ func Test_type() call assert_equal(v:t_func, type(function("tr", [8]))) call assert_equal(v:t_list, type([])) call assert_equal(v:t_dict, type({})) - call assert_equal(v:t_float, type(0.0)) + if has('float') + call assert_equal(v:t_float, type(0.0)) + endif call assert_equal(v:t_bool, type(v:false)) call assert_equal(v:t_bool, type(v:true)) call assert_equal(v:t_none, type(v:none)) @@ -1425,8 +1429,10 @@ func Test_num64() call assert_equal(-9223372036854775807, -1 / 0) call assert_equal(-9223372036854775807 - 1, 0 / 0) - call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150)) - call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150)) + if has('float') + call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150)) + call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150)) + endif let rng = range(0xFFFFffff, 0x100000001) call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng) @@ -1526,10 +1532,12 @@ func Test_bitwise_functions() call assert_equal(16, and(127, 16)) eval 127->and(16)->assert_equal(16) call assert_equal(0, and(127, 128)) - call assert_fails("call and(1.0, 1)", 'E805:') call assert_fails("call and([], 1)", 'E745:') call assert_fails("call and({}, 1)", 'E728:') - call assert_fails("call and(1, 1.0)", 'E805:') + if has('float') + call assert_fails("call and(1.0, 1)", 'E805:') + call assert_fails("call and(1, 1.0)", 'E805:') + endif call assert_fails("call and(1, [])", 'E745:') call assert_fails("call and(1, {})", 'E728:') " or @@ -1537,10 +1545,12 @@ func Test_bitwise_functions() call assert_equal(15, or(8, 7)) eval 8->or(7)->assert_equal(15) call assert_equal(123, or(0, 123)) - call assert_fails("call or(1.0, 1)", 'E805:') call assert_fails("call or([], 1)", 'E745:') call assert_fails("call or({}, 1)", 'E728:') - call assert_fails("call or(1, 1.0)", 'E805:') + if has('float') + call assert_fails("call or(1.0, 1)", 'E805:') + call assert_fails("call or(1, 1.0)", 'E805:') + endif call assert_fails("call or(1, [])", 'E745:') call assert_fails("call or(1, {})", 'E728:') " xor @@ -1548,10 +1558,12 @@ func Test_bitwise_functions() call assert_equal(111, xor(127, 16)) eval 127->xor(16)->assert_equal(111) call assert_equal(255, xor(127, 128)) - call assert_fails("call xor(1.0, 1)", 'E805:') + if has('float') + call assert_fails("call xor(1.0, 1)", 'E805:') + call assert_fails("call xor(1, 1.0)", 'E805:') + endif call assert_fails("call xor([], 1)", 'E745:') call assert_fails("call xor({}, 1)", 'E728:') - call assert_fails("call xor(1, 1.0)", 'E805:') call assert_fails("call xor(1, [])", 'E745:') call assert_fails("call xor(1, {})", 'E728:') " invert @@ -1559,7 +1571,9 @@ func Test_bitwise_functions() eval 127->invert()->and(65535)->assert_equal(65408) call assert_equal(65519, and(invert(16), 65535)) call assert_equal(65407, and(invert(128), 65535)) - call assert_fails("call invert(1.0)", 'E805:') + if has('float') + call assert_fails("call invert(1.0)", 'E805:') + endif call assert_fails("call invert([])", 'E745:') call assert_fails("call invert({})", 'E728:') endfunc @@ -1718,22 +1732,22 @@ func Test_compound_assignment_operators( call assert_equal('string', x) let x += 1 call assert_equal(1, x) - let x -= 1.5 - call assert_equal(-0.5, x) if has('float') - " Test for float - let x = 0.5 - let x += 4.5 - call assert_equal(5.0, x) - let x -= 1.5 - call assert_equal(3.5, x) - let x *= 3.0 - call assert_equal(10.5, x) - let x /= 2.5 - call assert_equal(4.2, x) - call assert_fails('let x %= 0.5', 'E734') - call assert_fails('let x .= "f"', 'E734') + " Test for float + let x -= 1.5 + call assert_equal(-0.5, x) + let x = 0.5 + let x += 4.5 + call assert_equal(5.0, x) + let x -= 1.5 + call assert_equal(3.5, x) + let x *= 3.0 + call assert_equal(10.5, x) + let x /= 2.5 + call assert_equal(4.2, x) + call assert_fails('let x %= 0.5', 'E734') + call assert_fails('let x .= "f"', 'E734') endif " Test for environment variable diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -743,6 +743,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 183, +/**/ 182, /**/ 181,