lib/strings+test: compare returns int, not i32
Hare's strings::compare returns int (ref/hare/strings/compare.ha:12). Result is a sign, not an index, so the i32 was cargo-culted from the str-index type. Callsites already compared against 0, so callers needed no migration. Widened the two return-site casts (u8→int, i32→int) — the latter avoids i32 underflow on adversarial length diffs. Added a multibyte test row contrasting ASCII vs UTF-8 lead byte to exercise the high-bit-operand path.
This commit is contained in:
@@ -584,6 +584,7 @@ fn streq(a: str, b: str) bool = {
|
||||
if (strings.compare("AB", "ABC") >= 0) { fail(); };
|
||||
if (strings.compare("BCD", "ABC") <= 0) { fail(); };
|
||||
if (strings.compare("ABC", "abc") >= 0) { fail(); };
|
||||
if (strings.compare("ABC", "こんにちは") >= 0) { fail(); };
|
||||
};
|
||||
|
||||
// ---- sub / bytesub ----------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user