diff options
author | Eduardo Julian | 2018-05-07 21:43:19 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-05-07 21:43:19 -0400 |
commit | 07c70ad15ba4a8c9b00773a0a14eade28fe06569 (patch) | |
tree | 18d6e938cb0a79ecffddd64da1958de47d75ee0f /stdlib/test | |
parent | febfa99c2823219c2e76d2c73b1fd8db8f6c9918 (diff) |
- Implemented bit-count in pure Lux.
Diffstat (limited to '')
-rw-r--r-- | stdlib/test/test/lux/data/bit.lux | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/stdlib/test/test/lux/data/bit.lux b/stdlib/test/test/lux/data/bit.lux index f8c9bc8ef..1b8110d31 100644 --- a/stdlib/test/test/lux/data/bit.lux +++ b/stdlib/test/test/lux/data/bit.lux @@ -14,12 +14,14 @@ idx (:: @ map (n/% &.width) r.nat)] ($_ seq (test "Clearing and settings bits should alter the count." - (and (n/< (&.count (&.set idx pattern)) + (and (n/= (n/dec (&.count (&.set idx pattern))) (&.count (&.clear idx pattern))) - (n/<= (&.count pattern) - (&.count (&.clear idx pattern))) - (n/>= (&.count pattern) - (&.count (&.set idx pattern))))) + (|> (&.count pattern) + (n/- (&.count (&.clear idx pattern))) + (n/<= +1)) + (|> (&.count (&.set idx pattern)) + (n/- (&.count pattern)) + (n/<= +1)))) (test "Can query whether a bit is set." (and (or (and (&.set? idx pattern) (not (&.set? idx (&.clear idx pattern)))) @@ -30,7 +32,7 @@ (not (&.set? idx (&.flip idx pattern)))) (and (not (&.set? idx pattern)) (&.set? idx (&.flip idx pattern)))))) - (test "The negation of a bit pattern should have a complementary bit count." + (test "The negation of a bit pattern should have a complementary bit-count." (n/= &.width (n/+ (&.count pattern) (&.count (&.not pattern))))) |