diff options
-rw-r--r-- | src/nvim/strings.c | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_expr.vim | 43 | ||||
-rw-r--r-- | src/nvim/testdir/test_largefile.vim | 7 | ||||
-rw-r--r-- | src/nvim/testdir/test_sort.vim | 36 | ||||
-rw-r--r-- | src/nvim/testdir/test_vimscript.vim | 22 |
5 files changed, 49 insertions, 60 deletions
diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 81a1a68a94..cb66f7682d 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -900,6 +900,7 @@ int vim_vsnprintf_typval( } switch (fmt_spec) { + case 'b': case 'B': case 'd': case 'u': case 'o': case 'x': case 'X': if (tvs && length_modifier == '\0') { length_modifier = '2'; diff --git a/src/nvim/testdir/test_expr.vim b/src/nvim/testdir/test_expr.vim index b8d6f5aa7d..7b90ba56e0 100644 --- a/src/nvim/testdir/test_expr.vim +++ b/src/nvim/testdir/test_expr.vim @@ -125,22 +125,7 @@ func Test_option_value() endfunc function Test_printf_64bit() - if has('num64') - call assert_equal("123456789012345", printf('%d', 123456789012345)) - endif -endfunc - -func Test_setmatches() - hi def link 1 Comment - hi def link 2 PreProc - let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4}] - let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4}] - if has('conceal') - let set[0]['conceal'] = 5 - let exp[0]['conceal'] = '5' - endif - call setmatches(set) - call assert_equal(exp, getmatches()) + call assert_equal("123456789012345", printf('%d', 123456789012345)) endfunc function Test_printf_spec_s() @@ -168,6 +153,19 @@ function Test_printf_spec_s() call assert_equal(string(function('printf', ['%s'])), printf('%s', function('printf', ['%s']))) endfunc +function Test_printf_spec_b() + call assert_equal("0", printf('%b', 0)) + call assert_equal("00001100", printf('%08b', 12)) + call assert_equal("11111111", printf('%08b', 0xff)) + call assert_equal(" 1111011", printf('%10b', 123)) + call assert_equal("0001111011", printf('%010b', 123)) + call assert_equal(" 0b1111011", printf('%#10b', 123)) + call assert_equal("0B01111011", printf('%#010B', 123)) + call assert_equal("1001001100101100000001011010010", printf('%b', 1234567890)) + call assert_equal("11100000100100010000110000011011101111101111001", printf('%b', 123456789012345)) + call assert_equal("1111111111111111111111111111111111111111111111111111111111111111", printf('%b', -1)) +endfunc + function Test_printf_misc() call assert_equal('123', printf('123')) call assert_fails("call printf('123', 3)", "E767:") @@ -482,6 +480,19 @@ func Test_funcref() call assert_fails('let OneByRef = funcref("One", repeat(["foo"], 21))', 'E118:') endfunc +func Test_setmatches() + hi def link 1 Comment + hi def link 2 PreProc + let set = [{"group": 1, "pattern": 2, "id": 3, "priority": 4}] + let exp = [{"group": '1', "pattern": '2', "id": 3, "priority": 4}] + if has('conceal') + let set[0]['conceal'] = 5 + let exp[0]['conceal'] = '5' + endif + call setmatches(set) + call assert_equal(exp, getmatches()) +endfunc + func Test_empty_concatenate() call assert_equal('b', 'a'[4:0] . 'b') call assert_equal('b', 'b' . 'a'[4:0]) diff --git a/src/nvim/testdir/test_largefile.vim b/src/nvim/testdir/test_largefile.vim index 3f9c2dc150..fa32b7fb5c 100644 --- a/src/nvim/testdir/test_largefile.vim +++ b/src/nvim/testdir/test_largefile.vim @@ -24,11 +24,6 @@ func Test_largefile() w " Check if the file size is 4,000,000,000 bytes. let fsize=getfsize(fname) - if has('num64') - call assert_true(fsize == 4000000000) - else - " getfsize() returns -2 if a Number is 32 bits. - call assert_true(fsize == -2) - endif + call assert_true(fsize == 4000000000) call delete(fname) endfunc diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim index 7da82b0185..7533eaf2e8 100644 --- a/src/nvim/testdir/test_sort.vim +++ b/src/nvim/testdir/test_sort.vim @@ -1257,9 +1257,8 @@ abc \ '2147483647'], getline(1, '$')) bwipe! - if has('num64') - new - a + new + a -9223372036854775808 -9223372036854775807 @@ -1274,22 +1273,21 @@ abc abc . - sort n - call assert_equal(['', - \ 'abc', - \ '', - \ '-9223372036854775808', - \ '-9223372036854775808', - \ '-9223372036854775807', - \ '-9223372036854775806', - \ '-1', - \ '0', - \ '1', - \ '9223372036854775806', - \ '9223372036854775807', - \ '9223372036854775807'], getline(1, '$')) - bwipe! - endif + sort n + call assert_equal(['', + \ 'abc', + \ '', + \ '-9223372036854775808', + \ '-9223372036854775808', + \ '-9223372036854775807', + \ '-9223372036854775806', + \ '-1', + \ '0', + \ '1', + \ '9223372036854775806', + \ '9223372036854775807', + \ '9223372036854775807'], getline(1, '$')) + bwipe! endfunc diff --git a/src/nvim/testdir/test_vimscript.vim b/src/nvim/testdir/test_vimscript.vim index cb81997d39..118a5dab2b 100644 --- a/src/nvim/testdir/test_vimscript.vim +++ b/src/nvim/testdir/test_vimscript.vim @@ -1068,10 +1068,6 @@ endfunc "------------------------------------------------------------------------------- func Test_num64() - if !has('num64') - return - endif - call assert_notequal( 4294967296, 0) call assert_notequal(-4294967296, 0) call assert_equal( 4294967296, 0xFFFFffff + 1) @@ -1313,27 +1309,15 @@ func Test_compound_assignment_operators() " Test special cases: division or modulus with 0. let x = 1 let x /= 0 - if has('num64') - call assert_equal(0x7FFFFFFFFFFFFFFF, x) - else - call assert_equal(0x7fffffff, x) - endif + call assert_equal(0x7FFFFFFFFFFFFFFF, x) let x = -1 let x /= 0 - if has('num64') - call assert_equal(-0x7FFFFFFFFFFFFFFF, x) - else - call assert_equal(-0x7fffffff, x) - endif + call assert_equal(-0x7FFFFFFFFFFFFFFF, x) let x = 0 let x /= 0 - if has('num64') - call assert_equal(-0x7FFFFFFFFFFFFFFF - 1, x) - else - call assert_equal(-0x7FFFFFFF - 1, x) - endif + call assert_equal(-0x7FFFFFFFFFFFFFFF - 1, x) let x = 1 let x %= 0 |