mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 17:33:38 +00:00
The functions byte/2 and 'byte :='/2 both throw a bitmap_error/1 exception if
the given byte index is out of bounds. The error message returned as part of
the exception reports the byte index that is out of bounds but then gives the
valid bounds of *bit* indexes in the bitmap. There are two possible fixes:
1. report the out of bounds index as the bit index of the start of the byte.
2. report the valid bounds of the of byte indexes in the bitmap.
This change implements the latter.
Style and formatting fixes to the bitmap module.
library/bitmap.m:
Make the above fix.
Add separate predicates for reporting out of bounds bit and byte
indexes.
Do not provide erroneous functions that duplicate the functionality of,
or forward their work, to erroneous predicates of the same name.
Add the predicate is_empty/1.
Remove some unnecessary module qualification.
Use state variable notation in more spots.
tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_bytes.{m,exp}:
Add a new test for byte lookups in bitmaps -- this wasn't covered
by the existing test cases.
tests/hard_coded/bitmap_empty.exp:
tests/hard_coded/btimap_test.exp:
Conform to the above changes.
NEWS:
Announce the addition of bitmap.is_empty/1.
69 lines
940 B
Plaintext
69 lines
940 B
Plaintext
-- new
|
|
"<0:>"
|
|
-- copy
|
|
"<0:>"
|
|
-- resize
|
|
"<0:>"
|
|
"<4:F0>"
|
|
"<0:>"
|
|
-- shrink_without_copying
|
|
"<0:>"
|
|
-- in_range
|
|
ok
|
|
ok
|
|
ok
|
|
-- byte_in_range
|
|
ok
|
|
ok
|
|
ok
|
|
-- num_bits
|
|
0
|
|
-- det_num_bytes
|
|
0
|
|
-- ^bit
|
|
expected: bitmap_error("bitmap.bit: bit index 0 is out of bounds [0, 0).")
|
|
-- ^bits
|
|
0
|
|
-- ^bits:=
|
|
"<0:>"
|
|
-- ^byte
|
|
expected: bitmap_error("bitmap.byte: byte index 0 is out of bounds [0, 0).")
|
|
-- ^byte:=
|
|
expected: bitmap_error("bitmap.\'byte :=\': byte index 0 is out of bounds [0, 0).")
|
|
-- slice
|
|
slice_ctor("<0:>", 0, 0)
|
|
-- byte_slice
|
|
slice_ctor("<0:>", 0, 0)
|
|
-- flip
|
|
expected: bitmap_error("bitmap.flip: bit index 0 is out of bounds [0, 0).")
|
|
-- complement
|
|
"<0:>"
|
|
-- union
|
|
"<0:>"
|
|
-- intersect
|
|
"<0:>"
|
|
-- difference
|
|
"<0:>"
|
|
-- xor
|
|
"<0:>"
|
|
-- append_list
|
|
"<2:C0>"
|
|
-- copy_bits
|
|
"<0:>"
|
|
-- copy_bits_in_bitmap
|
|
"<0:>"
|
|
-- copy_bytes
|
|
"<0:>"
|
|
-- copy_bytes_in_bitmap
|
|
"<0:>"
|
|
-- from_string
|
|
"<0:>"
|
|
-- to_byte_string
|
|
<>
|
|
-- hash
|
|
0
|
|
-- bitmap_equal
|
|
equal
|
|
-- bitmap_compare
|
|
'='
|