diff options
Diffstat (limited to 'src/testdir/test_vimscript.vim')
-rw-r--r-- | src/testdir/test_vimscript.vim | 152 |
1 files changed, 63 insertions, 89 deletions
diff --git a/src/testdir/test_vimscript.vim b/src/testdir/test_vimscript.vim index 07dc59d15a..641ef73687 100644 --- a/src/testdir/test_vimscript.vim +++ b/src/testdir/test_vimscript.vim @@ -6490,9 +6490,7 @@ func Test_type() call assert_equal(2, type(function("tr", [8]))) call assert_equal(3, type([])) call assert_equal(4, type({})) - if has('float') - call assert_equal(5, type(0.0)) - endif + call assert_equal(5, type(0.0)) call assert_equal(6, type(v:false)) call assert_equal(6, type(v:true)) call assert_equal(7, type(v:none)) @@ -6505,9 +6503,7 @@ 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({})) - if has('float') - call assert_equal(v:t_float, type(0.0)) - endif + call assert_equal(v:t_float, type(0.0)) 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)) @@ -6551,11 +6547,9 @@ func Test_type() call assert_true(v:none == 0) call assert_false(v:none == 1) call assert_false(v:none != 0) - if has('float') - call assert_true(v:null == 0.0) - call assert_false(v:null == 0.1) - call assert_false(v:null != 0.0) - endif + call assert_true(v:null == 0.0) + call assert_false(v:null == 0.1) + call assert_false(v:null != 0.0) call assert_true(v:false is v:false) call assert_true(v:true is v:true) @@ -6670,16 +6664,14 @@ func Test_echo_and_string() \ "'foo bar'"], l) " Float - if has('float') - let a = -1.2e0 - redir => result - echo a - echo string(a) - redir END - let l = split(result, "\n") - call assert_equal(["-1.2", - \ "-1.2"], l) - endif + let a = -1.2e0 + redir => result + echo a + echo string(a) + redir END + let l = split(result, "\n") + call assert_equal(["-1.2", + \ "-1.2"], l) " Funcref redir => result @@ -6816,10 +6808,8 @@ 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 + call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150)) + call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150)) let rng = range(0xFFFFffff, 0x100000001) call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng) @@ -6921,10 +6911,8 @@ func Test_bitwise_functions() call assert_equal(0, and(127, 128)) call assert_fails("call and([], 1)", 'E745:') call assert_fails("call and({}, 1)", 'E728:') - 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.0, 1)", 'E805:') + call assert_fails("call and(1, 1.0)", 'E805:') call assert_fails("call and(1, [])", 'E745:') call assert_fails("call and(1, {})", 'E728:') " or @@ -6934,10 +6922,8 @@ func Test_bitwise_functions() call assert_equal(123, or(0, 123)) call assert_fails("call or([], 1)", 'E745:') call assert_fails("call or({}, 1)", 'E728:') - 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.0, 1)", 'E805:') + call assert_fails("call or(1, 1.0)", 'E805:') call assert_fails("call or(1, [])", 'E745:') call assert_fails("call or(1, {})", 'E728:') " xor @@ -6945,10 +6931,8 @@ 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)) - 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.0, 1)", 'E805:') + call assert_fails("call xor(1, 1.0)", 'E805:') call assert_fails("call xor([], 1)", 'E745:') call assert_fails("call xor({}, 1)", 'E728:') call assert_fails("call xor(1, [])", 'E745:') @@ -6958,9 +6942,7 @@ 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)) - if has('float') - call assert_fails("call invert(1.0)", 'E805:') - endif + call assert_fails("call invert(1.0)", 'E805:') call assert_fails("call invert([])", 'E745:') call assert_fails("call invert({})", 'E728:') endfunc @@ -7039,38 +7021,36 @@ func Test_compound_assignment_operators() let x += 1 call assert_equal(1, 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) - 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:') - let x = !3.14 - call assert_equal(0.0, x) - - " integer and float operations - let x = 1 - let x *= 2.1 - call assert_equal(2.1, x) - let x = 1 - let x /= 0.25 - call assert_equal(4.0, x) - let x = 1 - call assert_fails('let x %= 0.25', 'E734:') - let x = 1 - call assert_fails('let x .= 0.25', 'E734:') - let x = 1.0 - call assert_fails('let x += [1.1]', 'E734:') - endif + " 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:') + let x = !3.14 + call assert_equal(0.0, x) + + " integer and float operations + let x = 1 + let x *= 2.1 + call assert_equal(2.1, x) + let x = 1 + let x /= 0.25 + call assert_equal(4.0, x) + let x = 1 + call assert_fails('let x %= 0.25', 'E734:') + let x = 1 + call assert_fails('let x .= 0.25', 'E734:') + let x = 1.0 + call assert_fails('let x += [1.1]', 'E734:') " Test for environment variable let $FOO = 1 @@ -7142,9 +7122,7 @@ func Test_refcount() call assert_equal(0, test_refcount({})) call assert_equal(0, test_refcount(0zff)) call assert_equal(0, test_refcount({-> line('.')})) - if has('float') - call assert_equal(-1, test_refcount(0.1)) - endif + call assert_equal(-1, test_refcount(0.1)) if has('job') call assert_equal(0, test_refcount(job_start([&shell, &shellcmdflag, 'echo .']))) endif @@ -7156,10 +7134,8 @@ func Test_refcount() call assert_equal(-1, test_refcount(x)) let x = v:true call assert_equal(-1, test_refcount(x)) - if has('float') - let x = 0.1 - call assert_equal(-1, test_refcount(x)) - endif + let x = 0.1 + call assert_equal(-1, test_refcount(x)) " Check refcount let x = [] @@ -7377,16 +7353,14 @@ endfunc " Test for errors in converting to float from various types {{{1 func Test_float_conversion_errors() - if has('float') - call assert_fails('let x = 4.0 % 2.0', 'E804:') - call assert_fails('echo 1.1[0]', 'E806:') - call assert_fails('echo sort([function("min"), 1], "f")', 'E891:') - call assert_fails('echo 3.2 == "vim"', 'E892:') - call assert_fails('echo sort([[], 1], "f")', 'E893:') - call assert_fails('echo sort([{}, 1], "f")', 'E894:') - call assert_fails('echo 3.2 == v:true', 'E362:') - call assert_fails('echo 3.2 == v:none', 'E907:') - endif + call assert_fails('let x = 4.0 % 2.0', 'E804:') + call assert_fails('echo 1.1[0]', 'E806:') + call assert_fails('echo sort([function("min"), 1], "f")', 'E891:') + call assert_fails('echo 3.2 == "vim"', 'E892:') + call assert_fails('echo sort([[], 1], "f")', 'E893:') + call assert_fails('echo sort([{}, 1], "f")', 'E894:') + call assert_fails('echo 3.2 == v:true', 'E362:') + call assert_fails('echo 3.2 == v:none', 'E907:') endfunc " invalid function names {{{1 |