Skip to content

Commit f2382d1

Browse files
Copilotmrjf
andauthored
Fix flaky strRemovePrefix property test
Co-authored-by: mrjf <180956+mrjf@users.noreply.github.com>
1 parent 7222399 commit f2382d1

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

tests/stats/string_ops.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,12 @@ describe("strNormalize — properties", () => {
352352
});
353353

354354
describe("strRemovePrefix — properties", () => {
355-
it("result never starts with prefix (when prefix non-empty)", () => {
355+
it("removes exactly one occurrence of prefix when present, else returns str unchanged", () => {
356356
fc.assert(
357357
fc.property(fc.asciiString(), fc.asciiString({ minLength: 1 }), (str, prefix) => {
358358
const result = strRemovePrefix(str, prefix);
359-
return !(result.startsWith(prefix) && str.startsWith(prefix));
359+
// Mirrors Python's str.removeprefix(): strips at most one leading occurrence.
360+
return str.startsWith(prefix) ? prefix + result === str : result === str;
360361
}),
361362
);
362363
});

0 commit comments

Comments
 (0)