X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=contrib%2Fsb-rotate-byte%2Frotate-byte-tests.lisp;h=6e6b7f6059f816ae65885f3259ab0b6408967c87;hb=8369a441bfd49566e70939c25f42f8d1f5423e4e;hp=252e06d0590e9b2f29c4f38ac68a2d65ccef2ed9;hpb=6df5926c567b40b0217e0cc16fd604197add804f;p=sbcl.git diff --git a/contrib/sb-rotate-byte/rotate-byte-tests.lisp b/contrib/sb-rotate-byte/rotate-byte-tests.lisp index 252e06d..6e6b7f6 100644 --- a/contrib/sb-rotate-byte/rotate-byte-tests.lisp +++ b/contrib/sb-rotate-byte/rotate-byte-tests.lisp @@ -1,5 +1,8 @@ (in-package "SB-ROTATE-BYTE") +;;; Ensure we don't bug out with an identity rotation. +(assert (= (rotate-byte 0 (byte 32 0) 3) 3)) + (assert (= (rotate-byte 3 (byte 32 0) 3) 24)) (assert (= (rotate-byte 3 (byte 16 0) 3) 24)) (assert (= (rotate-byte 3 (byte 2 0) 3) 3)) @@ -65,3 +68,26 @@ (assert (= (ub32-reg-pressure 5 5) 10880)) (assert (= (ub32-reg-pressure 5 (ash 1 26)) 2147494368)) (assert (= (ub32-reg-pressure 5 (ash 1 27)) 10721)) + +(defun ub64/c (integer) + (declare (type (unsigned-byte 64) integer)) + (rotate-byte 6 (byte 64 0) integer)) + +(defun ub64/-c (integer) + (declare (type (unsigned-byte 64) integer)) + (rotate-byte -6 (byte 64 0) integer)) + +(assert (= (ub64/-c 320) 5)) +(assert (= (ub64/-c 64) 1)) +(assert (= (ub64/-c (ash 1 63)) (ash 1 57))) +(assert (= (ub64/-c 1) (ash 1 58))) + +(defun ub64 (count integer) + (declare (type (unsigned-byte 64) integer) + (type (integer -63 63) count)) + (rotate-byte count (byte 64 0) integer)) + +(assert (= (ub64 6 5) 320)) +(assert (= (ub64 6 1) 64)) +(assert (= (ub64 6 (ash 1 57)) (ash 1 63))) +(assert (= (ub64 6 (ash 1 58)) 1))