mirror of
https://github.com/morluto/rea
synced 2026-10-26 06:16:17 -04:00
test(search): pin native Unicode substring matching
The shared literal owner already applies Unicode simple folding. Verify the reported production-helper cases across insensitive literal, sensitive literal and regex selection. Fixes #6634
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { literalSubstringPredicate } from "./analysisSearch.js";
|
||||
import {
|
||||
analysisSearchPredicate,
|
||||
literalSubstringPredicate,
|
||||
} from "./analysisSearch.js";
|
||||
|
||||
it("uses Unicode simple case folding for literal substrings", () => {
|
||||
const matchesSigma = literalSubstringPredicate("Σ", false);
|
||||
@@ -11,3 +14,40 @@ it("uses Unicode simple case folding for literal substrings", () => {
|
||||
expect(literalSubstringPredicate("A.B", false)("a.b")).toBe(true);
|
||||
expect(literalSubstringPredicate("A.B", false)("axb")).toBe(false);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["Σ", "ΟΣ"],
|
||||
["σ", "ΟΣ"],
|
||||
["ς", "ΟΣ"],
|
||||
["Σ", "ΣA"],
|
||||
["foo", "FOO"],
|
||||
["ΟΣ", "ΟΣ"],
|
||||
])(
|
||||
"retains native literal match %s in %s when case is ignored",
|
||||
(pattern, value) => {
|
||||
expect(
|
||||
analysisSearchPredicate({
|
||||
pattern,
|
||||
mode: "literal",
|
||||
case_sensitive: false,
|
||||
document: undefined,
|
||||
})(value),
|
||||
).toBe(true);
|
||||
expect(
|
||||
analysisSearchPredicate({
|
||||
pattern,
|
||||
mode: "literal",
|
||||
case_sensitive: true,
|
||||
document: undefined,
|
||||
})(value),
|
||||
).toBe(value.includes(pattern));
|
||||
expect(
|
||||
analysisSearchPredicate({
|
||||
pattern,
|
||||
mode: "regex",
|
||||
case_sensitive: false,
|
||||
document: undefined,
|
||||
})(value),
|
||||
).toBe(true);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user