summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/std/search.myr2
-rw-r--r--lib/std/test/search.myr2
2 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/search.myr b/lib/std/search.myr
index e5abd99..8ae364f 100644
--- a/lib/std/search.myr
+++ b/lib/std/search.myr
@@ -22,7 +22,7 @@ generic lsearch = {sl, key, cmp
/* binary search over a sorted list of values. */
generic bsearch = {sl, key, cmp
- var hi, lo, mid : usize
+ var hi, lo, mid : size
lo = 0
hi = sl.len - 1
diff --git a/lib/std/test/search.myr b/lib/std/test/search.myr
index 342a406..eea3680 100644
--- a/lib/std/test/search.myr
+++ b/lib/std/test/search.myr
@@ -8,11 +8,13 @@ const main = {
expect(std.lsearch(sl[:], 33, std.numcmp), `std.Some sl.len - 1)
expect(std.lsearch(sl[:], 5, std.numcmp), `std.Some 2)
expect(std.lsearch(sl[:], 6, std.numcmp), `std.None)
+ expect(std.lsearch(sl[:0], 6, std.numcmp), `std.None)
expect(std.bsearch(sl[:], 1, std.numcmp), `std.Some 0)
expect(std.bsearch(sl[:], 33, std.numcmp), `std.Some sl.len - 1)
expect(std.bsearch(sl[:], 5, std.numcmp), `std.Some 2)
expect(std.bsearch(sl[:], 6, std.numcmp), `std.None)
+ expect(std.bsearch(sl[:0], 1, std.numcmp), `std.None) /* empty slice */
}
const expect = {a, b