[m-rev.] for review: fix some error reporting in the bitmap module

Julien Fischer jfischer at opturion.com
Thu Dec 28 23:07:36 AEDT 2017


For review by anyone.

------------------------

Fix some error reporting in bitmap module.

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.

Julien.

diff --git a/NEWS b/NEWS
index 1db79b7..74f1d9a 100644
--- a/NEWS
+++ b/NEWS
@@ -499,6 +499,10 @@ Changes to the Mercury standard library:
    - det_insert_duplicates/4
    - det_insert_duplicates/3

+* We have added the following predicate to the bitmap module:
+
+  - is_empty/1
+
  Changes to the Mercury compiler:

  * We have extended tail call optimization from self recursive calls only
diff --git a/library/bitmap.m b/library/bitmap.m
index d5ff70b..75fb74f 100644
--- a/library/bitmap.m
+++ b/library/bitmap.m
@@ -2,6 +2,7 @@
  % vim: ts=4 sw=4 et ft=mercury
  %---------------------------------------------------------------------------%
  % Copyright (C) 2001-2002, 2004-2007, 2009-2011 The University of Melbourne
+% Copyright (C) 2013-2017 The Mercury team.
  % This file may only be copied under the terms of the GNU Library General
  % Public License - see the file COPYING.LIB in the Mercury distribution.
  %---------------------------------------------------------------------------%
@@ -115,6 +116,13 @@
      %
  :- func bits_per_byte = int.

+    % is_empty(Bitmap):
+    % True iff Bitmap is a bitmap containint zero bits.
+    %
+:- pred is_empty(bitmap).
+%:- mode is_empty(bitmap_ui) is semidet.
+:- mode is_empty(in) is semidet.
+
  %---------------------------------------------------------------------------%
  %
  % Get or set the given bit.
@@ -278,18 +286,18 @@

  %---------------------------------------------------------------------------%

-    % Slice = bitmap.slice(BM, StartIndex, NumBits)
+    % Slice = slice(BM, StartIndex, NumBits)
      %
      % A bitmap slice represents the sub-range of a bitmap of NumBits bits
      % starting at bit index StartIndex. Throws an exception if the slice
      % is not within the bounds of the bitmap.
      %
-:- type bitmap.slice.
-:- func bitmap.slice(bitmap, bit_index, num_bits) = bitmap.slice.
+:- type slice.
+:- func slice(bitmap, bit_index, num_bits) = bitmap.slice.

      % As above, but use byte indices.
      %
-:- func bitmap.byte_slice(bitmap, byte_index, num_bytes) = bitmap.slice.
+:- func byte_slice(bitmap, byte_index, num_bytes) = slice.

      % Access functions for slices.
      %
@@ -412,7 +420,7 @@

      % Used by io.m.

-    % throw_bounds_error(BM, PredName, Index, NumBits)
+    % throw_bounds_error(BM, PredName, Index, NumBits):
      %
  :- pred throw_bounds_error(bitmap::in, string::in, bit_index::in, num_bits::in)
      is erroneous.
