aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/testdir/shared.vim6
-rw-r--r--src/nvim/testdir/test_cscope.vim36
-rw-r--r--src/nvim/testdir/test_functions.vim18
-rw-r--r--src/nvim/testdir/test_glob2regpat.vim4
-rw-r--r--src/nvim/testdir/test_listdict.vim8
-rw-r--r--src/nvim/testdir/test_partial.vim2
-rw-r--r--src/nvim/testdir/test_regexp_latin.vim9
-rw-r--r--src/nvim/testdir/test_sort.vim29
-rw-r--r--src/nvim/testdir/test_true_false.vim7
-rw-r--r--src/nvim/testdir/test_user_func.vim8
-rw-r--r--src/nvim/testdir/test_vimscript.vim34
11 files changed, 83 insertions, 78 deletions
diff --git a/src/nvim/testdir/shared.vim b/src/nvim/testdir/shared.vim
index 0e20ac1593..f456ff4250 100644
--- a/src/nvim/testdir/shared.vim
+++ b/src/nvim/testdir/shared.vim
@@ -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()
diff --git a/src/nvim/testdir/test_cscope.vim b/src/nvim/testdir/test_cscope.vim
index e5dab05511..2c016ea1f6 100644
--- a/src/nvim/testdir/test_cscope.vim
+++ b/src/nvim/testdir/test_cscope.vim
@@ -115,23 +115,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): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);'], split(a, '\n', 1))
- call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);', 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): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);'], split(a, '\n', 1))
+ call assert_equal(' item = (mf_hashitem_T *)lalloc_clear(sizeof(*item), FALSE);', 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/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 85d1bc7076..224ca257ab 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/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']))
@@ -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:')
- call assert_fails('call strwidth(1.2)', 'E806:')
+ if has('float')
+ call assert_fails('call strwidth(1.2)', 'E806:')
+ endif
endfor
set ambiwidth&
diff --git a/src/nvim/testdir/test_glob2regpat.vim b/src/nvim/testdir/test_glob2regpat.vim
index e6e41f13e7..354f239ef1 100644
--- a/src/nvim/testdir/test_glob2regpat.vim
+++ b/src/nvim/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/nvim/testdir/test_listdict.vim b/src/nvim/testdir/test_listdict.vim
index affb141a26..5152af8f58 100644
--- a/src/nvim/testdir/test_listdict.vim
+++ b/src/nvim/testdir/test_listdict.vim
@@ -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:')
- 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.
@@ -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:')
- 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/nvim/testdir/test_partial.vim b/src/nvim/testdir/test_partial.vim
index 52aac05ea1..8c90f21600 100644
--- a/src/nvim/testdir/test_partial.vim
+++ b/src/nvim/testdir/test_partial.vim
@@ -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
diff --git a/src/nvim/testdir/test_regexp_latin.vim b/src/nvim/testdir/test_regexp_latin.vim
index cacdd68d10..712f1e6025 100644
--- a/src/nvim/testdir/test_regexp_latin.vim
+++ b/src/nvim/testdir/test_regexp_latin.vim
@@ -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}
diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim
index 6d55889641..570c4415c6 100644
--- a/src/nvim/testdir/test_sort.vim
+++ b/src/nvim/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
@@ -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' : [
diff --git a/src/nvim/testdir/test_true_false.vim b/src/nvim/testdir/test_true_false.vim
index 84aca737ac..315ba188cb 100644
--- a/src/nvim/testdir/test_true_false.vim
+++ b/src/nvim/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/nvim/testdir/test_user_func.vim b/src/nvim/testdir/test_user_func.vim
index e9e181ce3d..7dcd92a54b 100644
--- a/src/nvim/testdir/test_user_func.vim
+++ b/src/nvim/testdir/test_user_func.vim
@@ -113,9 +113,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/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim
index 43907de1d9..5922660ef9 100644
--- a/src/nvim/testdir/test_vimscript.vim
+++ b/src/nvim/testdir/test_vimscript.vim
@@ -1271,8 +1271,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)
@@ -1531,22 +1533,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