mirror of
https://github.com/neovim/neovim.git
synced 2025-10-10 03:46:31 +00:00
test/old: partial port of patch v8.2.1.0183
Prep for patch v8.2.0511.
This commit is contained in:
@@ -179,7 +179,7 @@ endfunc
|
|||||||
func s:WaitForCommon(expr, assert, timeout)
|
func s:WaitForCommon(expr, assert, timeout)
|
||||||
" using reltime() is more accurate, but not always available
|
" using reltime() is more accurate, but not always available
|
||||||
let slept = 0
|
let slept = 0
|
||||||
if has('reltime')
|
if exists('*reltimefloat')
|
||||||
let start = reltime()
|
let start = reltime()
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -204,7 +204,7 @@ func s:WaitForCommon(expr, assert, timeout)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
sleep 10m
|
sleep 10m
|
||||||
if has('reltime')
|
if exists('*reltimefloat')
|
||||||
let slept = float2nr(reltimefloat(reltime(start)) * 1000)
|
let slept = float2nr(reltimefloat(reltime(start)) * 1000)
|
||||||
else
|
else
|
||||||
let slept += 10
|
let slept += 10
|
||||||
@@ -220,7 +220,7 @@ endfunc
|
|||||||
" feeds key-input and resumes process. Return time waited in milliseconds.
|
" feeds key-input and resumes process. Return time waited in milliseconds.
|
||||||
" Without +timers it uses simply :sleep.
|
" Without +timers it uses simply :sleep.
|
||||||
func Standby(msec)
|
func Standby(msec)
|
||||||
if has('timers')
|
if has('timers') && exists('*reltimefloat')
|
||||||
let start = reltime()
|
let start = reltime()
|
||||||
let g:_standby_timer = timer_start(a:msec, function('s:feedkeys'))
|
let g:_standby_timer = timer_start(a:msec, function('s:feedkeys'))
|
||||||
call getchar()
|
call getchar()
|
||||||
|
@@ -115,23 +115,25 @@ func Test_cscopeWithCscopeConnections()
|
|||||||
" Test 10: Invalid find command
|
" Test 10: Invalid find command
|
||||||
call assert_fails('cs find x', 'E560:')
|
call assert_fails('cs find x', 'E560:')
|
||||||
|
|
||||||
" Test 11: Find places where this symbol is assigned a value
|
if has('float')
|
||||||
" this needs a cscope >= 15.8
|
" Test 11: Find places where this symbol is assigned a value
|
||||||
" unfortunately, Travis has cscope version 15.7
|
" this needs a cscope >= 15.8
|
||||||
let cscope_version = systemlist('cscope --version')[0]
|
" unfortunately, Travis has cscope version 15.7
|
||||||
let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
|
let cscope_version = systemlist('cscope --version')[0]
|
||||||
if cs_version >= 15.8
|
let cs_version = str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
|
||||||
for cmd in ['cs find a item', 'cs find 9 item']
|
if cs_version >= 15.8
|
||||||
let a = execute(cmd)
|
for cmd in ['cs find a item', 'cs find 9 item']
|
||||||
call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);'], split(a, '\n', 1))
|
let a = execute(cmd)
|
||||||
call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);', getline('.'))
|
call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);'], split(a, '\n', 1))
|
||||||
cnext
|
call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);', getline('.'))
|
||||||
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
cnext
|
||||||
cnext
|
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
||||||
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
cnext
|
||||||
cnext
|
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
||||||
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
cnext
|
||||||
endfor
|
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Test 12: leading whitespace is not removed for cscope find text
|
" Test 12: leading whitespace is not removed for cscope find text
|
||||||
|
@@ -28,12 +28,14 @@ func Test_empty()
|
|||||||
call assert_equal(0, empty(1))
|
call assert_equal(0, empty(1))
|
||||||
call assert_equal(0, empty(-1))
|
call assert_equal(0, empty(-1))
|
||||||
|
|
||||||
call assert_equal(1, empty(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(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(-1.0))
|
||||||
call assert_equal(0, empty(0.0/0.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(1, empty([]))
|
||||||
call assert_equal(0, empty(['a']))
|
call assert_equal(0, empty(['a']))
|
||||||
@@ -115,7 +117,9 @@ func Test_strwidth()
|
|||||||
call assert_fails('call strwidth({->0})', 'E729:')
|
call assert_fails('call strwidth({->0})', 'E729:')
|
||||||
call assert_fails('call strwidth([])', 'E730:')
|
call assert_fails('call strwidth([])', 'E730:')
|
||||||
call assert_fails('call strwidth({})', 'E731:')
|
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
|
endfor
|
||||||
|
|
||||||
set ambiwidth&
|
set ambiwidth&
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
" Test glob2regpat()
|
" Test glob2regpat()
|
||||||
|
|
||||||
func Test_glob2regpat_invalid()
|
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("}")', 'E219:')
|
||||||
call assert_fails('call glob2regpat("{")', 'E220:')
|
call assert_fails('call glob2regpat("{")', 'E220:')
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -689,7 +689,9 @@ func Test_listdict_extend()
|
|||||||
let l = [1, 2, 3]
|
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], -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.
|
" Test extend() with dictionaries.
|
||||||
|
|
||||||
@@ -713,7 +715,9 @@ func Test_listdict_extend()
|
|||||||
let d = {'a': 'A', 'b': 'B'}
|
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'}, 'error')", 'E737:')
|
||||||
call assert_fails("call extend(d, {'b': 0, 'c':'C'}, 'xxx')", 'E475:')
|
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_equal({'a': 'A', 'b': 'B'}, d)
|
||||||
|
|
||||||
call assert_fails("call extend([1, 2], 1)", 'E712:')
|
call assert_fails("call extend([1, 2], 1)", 'E712:')
|
||||||
|
@@ -105,7 +105,7 @@ fun InnerCall(funcref)
|
|||||||
endfu
|
endfu
|
||||||
|
|
||||||
fun OuterCall()
|
fun OuterCall()
|
||||||
let opt = { 'func' : function('sin') }
|
let opt = { 'func' : function('max') }
|
||||||
call InnerCall(opt.func)
|
call InnerCall(opt.func)
|
||||||
endfu
|
endfu
|
||||||
|
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
" Tests for regexp in latin1 encoding
|
" Tests for regexp in latin1 encoding
|
||||||
|
|
||||||
" set encoding=latin1
|
" set encoding=latin1
|
||||||
scriptencoding latin1
|
scriptencoding latin1
|
||||||
|
|
||||||
|
source check.vim
|
||||||
|
|
||||||
func s:equivalence_test()
|
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 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)
|
let groups = split(str)
|
||||||
@@ -42,9 +45,9 @@ func Test_range_with_newline()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_pattern_compile_speed()
|
func Test_pattern_compile_speed()
|
||||||
if !exists('+spellcapcheck') || !has('reltime')
|
CheckOption spellcapcheck
|
||||||
return
|
CheckFunction reltimefloat
|
||||||
endif
|
|
||||||
let start = reltime()
|
let start = reltime()
|
||||||
" this used to be very slow, not it should be about a second
|
" this used to be very slow, not it should be about a second
|
||||||
set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179}
|
set spc=\\v(((((Nxxxxxxx&&xxxx){179})+)+)+){179}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
" Tests for the "sort()" function and for the ":sort" command.
|
" Tests for the "sort()" function and for the ":sort" command.
|
||||||
|
|
||||||
|
source check.vim
|
||||||
|
|
||||||
func Compare1(a, b) abort
|
func Compare1(a, b) abort
|
||||||
call sort(range(3), 'Compare2')
|
call sort(range(3), 'Compare2')
|
||||||
return a:a - a:b
|
return a:a - a:b
|
||||||
@@ -59,6 +61,7 @@ func Test_sort_numbers()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_sort_float()
|
func Test_sort_float()
|
||||||
|
CheckFeature float
|
||||||
call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f'))
|
call assert_equal([0.28, 3, 13.5], sort([13.5, 0.28, 3], 'f'))
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@@ -68,6 +71,8 @@ func Test_sort_nested()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_sort_default()
|
func Test_sort_default()
|
||||||
|
CheckFeature float
|
||||||
|
|
||||||
" docs say omitted, empty or zero argument sorts on string representation.
|
" 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"]))
|
||||||
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"], ''))
|
||||||
@@ -1176,30 +1181,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',
|
\ 'name' : 'alphabetical, sorted input',
|
||||||
\ 'cmd' : 'sort',
|
\ 'cmd' : 'sort',
|
||||||
\ 'input' : [
|
\ 'input' : [
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
" Test behavior of boolean-like values.
|
" Test behavior of boolean-like values.
|
||||||
|
|
||||||
|
source check.vim
|
||||||
|
|
||||||
" Test what is explained at ":help TRUE" and ":help FALSE".
|
" Test what is explained at ":help TRUE" and ":help FALSE".
|
||||||
func Test_if()
|
func Test_if()
|
||||||
if v:false
|
if v:false
|
||||||
@@ -41,7 +43,9 @@ func Test_if()
|
|||||||
call assert_fails('if [1]', 'E745')
|
call assert_fails('if [1]', 'E745')
|
||||||
call assert_fails('if {1: 1}', 'E728')
|
call assert_fails('if {1: 1}', 'E728')
|
||||||
call assert_fails('if function("string")', 'E703')
|
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
|
endfunc
|
||||||
|
|
||||||
function Try_arg_true_false(expr, false_val, true_val)
|
function Try_arg_true_false(expr, false_val, true_val)
|
||||||
@@ -113,6 +117,7 @@ func Test_true_false_arg()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Try_arg_non_zero(expr, false_val, true_val)
|
function Try_arg_non_zero(expr, false_val, true_val)
|
||||||
|
CheckFeature float
|
||||||
for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
|
for v in ['v:false', '0', '[1]', '{2:3}', '3.4']
|
||||||
let r = eval(substitute(a:expr, '%v%', v, ''))
|
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)
|
call assert_equal(a:false_val, r, 'result for ' . v . ' is not ' . a:false_val . ' but ' . r)
|
||||||
|
@@ -113,9 +113,11 @@ func MakeBadFunc()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_default_arg()
|
func Test_default_arg()
|
||||||
call assert_equal(1.0, Log(10))
|
if has('float')
|
||||||
call assert_equal(log(10), Log(10, exp(1)))
|
call assert_equal(1.0, Log(10))
|
||||||
call assert_fails("call Log(1,2,3)", 'E118')
|
call assert_equal(log(10), Log(10, exp(1)))
|
||||||
|
call assert_fails("call Log(1,2,3)", 'E118')
|
||||||
|
endif
|
||||||
|
|
||||||
let res = Args(1)
|
let res = Args(1)
|
||||||
call assert_equal(res.mandatory, 1)
|
call assert_equal(res.mandatory, 1)
|
||||||
|
@@ -1271,8 +1271,10 @@ func Test_num64()
|
|||||||
call assert_equal(-9223372036854775807, -1 / 0)
|
call assert_equal(-9223372036854775807, -1 / 0)
|
||||||
call assert_equal(-9223372036854775807 - 1, 0 / 0)
|
call assert_equal(-9223372036854775807 - 1, 0 / 0)
|
||||||
|
|
||||||
call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
|
if has('float')
|
||||||
call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
|
call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
|
||||||
|
call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
|
||||||
|
endif
|
||||||
|
|
||||||
let rng = range(0xFFFFffff, 0x100000001)
|
let rng = range(0xFFFFffff, 0x100000001)
|
||||||
call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng)
|
call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng)
|
||||||
@@ -1531,22 +1533,22 @@ func Test_compound_assignment_operators()
|
|||||||
call assert_equal('string', x)
|
call assert_equal('string', x)
|
||||||
let x += 1
|
let x += 1
|
||||||
call assert_equal(1, x)
|
call assert_equal(1, x)
|
||||||
let x -= 1.5
|
|
||||||
call assert_equal(-0.5, x)
|
|
||||||
|
|
||||||
if has('float')
|
if has('float')
|
||||||
" Test for float
|
" Test for float
|
||||||
let x = 0.5
|
let x -= 1.5
|
||||||
let x += 4.5
|
call assert_equal(-0.5, x)
|
||||||
call assert_equal(5.0, x)
|
let x = 0.5
|
||||||
let x -= 1.5
|
let x += 4.5
|
||||||
call assert_equal(3.5, x)
|
call assert_equal(5.0, x)
|
||||||
let x *= 3.0
|
let x -= 1.5
|
||||||
call assert_equal(10.5, x)
|
call assert_equal(3.5, x)
|
||||||
let x /= 2.5
|
let x *= 3.0
|
||||||
call assert_equal(4.2, x)
|
call assert_equal(10.5, x)
|
||||||
call assert_fails('let x %= 0.5', 'E734')
|
let x /= 2.5
|
||||||
call assert_fails('let x .= "f"', 'E734')
|
call assert_equal(4.2, x)
|
||||||
|
call assert_fails('let x %= 0.5', 'E734')
|
||||||
|
call assert_fails('let x .= "f"', 'E734')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Test for environment variable
|
" Test for environment variable
|
||||||
|
Reference in New Issue
Block a user