1- local function test (bits )
2- local bint = require ' bint' (bits )
1+ local function test (bits , wordbits )
2+ local bint = require ' bint' (bits , wordbits )
33
44 local function assert_eq (a , b )
55 if a ~= b then -- luacov:disable
@@ -340,6 +340,12 @@ local function test(bits)
340340 local function test_shr (x , y )
341341 assert_eq ((bint (x ) >> y ):tointeger (), x >> y )
342342 end
343+ local function test_brol (x , y )
344+ assert_eq (bint (x ):brol (y ):tointeger (), (x << y ) | (x >> (64 - y )))
345+ end
346+ local function test_bror (x , y )
347+ assert_eq (bint (x ):bror (y ):tointeger (), (x >> y ) | (x << (64 - y )))
348+ end
343349 local function test_shlone (x )
344350 assert_eq (bint (x ):_shlone ():tointeger (), x << 1 )
345351 end
@@ -355,6 +361,10 @@ local function test(bits)
355361 test_bwrap (x , y ) test_bwrap (x , - y ) test_bwrap (- x , y )
356362 test_shlone (x ) test_shlone (y )
357363 test_shrone (x ) test_shrone (y )
364+ if bits == 64 then
365+ test_brol (x , y )
366+ test_bror (x , y )
367+ end
358368 end
359369 test_ops (0 , 0 )
360370 test_ops (1 , 0 )
@@ -413,6 +423,10 @@ local function test(bits)
413423 test_ops ( 524288 , 19 )
414424 test_ops (1048576 , 20 )
415425 test_ops (1048576 , 100 )
426+ assert_eq (bint .brol (1 , - 1 ), bint .mininteger ())
427+ assert_eq (bint .bror (1 , 1 ), bint .mininteger ())
428+ assert_eq (bint .brol (bint .mininteger (), 1 ), bint (1 ))
429+ assert_eq (bint .bror (bint .mininteger (), - 1 ), bint (1 ))
416430 end
417431
418432 do -- pow
0 commit comments