0
0
mirror of https://github.com/vim/vim.git synced 2025-10-06 05:44:14 -04:00

patch 8.2.5004: right shift on negative number does not work as documented

Problem:    Right shift on negative number does not work as documented.
Solution:   Use a uvarnumber_T type cast.
This commit is contained in:
Bram Moolenaar
2022-05-22 20:16:32 +01:00
parent a061f34191
commit 338bf58eba
7 changed files with 26 additions and 19 deletions

View File

@@ -958,6 +958,8 @@ func Test_bitwise_shift()
call assert_equal(0, 0 >> 4)
call assert_equal(0, 999999 >> 100)
call assert_equal(0, 999999 << 100)
call assert_equal(-1, -1 >> 0)
call assert_equal(-1, -1 << 0)
VAR a = 8
VAR b = 2
call assert_equal(2, a >> b)
@@ -976,6 +978,15 @@ func Test_bitwise_shift()
for i in range(0, v:numbersize - 2)
LET val = and(val, invert(1 << i))
endfor
#" -1 has all the bits set
call assert_equal(-2, -1 << 1)
call assert_equal(-4, -1 << 2)
call assert_equal(-8, -1 << 3)
if v:numbersize == 64
call assert_equal(0x7fffffffffffffff, -1 >> 1)
call assert_equal(0x3fffffffffffffff, -1 >> 2)
call assert_equal(0x1fffffffffffffff, -1 >> 3)
endif
call assert_equal(0, val)
#" multiple operators
call assert_equal(16, 1 << 2 << 2)