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)
|
||||
" using reltime() is more accurate, but not always available
|
||||
let slept = 0
|
||||
if has('reltime')
|
||||
if exists('*reltimefloat')
|
||||
let start = reltime()
|
||||
endif
|
||||
|
||||
@@ -204,7 +204,7 @@ func s:WaitForCommon(expr, assert, timeout)
|
||||
endif
|
||||
|
||||
sleep 10m
|
||||
if has('reltime')
|
||||
if exists('*reltimefloat')
|
||||
let slept = float2nr(reltimefloat(reltime(start)) * 1000)
|
||||
else
|
||||
let slept += 10
|
||||
@@ -220,7 +220,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()
|
||||
|
@@ -115,6 +115,7 @@ func Test_cscopeWithCscopeConnections()
|
||||
" Test 10: Invalid find command
|
||||
call assert_fails('cs find x', 'E560:')
|
||||
|
||||
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
|
||||
@@ -133,6 +134,7 @@ func Test_cscopeWithCscopeConnections()
|
||||
call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
|
||||
" Test 12: leading whitespace is not removed for cscope find text
|
||||
let a = execute('cscope find t test_mf_hash')
|
||||
|
@@ -28,12 +28,14 @@ func Test_empty()
|
||||
call assert_equal(0, empty(1))
|
||||
call assert_equal(0, empty(-1))
|
||||
|
||||
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']))
|
||||
@@ -115,7 +117,9 @@ func Test_strwidth()
|
||||
call assert_fails('call strwidth({->0})', 'E729:')
|
||||
call assert_fails('call strwidth([])', 'E730:')
|
||||
call assert_fails('call strwidth({})', 'E731:')
|
||||
if has('float')
|
||||
call assert_fails('call strwidth(1.2)', 'E806:')
|
||||
endif
|
||||
endfor
|
||||
|
||||
set ambiwidth&
|
||||
|
@@ -1,7 +1,9 @@
|
||||
" Test glob2regpat()
|
||||
|
||||
func Test_glob2regpat_invalid()
|
||||
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
|
||||
|
@@ -689,7 +689,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:')
|
||||
if has('float')
|
||||
call assert_fails("call extend(l, [4, 5, 6], 1.2)", 'E805:')
|
||||
endif
|
||||
|
||||
" Test extend() with dictionaries.
|
||||
|
||||
@@ -713,7 +715,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:')
|
||||
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:')
|
||||
|
@@ -105,7 +105,7 @@ fun InnerCall(funcref)
|
||||
endfu
|
||||
|
||||
fun OuterCall()
|
||||
let opt = { 'func' : function('sin') }
|
||||
let opt = { 'func' : function('max') }
|
||||
call InnerCall(opt.func)
|
||||
endfu
|
||||
|
||||
|
@@ -1,7 +1,10 @@
|
||||
" Tests for regexp in latin1 encoding
|
||||
|
||||
" 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)
|
||||
@@ -42,9 +45,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}
|
||||
|
@@ -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
|
||||
@@ -59,6 +61,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
|
||||
|
||||
@@ -68,6 +71,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"], ''))
|
||||
@@ -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',
|
||||
\ 'cmd' : 'sort',
|
||||
\ 'input' : [
|
||||
|
@@ -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')
|
||||
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)
|
||||
|
@@ -113,9 +113,11 @@ func MakeBadFunc()
|
||||
endfunc
|
||||
|
||||
func Test_default_arg()
|
||||
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)
|
||||
|
@@ -1271,8 +1271,10 @@ func Test_num64()
|
||||
call assert_equal(-9223372036854775807, -1 / 0)
|
||||
call assert_equal(-9223372036854775807 - 1, 0 / 0)
|
||||
|
||||
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)
|
||||
@@ -1531,11 +1533,11 @@ 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 -= 1.5
|
||||
call assert_equal(-0.5, x)
|
||||
let x = 0.5
|
||||
let x += 4.5
|
||||
call assert_equal(5.0, x)
|
||||
|
Reference in New Issue
Block a user