@@ -751,22 +751,30 @@ dwTests.test("TwoWords") {
751
751
}
752
752
753
753
dwTests. test ( " Bitshifts " ) {
754
- typealias DWU16 = DoubleWidth < UInt8 >
755
- typealias DWU32 = DoubleWidth < DWU16 >
756
- typealias DWU64 = DoubleWidth < DWU32 >
754
+ typealias DWU64 = DoubleWidth < DoubleWidth < DoubleWidth < UInt8 > > >
755
+ typealias DWI64 = DoubleWidth < DoubleWidth < DoubleWidth < Int8 > > >
757
756
758
- func f( _ x: UInt64 ) {
759
- let y = DWU64 ( x)
760
- for i in - 65 ... 65 {
757
+ func f< T: FixedWidthInteger , U: FixedWidthInteger > ( _ x: T , type: U . Type ) {
758
+ let y = U ( x)
759
+ expectEqual ( T . bitWidth, U . bitWidth)
760
+ for i in - ( T . bitWidth + 1 ) ... ( T . bitWidth + 1 ) {
761
761
expectTrue ( x << i == y << i)
762
762
expectTrue ( x >> i == y >> i)
763
+
764
+ expectTrue ( x &<< i == y &<< i)
765
+ expectTrue ( x &>> i == y &>> i)
763
766
}
764
767
}
765
768
766
- f ( 1 )
767
- f ( ~ ( ~ 0 >> 1 ) )
768
- f ( . max)
769
- f ( 0b11110000_10100101_11110000_10100101_11110000_10100101_11110000_10100101 )
769
+ f ( 1 as UInt64 , type: DWU64 . self)
770
+ f ( ~ ( ~ 0 as UInt64 >> 1 ) , type: DWU64 . self)
771
+ f ( UInt64 . max, type: DWU64 . self)
772
+ f ( 0b11110000_10100101_11110000_10100101_11110000_10100101_11110000_10100101 as UInt64 , type: DWU64 . self)
773
+
774
+ f ( 1 as Int64 , type: DWI64 . self)
775
+ f ( Int64 . min, type: DWI64 . self)
776
+ f ( Int64 . max, type: DWI64 . self)
777
+ f ( 0b01010101_10100101_11110000_10100101_11110000_10100101_11110000_10100101 as Int64 , type: DWI64 . self)
770
778
}
771
779
772
780
dwTests. test ( " Remainder/DividingBy0 " ) {
0 commit comments