summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_expr.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-05-22 20:16:32 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-22 20:16:32 +0100
commit338bf58eba758585ffef3fdfdba7d48477aacb7c (patch)
tree5ae6ce8b90f6aaaa06eb6d2192c9102c59fdd3b1 /src/testdir/test_expr.vim
parenta061f34191712df7dde7716705fe0ec074e9758e (diff)
patch 8.2.5004: right shift on negative number does not work as documentedv8.2.5004
Problem: Right shift on negative number does not work as documented. Solution: Use a uvarnumber_T type cast.
Diffstat (limited to 'src/testdir/test_expr.vim')
-rw-r--r--src/testdir/test_expr.vim11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/testdir/test_expr.vim b/src/testdir/test_expr.vim
index 24daeb6655..ffac6df806 100644
--- a/src/testdir/test_expr.vim
+++ b/src/testdir/test_expr.vim
@@ -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)