@@ -430,7 +438,7 @@

  init(N, B) = BM :-
      ( if N < 0 then
-        throw_bitmap_error("bitmap.init: negative size") = _ : int
+        throw_bitmap_error("bitmap.init: negative size")
      else
          X    = initializer(B),
          BM0  = initialize_bitmap(allocate_bitmap(N), N, X),
@@ -549,21 +557,26 @@ bits_per_byte = 8.

  %---------------------------------------------------------------------------%

-BM ^ bit(I) =
+is_empty(BM) :-
+    BM ^ num_bits = 0.
+
+%---------------------------------------------------------------------------%
+
+BM ^ bit(I) = B :-
      ( if in_range(BM, I) then
-        BM ^ unsafe_bit(I)
+        B = BM ^ unsafe_bit(I)
      else
-        throw_bounds_error(BM, "bitmap.bit", I)
+        throw_bit_bounds_error(BM, "bitmap.bit", I)
      ).

  BM ^ unsafe_bit(I) =
      ( if unsafe_is_set(BM, I) then yes else no ).

-(BM ^ bit(I) := B) =
-    ( if in_range(BM, I) then
-        BM ^ unsafe_bit(I) := B
+(!.BM ^ bit(I) := B) = !:BM :-
+    ( if in_range(!.BM, I) then
+        !BM ^ unsafe_bit(I) := B
      else
-        throw_bounds_error(BM, "bitmap.'bit :='", I)
+        throw_bit_bounds_error(!.BM, "bitmap.'bit :='", I)
      ).

  (BM ^ unsafe_bit(I) := yes) = unsafe_set(BM, I).
@@ -571,14 +584,14 @@ BM ^ unsafe_bit(I) =

  %---------------------------------------------------------------------------%

-BM ^ bits(FirstBit, NumBits) =
+BM ^ bits(FirstBit, NumBits) = Word :-
      ( if
          FirstBit >= 0,
          NumBits >= 0,
          NumBits =< int.bits_per_int,
          in_range_rexcl(BM, FirstBit + NumBits)
      then
-        BM ^ unsafe_bits(FirstBit, NumBits)
+        Word = BM ^ unsafe_bits(FirstBit, NumBits)
      else if
          ( NumBits < 0
          ; NumBits > int.bits_per_int
@@ -587,7 +600,7 @@ BM ^ bits(FirstBit, NumBits) =
          throw_bitmap_error("bitmap.bits: number of bits must be between " ++
              "0 and `int.bits_per_int'.")
      else
-        throw_bounds_error(BM, "bitmap.bits", FirstBit)
+        throw_bit_bounds_error(BM, "bitmap.bits", FirstBit)
      ).

  BM ^ unsafe_bits(FirstBit, NumBits) = Bits :-
@@ -635,14 +648,14 @@ extract_bits_from_byte_index(ByteIndex, FirstBitIndex,

  %---------------------------------------------------------------------------%

-(BM ^ bits(FirstBit, NumBits) := Bits) =
+(!.BM ^ bits(FirstBit, NumBits) := Bits) = !:BM :-
      ( if
          FirstBit >= 0,
          NumBits >= 0,
          NumBits =< int.bits_per_int,
-        in_range_rexcl(BM, FirstBit + NumBits)
+        in_range_rexcl(!.BM, FirstBit + NumBits)
      then
-        BM ^ unsafe_bits(FirstBit, NumBits) := Bits
+        !BM ^ unsafe_bits(FirstBit, NumBits) := Bits
      else if
          ( NumBits < 0
          ; NumBits > int.bits_per_int
@@ -652,7 +665,7 @@ extract_bits_from_byte_index(ByteIndex, FirstBitIndex,
              "bitmap.'bits :=': number of bits must be between " ++
              "0 and `int.bits_per_int'.")
      else
-        throw_bounds_error(BM, "bitmap.'bits :='", FirstBit)
+        throw_bit_bounds_error(!.BM, "bitmap.'bits :='", FirstBit)
      ).

  (BM0 ^ unsafe_bits(FirstBit, NumBits) := Bits) = BM :-
@@ -694,11 +707,11 @@ set_bits_in_byte_index(ByteIndex, LastBitIndex, NumBitsThisByte, Bits, !BM) :-

  %---------------------------------------------------------------------------%

-BM ^ byte(N) =
+BM ^ byte(N) = Byte :-
      ( if N >= 0, in_range(BM, N * bits_per_byte + bits_per_byte - 1) then
-        BM ^ unsafe_byte(N)
+        Byte = BM ^ unsafe_byte(N)
      else
-        throw_bounds_error(BM, "bitmap.byte", N)
+        throw_byte_bounds_error(BM, "bitmap.byte", N)
      ).

  _ ^ unsafe_byte(_) = _ :-
@@ -736,11 +749,11 @@ _ ^ unsafe_byte(_) = _ :-

  %---------------------------------------------------------------------------%

-(BM ^ byte(N) := Byte) =
-    ( if N >= 0, in_range(BM, N * bits_per_byte + bits_per_byte - 1) then
-        BM ^ unsafe_byte(N) := Byte
+(!.BM ^ byte(N) := Byte) = !:BM :-
+    ( if N >= 0, in_range(!.BM, N * bits_per_byte + bits_per_byte - 1) then
+        !BM ^ unsafe_byte(N) := Byte
      else
-        throw_bounds_error(BM, "bitmap.'byte :='", N)
+        throw_byte_bounds_error(!.BM, "bitmap.'byte :='", N)
      ).

  (_ ^ unsafe_byte(_) := _) = _ :-
@@ -782,45 +795,48 @@ _ ^ unsafe_byte(_) = _ :-

  %---------------------------------------------------------------------------%

-flip(BM, I) =
-    ( if in_range(BM, I) then
-        unsafe_flip(BM, I)
+flip(!.BM, I) = !:BM :-
+    flip(I, !BM).
+
+flip(I, !BM) :-
+    ( if in_range(!.BM, I) then
+        !:BM = unsafe_flip(!.BM, I)
      else
-        throw_bounds_error(BM, "bitmap.flip", I)
+        throw_bit_bounds_error(!.BM, "bitmap.flip", I)
      ).

-flip(I, BM, flip(BM, I)).
+set(!.BM, I) = !:BM :-
+    set(I, !BM).

-set(BM, I) =
-    ( if in_range(BM, I) then
-        unsafe_set(BM, I)
+set(I, !BM) :-
+    ( if in_range(!.BM, I) then
+        !:BM = unsafe_set(!.BM, I)
      else
-        throw_bounds_error(BM, "bitmap.set", I)
+        throw_bit_bounds_error(!.BM, "bitmap.set", I)
      ).

-set(I, BM, set(BM, I)).
+clear(!.BM, I) = !:BM :-
+    clear(I, !BM).

-clear(BM, I) =
-    ( if in_range(BM, I) then
-        unsafe_clear(BM, I)
+clear(I, !BM) :-
+    ( if in_range(!.BM, I) then
+        !:BM = unsafe_clear(!.BM, I)
      else
-        throw_bounds_error(BM, "bitmap.clear", I)
+        throw_bit_bounds_error(!.BM, "bitmap.clear", I)
      ).

-clear(I, BM, clear(BM, I)).
-
  is_set(BM, I) :-
      ( if in_range(BM, I) then
          unsafe_is_set(BM, I)
      else
-        throw_bounds_error(BM, "bitmap.is_set", I) = _ : int
+        throw_bit_bounds_error(BM, "bitmap.is_set", I)
      ).

  is_clear(BM, I) :-
      ( if in_range(BM, I) then
          unsafe_is_clear(BM, I)
      else
-        throw_bounds_error(BM, "bitmap.is_clear", I) = _ : int
+        throw_bit_bounds_error(BM, "bitmap.is_clear", I)
      ).

  %---------------------------------------------------------------------------%
@@ -926,8 +942,8 @@ shrink_without_copying(!.BM, NewSize) = !:BM :-
      ( if 0 =< NewSize, NewSize =< !.BM ^ num_bits then
          !:BM = !.BM ^ num_bits := NewSize
      else
-        throw_bounds_error(!.BM,
-            "bitmap.shrink_without_copying", NewSize) = _ : int
+        throw_bit_bounds_error(!.BM,
+            "bitmap.shrink_without_copying", NewSize)
      ).

  :- func 'num_bits :='(bitmap, num_bits) = bitmap.
@@ -1030,30 +1046,30 @@ complement_2(ByteI, BM0) = BM :-

  %---------------------------------------------------------------------------%

-union(BMa, BMb) =
+union(BMa, BMb) = BMc :-
      ( if num_bits(BMa) = num_bits(BMb) then
-        zip((\/), BMa, BMb)
+        BMc = zip((\/), BMa, BMb)
      else
          throw_bitmap_error("bitmap.union: bitmaps not the same size")
      ).

-intersect(BMa, BMb) =
+intersect(BMa, BMb) = BMc :-
      ( if num_bits(BMa) = num_bits(BMb) then
-        zip((/\), BMa, BMb)
+        BMc = zip((/\), BMa, BMb)
      else
          throw_bitmap_error("bitmap.intersect: bitmaps not the same size")
      ).

-difference(BMa, BMb) =
+difference(BMa, BMb) = BMc :-
      ( if num_bits(BMa) = num_bits(BMb) then
-        zip((func(X, Y) = (X /\ \Y)), BMa, BMb)
+        BMc = zip((func(X, Y) = (X /\ \Y)), BMa, BMb)
      else
          throw_bitmap_error("bitmap.difference: bitmaps not the same size")
      ).

-xor(BMa, BMb) =
+xor(BMa, BMb) = BMc :-
      ( if num_bits(BMa) = num_bits(BMb) then
-        zip((func(X, Y) = (X `xor` Y)), BMa, BMb)
+        BMc = zip((func(X, Y) = (X `xor` Y)), BMa, BMb)
      else
          throw_bitmap_error("bitmap.xor: bitmaps not the same size")
      ).
@@ -1121,16 +1137,17 @@ copy_bits_in_bitmap(SrcBM, SrcStartBit, DestStartBit, NumBits) =
  % :- mode copy_bits(in, bitmap_ui, in, bitmap_di, in, in) = bitmap_uo is det.
  :- mode copy_bits(in, in, in, bitmap_di, in, in) = bitmap_uo is det.

-copy_bits(SameBM, SrcBM, SrcStartBit, DestBM, DestStartBit, NumBits) =
+copy_bits(SameBM, SrcBM, SrcStartBit, !.DestBM, DestStartBit, NumBits)
+        = !:DestBM :-
      ( if
          NumBits >= 0,
          SrcStartBit >= 0,
          DestStartBit >= 0,
          in_range_rexcl(SrcBM, SrcStartBit + NumBits),
-        in_range_rexcl(DestBM, DestStartBit + NumBits)
+        in_range_rexcl(!.DestBM, DestStartBit + NumBits)
      then
-        unsafe_copy_bits(SameBM, SrcBM, SrcStartBit,
-            DestBM, DestStartBit, NumBits)
+        !:DestBM = unsafe_copy_bits(SameBM, SrcBM, SrcStartBit,
+            !.DestBM, DestStartBit, NumBits)
      else
          ( if
              ( NumBits < 0
@@ -1142,10 +1159,10 @@ copy_bits(SameBM, SrcBM, SrcStartBit, DestBM, DestStartBit, NumBits) =
                  SrcStartBit, NumBits)
          else if
              ( DestStartBit < 0
-            ; not in_range(DestBM, DestStartBit + NumBits - 1)
+            ; not in_range(!.DestBM, DestStartBit + NumBits - 1)
              )
          then
-            throw_bounds_error(DestBM, "copy_bits (destination)",
+            throw_bounds_error(!.DestBM, "copy_bits (destination)",
                  DestStartBit, NumBits)
          else
              throw_bitmap_error("bitmap.copy_bits: failed to diagnose error")
@@ -1271,19 +1288,20 @@ copy_bytes_in_bitmap(SrcBM, SrcStartByteIndex, DestStartByteIndex, NumBytes) =
  :- mode copy_bytes(in, in, in,
      bitmap_di, in, in) = bitmap_uo is det.

-copy_bytes(SameBM, SrcBM, SrcStartByte, DestBM, DestStartByte, NumBytes) =
+copy_bytes(SameBM, SrcBM, SrcStartByte, !.DestBM, DestStartByte, NumBytes)
+        = !:DestBM :-
      ( if
          NumBytes = 0
      then
-        DestBM
+        true
      else if
          NumBytes > 0,
          SrcStartByte >= 0,
          byte_in_range(SrcBM, SrcStartByte + NumBytes - 1),
          DestStartByte >= 0,
-        byte_in_range(DestBM, DestStartByte + NumBytes - 1)
+        byte_in_range(!.DestBM, DestStartByte + NumBytes - 1)
      then
-        unsafe_copy_bytes(SameBM, SrcBM, SrcStartByte, DestBM,
+        !:DestBM = unsafe_copy_bytes(SameBM, SrcBM, SrcStartByte, !.DestBM,
              DestStartByte, NumBytes)
      else
          throw_bitmap_error("bitmap.copy_bytes: out of range")
@@ -2005,44 +2023,42 @@ set_bits_in_byte(Byte0, FirstBit, NumBits, Bits) = Byte :-

  %---------------------------------------------------------------------------%

-    % throw_bounds_error(BM, PredName, Index)
+    % throw_bit_bounds_error(BM, PredName, BitIndex):
      %
-:- func throw_bounds_error(bitmap, string, bit_index) = _ is erroneous.
+:- pred throw_bit_bounds_error(bitmap::in, string::in, bit_index::in) is erroneous.

-throw_bounds_error(BM, Pred, Index) =
-    throw_bitmap_error(
-        % XXX Why is the bounds "[x - y)" in throw_bitmap_error/3
-        % versus "[x, y)" in throw_bounds_error/4?
-        string.format(
-            "%s: index %d is out of bounds [0 - %d).",
-            [s(Pred), i(Index), i(BM ^ num_bits)])).
+throw_bit_bounds_error(BM, Pred, BitIndex) :-
+    string.format(
+        "%s: bit index %d is out of bounds [0, %d).",
+        [s(Pred), i(BitIndex), i(BM ^ num_bits)], Msg),
+    throw_bitmap_error(Msg).

-    % throw_bounds_error(BM, PredName, Index, NumBits)
+    % throw_byte_bounds_error(BM, PredName, ByteIndex):
      %
-:- func throw_bounds_error(bitmap, string, bit_index, num_bits) = _
-    is erroneous.
+:- pred throw_byte_bounds_error(bitmap::in, string::in, byte_index::in) is erroneous.

-throw_bounds_error(BM, Pred, Index, NumBits) = _ :-
-    throw_bounds_error(BM, Pred, Index, NumBits).
+throw_byte_bounds_error(BM, Pred, ByteIndex) :-
+    ( if BM ^ num_bits = 0 then
+        UB = -1
+    else
+        UB = BM ^ num_bits / bits_per_byte
+    ),
+    string.format(
+        "%s: byte index %d is out of bounds [0, %d].",
+        [s(Pred), i(ByteIndex), i(UB)], Msg),
+    throw_bitmap_error(Msg).

  throw_bounds_error(BM, Pred, Index, NumBits) :-
      ( if NumBits < 0 then
          string.format("%s: negative number of bits: %d.",
              [s(Pred), i(NumBits)], Msg)
      else
-        % XXX Why is the bounds "[x - y)" in throw_bitmap_error/3
-        % versus "[x, y)" in throw_bounds_error/4?
          string.format(
              "%s: %d bits starting at bit %d is out of bounds [0, %d).",
              [s(Pred), i(NumBits), i(Index), i(BM ^ num_bits)], Msg)
      ),
      throw_bitmap_error(Msg).

-:- func throw_bitmap_error(string) = _ is erroneous.
-
-throw_bitmap_error(Msg) = _ :-
-    throw_bitmap_error(Msg).
-
  :- pred throw_bitmap_error(string::in) is erroneous.

  throw_bitmap_error(Msg) :-
diff --git a/tests/hard_coded/Mmakefile b/tests/hard_coded/Mmakefile
index 4bdef3a..92fcd35 100644
--- a/tests/hard_coded/Mmakefile
+++ b/tests/hard_coded/Mmakefile
@@ -641,6 +641,7 @@ ifeq "$(findstring profdeep,$(GRADE))" ""
  		arith_uint16 \
  		arith_uint32 \
  		arith_uint8 \
+		bitmap_bytes \
  		bitmap_empty \
  		bitmap_test \
  		bitwise_int \
diff --git a/tests/hard_coded/bitmap_bytes.exp b/tests/hard_coded/bitmap_bytes.exp
index e69de29..63930a3 100644
--- a/tests/hard_coded/bitmap_bytes.exp
+++ b/tests/hard_coded/bitmap_bytes.exp
@@ -0,0 +1,19 @@
+Bitmap: 
+^ byte(-1): bitmap.byte: byte index -1 is out of bounds [0, -1].
+^ byte(0): bitmap.byte: byte index 0 is out of bounds [0, -1].
+^ byte(1): bitmap.byte: byte index 1 is out of bounds [0, -1].
+
+Bitmap: 00000000.00000000.00000000
+^ byte(-1): bitmap.byte: byte index -1 is out of bounds [0, 3].
+^ byte(0): 0
+^ byte(1): 0
+^ byte(2): 0
+^ byte(3): bitmap.byte: byte index 3 is out of bounds [0, 3].
+^ byte(4): bitmap.byte: byte index 4 is out of bounds [0, 3].
+
+Bitmap: 00000000.00000000.0
+^ byte(-1): bitmap.byte: byte index -1 is out of bounds [0, 2].
+^ byte(0): 0
+^ byte(1): 0
+^ byte(2): bitmap.byte: byte index 2 is out of bounds [0, 2].
+^ byte(3): bitmap.byte: byte index 3 is out of bounds [0, 2].
diff --git a/tests/hard_coded/bitmap_bytes.m b/tests/hard_coded/bitmap_bytes.m
index e69de29..35851bb 100644
--- a/tests/hard_coded/bitmap_bytes.m
+++ b/tests/hard_coded/bitmap_bytes.m
@@ -0,0 +1,57 @@
+%---------------------------------------------------------------------------%
+% vim: ts=4 sw=4 et ft=mercury
+%---------------------------------------------------------------------------%
+%
+% Test byte oriented lookups in bitmaps.
+
+:- module bitmap_bytes.
+:- interface.
+
+:- import_module io.
+
+:- pred main(io::di, io::uo) is cc_multi.
+
+%---------------------------------------------------------------------------%
+%---------------------------------------------------------------------------%
+
+:- implementation.
+
+:- import_module bitmap.
+:- import_module exception.
+:- import_module list.
+:- import_module string.
+
+%---------------------------------------------------------------------------%
+
+main(!IO) :-
+    BM0 = bitmap.init(0),
+    do_bitmap_test(BM0, [-1, 0, 1], !IO),
+    io.nl(!IO),
+
+    BM1 = bitmap.init(24),
+    do_bitmap_test(BM1, [-1, 0, 1, 2, 3, 4], !IO),
+    io.nl(!IO),
+
+    % With partial final byte.
+    BM2 = bitmap.init(17),
+    do_bitmap_test(BM2, [-1, 0, 1, 2, 3], !IO).
+
+:- pred do_bitmap_test(bitmap::in, list(byte_index)::in,
+    io::di, io::uo) is cc_multi.
+
+do_bitmap_test(BM, Indexes, !IO) :-
+    io.format("Bitmap: %s\n", [s(to_byte_string(BM))], !IO),
+    list.foldl(test_byte_lookup(BM), Indexes, !IO).
+
+:- pred test_byte_lookup(bitmap::in, byte_index::in, io::di, io::uo) is cc_multi.
+
+test_byte_lookup(BM, Index, !IO) :-
+    io.format("^ byte(%d): ", [i(Index)], !IO),
+    ( try []
+        Byte = BM ^ byte(Index)
+    then
+        io.write_int(Byte, !IO)
+    catch bitmap_error(Error) ->
+        io.write_string(Error, !IO)
+    ),
+    io.nl(!IO).
diff --git a/tests/hard_coded/bitmap_empty.exp b/tests/hard_coded/bitmap_empty.exp
index 304b5ca..1a7e557 100644
--- a/tests/hard_coded/bitmap_empty.exp
+++ b/tests/hard_coded/bitmap_empty.exp
@@ -21,21 +21,21 @@ ok
  -- det_num_bytes
  0
  -- ^bit
-expected: bitmap_error("bitmap.bit: index 0 is out of bounds [0 - 0).")
+expected: bitmap_error("bitmap.bit: bit index 0 is out of bounds [0, 0).")
  -- ^bits
  0
  -- ^bits:=
  "<0:>"
  -- ^byte
-expected: bitmap_error("bitmap.byte: index 0 is out of bounds [0 - 0).")
+expected: bitmap_error("bitmap.byte: byte index 0 is out of bounds [0, -1].")
  -- ^byte:=
-expected: bitmap_error("bitmap.\'byte :=\': index 0 is out of bounds [0 - 0).")
+expected: bitmap_error("bitmap.\'byte :=\': byte index 0 is out of bounds [0, -1].")
  -- slice
  slice_ctor("<0:>", 0, 0)
  -- byte_slice
  slice_ctor("<0:>", 0, 0)
  -- flip
-expected: bitmap_error("bitmap.flip: index 0 is out of bounds [0 - 0).")
+expected: bitmap_error("bitmap.flip: bit index 0 is out of bounds [0, 0).")
  -- complement
  "<0:>"
  -- union
diff --git a/tests/hard_coded/bitmap_test.exp b/tests/hard_coded/bitmap_test.exp
index 6d78c9a..49847da 100644
--- a/tests/hard_coded/bitmap_test.exp
+++ b/tests/hard_coded/bitmap_test.exp
@@ -235,15 +235,15 @@ First read succeeded
  Second read succeeded
  First read succeeded
  Second read succeeded
-Found exception as expected: bitmap_error("bitmap.bit: index -1 is out of bounds [0 - 64).")
-Found exception as expected: bitmap_error("bitmap.bit: index 64 is out of bounds [0 - 64).")
-Found exception as expected: bitmap_error("bitmap.bit: index 73 is out of bounds [0 - 64).")
+Found exception as expected: bitmap_error("bitmap.bit: bit index -1 is out of bounds [0, 64).")
+Found exception as expected: bitmap_error("bitmap.bit: bit index 64 is out of bounds [0, 64).")
+Found exception as expected: bitmap_error("bitmap.bit: bit index 73 is out of bounds [0, 64).")
  Found exception as expected: bitmap_error("copy_bits (source): 32 bits starting at bit -1 is out of bounds [0, 64).")
  Found exception as expected: bitmap_error("copy_bits (source): 32 bits starting at bit 33 is out of bounds [0, 64).")
  Found exception as expected: bitmap_error("copy_bits (destination): 32 bits starting at bit 33 is out of bounds [0, 64).")
-Found exception as expected: bitmap_error("bitmap.bits: index -1 is out of bounds [0 - 64).")
-Found exception as expected: bitmap_error("bitmap.bits: index 33 is out of bounds [0 - 64).")
+Found exception as expected: bitmap_error("bitmap.bits: bit index -1 is out of bounds [0, 64).")
+Found exception as expected: bitmap_error("bitmap.bits: bit index 33 is out of bounds [0, 64).")
  Found exception as expected: bitmap_error("bitmap.bits: number of bits must be between 0 and `int.bits_per_int\'.")
  Found exception as expected: bitmap_error("bitmap.bits: number of bits must be between 0 and `int.bits_per_int\'.")
-Found exception as expected: bitmap_error("bitmap.bits: index 65 is out of bounds [0 - 64).")
-Found exception as expected: bitmap_error("bitmap.bits: index -1 is out of bounds [0 - 64).")
+Found exception as expected: bitmap_error("bitmap.bits: bit index 65 is out of bounds [0, 64).")
+Found exception as expected: bitmap_error("bitmap.bits: bit index -1 is out of bounds [0, 64).")


More information about the reviews mailing list