2019-02-28 03:12:59 +03:00
|
|
|
/+ *test
|
|
|
|
|%
|
|
|
|
++ test-bits
|
|
|
|
;: weld
|
|
|
|
::
|
|
|
|
:: Random sanity testing
|
|
|
|
::
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x3 0x7 0x7]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 3] 0xff))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x1 0xee 0xff]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 8] 0x1.eeff))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x1 0xe 0xe 0xf 0xf]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 4] 0x1.eeff))
|
2019-02-28 03:12:59 +03:00
|
|
|
::
|
|
|
|
:: Typical use-cases
|
|
|
|
::
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x1 0x23.4567 0x89.abcd]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 24] 0x1.2345.6789.abcd))
|
2019-02-28 03:12:59 +03:00
|
|
|
::
|
|
|
|
:: Edge cases
|
|
|
|
::
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 31] 0x0))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 1] 0x0))
|
2019-02-28 03:12:59 +03:00
|
|
|
::
|
|
|
|
:: Word boundaries
|
|
|
|
::
|
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x7fff.ffff]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 31] 0x7fff.ffff))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x1 0x7fff.ffff]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 31] 0xffff.ffff))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x3 0x7fff.ffff]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 31] 0x1.ffff.ffff))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x3 0x7fff.ffff 0x7fff.ffff]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 31] 0xffff.ffff.ffff.ffff))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x1 0x1.ffff 0x1.ffff]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 17] 0x7.ffff.ffff))
|
2019-02-28 03:12:59 +03:00
|
|
|
%+ expect-eq
|
|
|
|
!> ~[0x123 0x456 0x789 0xabc 0xdef 0x12 0x345 0x678]
|
2020-12-02 04:56:45 +03:00
|
|
|
!> (flop (rip [0 12] 0x1234.5678.9abc.def0.1234.5678))
|
2019-02-28 03:12:59 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
--
|