comparison src/testdir/test_vimscript.vim @ 30310:029c59bf78f1 v9.0.0491

patch 9.0.0491: no good reason to build without the float feature Commit: https://github.com/vim/vim/commit/73e28dcc6125f616cf1f2d56443d22428a79e434 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 17 21:08:33 2022 +0100 patch 9.0.0491: no good reason to build without the float feature Problem: No good reason to build without the float feature. Solution: Remove configure check for float and "#ifdef FEAT_FLOAT".
author Bram Moolenaar <Bram@vim.org>
date Sat, 17 Sep 2022 22:15:05 +0200
parents 949e8978ea43
children 56e38195570b
comparison
equal deleted inserted replaced
30309:4ba3d27b5357 30310:029c59bf78f1
6488 call assert_equal(1, type("")) 6488 call assert_equal(1, type(""))
6489 call assert_equal(2, type(function("tr"))) 6489 call assert_equal(2, type(function("tr")))
6490 call assert_equal(2, type(function("tr", [8]))) 6490 call assert_equal(2, type(function("tr", [8])))
6491 call assert_equal(3, type([])) 6491 call assert_equal(3, type([]))
6492 call assert_equal(4, type({})) 6492 call assert_equal(4, type({}))
6493 if has('float') 6493 call assert_equal(5, type(0.0))
6494 call assert_equal(5, type(0.0))
6495 endif
6496 call assert_equal(6, type(v:false)) 6494 call assert_equal(6, type(v:false))
6497 call assert_equal(6, type(v:true)) 6495 call assert_equal(6, type(v:true))
6498 call assert_equal(7, type(v:none)) 6496 call assert_equal(7, type(v:none))
6499 call assert_equal(7, type(v:null)) 6497 call assert_equal(7, type(v:null))
6500 call assert_equal(8, v:t_job) 6498 call assert_equal(8, v:t_job)
6503 call assert_equal(v:t_string, type("")) 6501 call assert_equal(v:t_string, type(""))
6504 call assert_equal(v:t_func, type(function("tr"))) 6502 call assert_equal(v:t_func, type(function("tr")))
6505 call assert_equal(v:t_func, type(function("tr", [8]))) 6503 call assert_equal(v:t_func, type(function("tr", [8])))
6506 call assert_equal(v:t_list, type([])) 6504 call assert_equal(v:t_list, type([]))
6507 call assert_equal(v:t_dict, type({})) 6505 call assert_equal(v:t_dict, type({}))
6508 if has('float') 6506 call assert_equal(v:t_float, type(0.0))
6509 call assert_equal(v:t_float, type(0.0))
6510 endif
6511 call assert_equal(v:t_bool, type(v:false)) 6507 call assert_equal(v:t_bool, type(v:false))
6512 call assert_equal(v:t_bool, type(v:true)) 6508 call assert_equal(v:t_bool, type(v:true))
6513 call assert_equal(v:t_none, type(v:none)) 6509 call assert_equal(v:t_none, type(v:none))
6514 call assert_equal(v:t_none, type(v:null)) 6510 call assert_equal(v:t_none, type(v:null))
6515 call assert_equal(v:t_string, type(test_null_string())) 6511 call assert_equal(v:t_string, type(test_null_string()))
6549 call assert_false(v:null == 1) 6545 call assert_false(v:null == 1)
6550 call assert_false(v:null != 0) 6546 call assert_false(v:null != 0)
6551 call assert_true(v:none == 0) 6547 call assert_true(v:none == 0)
6552 call assert_false(v:none == 1) 6548 call assert_false(v:none == 1)
6553 call assert_false(v:none != 0) 6549 call assert_false(v:none != 0)
6554 if has('float') 6550 call assert_true(v:null == 0.0)
6555 call assert_true(v:null == 0.0) 6551 call assert_false(v:null == 0.1)
6556 call assert_false(v:null == 0.1) 6552 call assert_false(v:null != 0.0)
6557 call assert_false(v:null != 0.0)
6558 endif
6559 6553
6560 call assert_true(v:false is v:false) 6554 call assert_true(v:false is v:false)
6561 call assert_true(v:true is v:true) 6555 call assert_true(v:true is v:true)
6562 call assert_true(v:none is v:none) 6556 call assert_true(v:none is v:none)
6563 call assert_true(v:null is v:null) 6557 call assert_true(v:null is v:null)
6668 let l = split(result, "\n") 6662 let l = split(result, "\n")
6669 call assert_equal(["foo bar", 6663 call assert_equal(["foo bar",
6670 \ "'foo bar'"], l) 6664 \ "'foo bar'"], l)
6671 6665
6672 " Float 6666 " Float
6673 if has('float') 6667 let a = -1.2e0
6674 let a = -1.2e0 6668 redir => result
6675 redir => result 6669 echo a
6676 echo a 6670 echo string(a)
6677 echo string(a) 6671 redir END
6678 redir END 6672 let l = split(result, "\n")
6679 let l = split(result, "\n") 6673 call assert_equal(["-1.2",
6680 call assert_equal(["-1.2", 6674 \ "-1.2"], l)
6681 \ "-1.2"], l)
6682 endif
6683 6675
6684 " Funcref 6676 " Funcref
6685 redir => result 6677 redir => result
6686 echo function('string') 6678 echo function('string')
6687 echo string(function('string')) 6679 echo string(function('string'))
6814 6806
6815 call assert_equal( 9223372036854775807, 1 / 0) 6807 call assert_equal( 9223372036854775807, 1 / 0)
6816 call assert_equal(-9223372036854775807, -1 / 0) 6808 call assert_equal(-9223372036854775807, -1 / 0)
6817 call assert_equal(-9223372036854775807 - 1, 0 / 0) 6809 call assert_equal(-9223372036854775807 - 1, 0 / 0)
6818 6810
6819 if has('float') 6811 call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150))
6820 call assert_equal( 0x7FFFffffFFFFffff, float2nr( 1.0e150)) 6812 call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
6821 call assert_equal(-0x7FFFffffFFFFffff, float2nr(-1.0e150))
6822 endif
6823 6813
6824 let rng = range(0xFFFFffff, 0x100000001) 6814 let rng = range(0xFFFFffff, 0x100000001)
6825 call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng) 6815 call assert_equal([0xFFFFffff, 0x100000000, 0x100000001], rng)
6826 call assert_equal(0x100000001, max(rng)) 6816 call assert_equal(0x100000001, max(rng))
6827 call assert_equal(0xFFFFffff, min(rng)) 6817 call assert_equal(0xFFFFffff, min(rng))
6919 call assert_equal(16, and(127, 16)) 6909 call assert_equal(16, and(127, 16))
6920 eval 127->and(16)->assert_equal(16) 6910 eval 127->and(16)->assert_equal(16)
6921 call assert_equal(0, and(127, 128)) 6911 call assert_equal(0, and(127, 128))
6922 call assert_fails("call and([], 1)", 'E745:') 6912 call assert_fails("call and([], 1)", 'E745:')
6923 call assert_fails("call and({}, 1)", 'E728:') 6913 call assert_fails("call and({}, 1)", 'E728:')
6924 if has('float') 6914 call assert_fails("call and(1.0, 1)", 'E805:')
6925 call assert_fails("call and(1.0, 1)", 'E805:') 6915 call assert_fails("call and(1, 1.0)", 'E805:')
6926 call assert_fails("call and(1, 1.0)", 'E805:')
6927 endif
6928 call assert_fails("call and(1, [])", 'E745:') 6916 call assert_fails("call and(1, [])", 'E745:')
6929 call assert_fails("call and(1, {})", 'E728:') 6917 call assert_fails("call and(1, {})", 'E728:')
6930 " or 6918 " or
6931 call assert_equal(23, or(16, 7)) 6919 call assert_equal(23, or(16, 7))
6932 call assert_equal(15, or(8, 7)) 6920 call assert_equal(15, or(8, 7))
6933 eval 8->or(7)->assert_equal(15) 6921 eval 8->or(7)->assert_equal(15)
6934 call assert_equal(123, or(0, 123)) 6922 call assert_equal(123, or(0, 123))
6935 call assert_fails("call or([], 1)", 'E745:') 6923 call assert_fails("call or([], 1)", 'E745:')
6936 call assert_fails("call or({}, 1)", 'E728:') 6924 call assert_fails("call or({}, 1)", 'E728:')
6937 if has('float') 6925 call assert_fails("call or(1.0, 1)", 'E805:')
6938 call assert_fails("call or(1.0, 1)", 'E805:') 6926 call assert_fails("call or(1, 1.0)", 'E805:')
6939 call assert_fails("call or(1, 1.0)", 'E805:')
6940 endif
6941 call assert_fails("call or(1, [])", 'E745:') 6927 call assert_fails("call or(1, [])", 'E745:')
6942 call assert_fails("call or(1, {})", 'E728:') 6928 call assert_fails("call or(1, {})", 'E728:')
6943 " xor 6929 " xor
6944 call assert_equal(0, xor(127, 127)) 6930 call assert_equal(0, xor(127, 127))
6945 call assert_equal(111, xor(127, 16)) 6931 call assert_equal(111, xor(127, 16))
6946 eval 127->xor(16)->assert_equal(111) 6932 eval 127->xor(16)->assert_equal(111)
6947 call assert_equal(255, xor(127, 128)) 6933 call assert_equal(255, xor(127, 128))
6948 if has('float') 6934 call assert_fails("call xor(1.0, 1)", 'E805:')
6949 call assert_fails("call xor(1.0, 1)", 'E805:') 6935 call assert_fails("call xor(1, 1.0)", 'E805:')
6950 call assert_fails("call xor(1, 1.0)", 'E805:')
6951 endif
6952 call assert_fails("call xor([], 1)", 'E745:') 6936 call assert_fails("call xor([], 1)", 'E745:')
6953 call assert_fails("call xor({}, 1)", 'E728:') 6937 call assert_fails("call xor({}, 1)", 'E728:')
6954 call assert_fails("call xor(1, [])", 'E745:') 6938 call assert_fails("call xor(1, [])", 'E745:')
6955 call assert_fails("call xor(1, {})", 'E728:') 6939 call assert_fails("call xor(1, {})", 'E728:')
6956 " invert 6940 " invert
6957 call assert_equal(65408, and(invert(127), 65535)) 6941 call assert_equal(65408, and(invert(127), 65535))
6958 eval 127->invert()->and(65535)->assert_equal(65408) 6942 eval 127->invert()->and(65535)->assert_equal(65408)
6959 call assert_equal(65519, and(invert(16), 65535)) 6943 call assert_equal(65519, and(invert(16), 65535))
6960 call assert_equal(65407, and(invert(128), 65535)) 6944 call assert_equal(65407, and(invert(128), 65535))
6961 if has('float') 6945 call assert_fails("call invert(1.0)", 'E805:')
6962 call assert_fails("call invert(1.0)", 'E805:')
6963 endif
6964 call assert_fails("call invert([])", 'E745:') 6946 call assert_fails("call invert([])", 'E745:')
6965 call assert_fails("call invert({})", 'E728:') 6947 call assert_fails("call invert({})", 'E728:')
6966 endfunc 6948 endfunc
6967 6949
6968 " Test using bang after user command {{{1 6950 " Test using bang after user command {{{1
7037 let x .= 'ing' 7019 let x .= 'ing'
7038 call assert_equal('string', x) 7020 call assert_equal('string', x)
7039 let x += 1 7021 let x += 1
7040 call assert_equal(1, x) 7022 call assert_equal(1, x)
7041 7023
7042 if has('float') 7024 " Test for float
7043 " Test for float 7025 let x -= 1.5
7044 let x -= 1.5 7026 call assert_equal(-0.5, x)
7045 call assert_equal(-0.5, x) 7027 let x = 0.5
7046 let x = 0.5 7028 let x += 4.5
7047 let x += 4.5 7029 call assert_equal(5.0, x)
7048 call assert_equal(5.0, x) 7030 let x -= 1.5
7049 let x -= 1.5 7031 call assert_equal(3.5, x)
7050 call assert_equal(3.5, x) 7032 let x *= 3.0
7051 let x *= 3.0 7033 call assert_equal(10.5, x)
7052 call assert_equal(10.5, x) 7034 let x /= 2.5
7053 let x /= 2.5 7035 call assert_equal(4.2, x)
7054 call assert_equal(4.2, x) 7036 call assert_fails('let x %= 0.5', 'E734:')
7055 call assert_fails('let x %= 0.5', 'E734:') 7037 call assert_fails('let x .= "f"', 'E734:')
7056 call assert_fails('let x .= "f"', 'E734:') 7038 let x = !3.14
7057 let x = !3.14 7039 call assert_equal(0.0, x)
7058 call assert_equal(0.0, x) 7040
7059 7041 " integer and float operations
7060 " integer and float operations 7042 let x = 1
7061 let x = 1 7043 let x *= 2.1
7062 let x *= 2.1 7044 call assert_equal(2.1, x)
7063 call assert_equal(2.1, x) 7045 let x = 1
7064 let x = 1 7046 let x /= 0.25
7065 let x /= 0.25 7047 call assert_equal(4.0, x)
7066 call assert_equal(4.0, x) 7048 let x = 1
7067 let x = 1 7049 call assert_fails('let x %= 0.25', 'E734:')
7068 call assert_fails('let x %= 0.25', 'E734:') 7050 let x = 1
7069 let x = 1 7051 call assert_fails('let x .= 0.25', 'E734:')
7070 call assert_fails('let x .= 0.25', 'E734:') 7052 let x = 1.0
7071 let x = 1.0 7053 call assert_fails('let x += [1.1]', 'E734:')
7072 call assert_fails('let x += [1.1]', 'E734:')
7073 endif
7074 7054
7075 " Test for environment variable 7055 " Test for environment variable
7076 let $FOO = 1 7056 let $FOO = 1
7077 call assert_fails('let $FOO += 1', 'E734:') 7057 call assert_fails('let $FOO += 1', 'E734:')
7078 call assert_fails('let $FOO -= 1', 'E734:') 7058 call assert_fails('let $FOO -= 1', 'E734:')
7140 call assert_equal(-1, test_refcount(v:true)) 7120 call assert_equal(-1, test_refcount(v:true))
7141 call assert_equal(0, test_refcount([])) 7121 call assert_equal(0, test_refcount([]))
7142 call assert_equal(0, test_refcount({})) 7122 call assert_equal(0, test_refcount({}))
7143 call assert_equal(0, test_refcount(0zff)) 7123 call assert_equal(0, test_refcount(0zff))
7144 call assert_equal(0, test_refcount({-> line('.')})) 7124 call assert_equal(0, test_refcount({-> line('.')}))
7145 if has('float') 7125 call assert_equal(-1, test_refcount(0.1))
7146 call assert_equal(-1, test_refcount(0.1))
7147 endif
7148 if has('job') 7126 if has('job')
7149 call assert_equal(0, test_refcount(job_start([&shell, &shellcmdflag, 'echo .']))) 7127 call assert_equal(0, test_refcount(job_start([&shell, &shellcmdflag, 'echo .'])))
7150 endif 7128 endif
7151 7129
7152 " No refcount types 7130 " No refcount types
7154 call assert_equal(-1, test_refcount(x)) 7132 call assert_equal(-1, test_refcount(x))
7155 let x = 's' 7133 let x = 's'
7156 call assert_equal(-1, test_refcount(x)) 7134 call assert_equal(-1, test_refcount(x))
7157 let x = v:true 7135 let x = v:true
7158 call assert_equal(-1, test_refcount(x)) 7136 call assert_equal(-1, test_refcount(x))
7159 if has('float') 7137 let x = 0.1
7160 let x = 0.1 7138 call assert_equal(-1, test_refcount(x))
7161 call assert_equal(-1, test_refcount(x))
7162 endif
7163 7139
7164 " Check refcount 7140 " Check refcount
7165 let x = [] 7141 let x = []
7166 call assert_equal(1, test_refcount(x)) 7142 call assert_equal(1, test_refcount(x))
7167 7143
7375 call delete('Xscript') 7351 call delete('Xscript')
7376 endfunc 7352 endfunc
7377 7353
7378 " Test for errors in converting to float from various types {{{1 7354 " Test for errors in converting to float from various types {{{1
7379 func Test_float_conversion_errors() 7355 func Test_float_conversion_errors()
7380 if has('float') 7356 call assert_fails('let x = 4.0 % 2.0', 'E804:')
7381 call assert_fails('let x = 4.0 % 2.0', 'E804:') 7357 call assert_fails('echo 1.1[0]', 'E806:')
7382 call assert_fails('echo 1.1[0]', 'E806:') 7358 call assert_fails('echo sort([function("min"), 1], "f")', 'E891:')
7383 call assert_fails('echo sort([function("min"), 1], "f")', 'E891:') 7359 call assert_fails('echo 3.2 == "vim"', 'E892:')
7384 call assert_fails('echo 3.2 == "vim"', 'E892:') 7360 call assert_fails('echo sort([[], 1], "f")', 'E893:')
7385 call assert_fails('echo sort([[], 1], "f")', 'E893:') 7361 call assert_fails('echo sort([{}, 1], "f")', 'E894:')
7386 call assert_fails('echo sort([{}, 1], "f")', 'E894:') 7362 call assert_fails('echo 3.2 == v:true', 'E362:')
7387 call assert_fails('echo 3.2 == v:true', 'E362:') 7363 call assert_fails('echo 3.2 == v:none', 'E907:')
7388 call assert_fails('echo 3.2 == v:none', 'E907:')
7389 endif
7390 endfunc 7364 endfunc
7391 7365
7392 " invalid function names {{{1 7366 " invalid function names {{{1
7393 func Test_invalid_function_names() 7367 func Test_invalid_function_names()
7394 " function name not starting with capital 7368 " function name not starting with capital