Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/_StringProcessing/Utility/AsciiBitset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension DSLTree.CustomCharacterClass {
setBit(val)
if isCaseInsensitive {
switch val {
case 64...90: setBit(val + 32)
case 65...90: setBit(val + 32)
case 97...122: setBit(val - 32)
default: break
}
Expand Down
23 changes: 23 additions & 0 deletions Tests/RegexTests/MatchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,29 @@ extension RegexTests {
firstMatchTest(
"(?i)[X-cD]", input: input, match: input, semanticLevel: semantics)
}

// Boundary tests for case insensitive ASCII matching.
firstMatchTest(
"(?i)[@]", input: "@", match: "@", semanticLevel: semantics)
firstMatchTest(
"(?i)[@]", input: "`", match: nil, semanticLevel: semantics)
firstMatchTest(
"(?i)[`]", input: "`", match: "`", semanticLevel: semantics)
firstMatchTest(
"(?i)[`]", input: "@", match: nil, semanticLevel: semantics)
// A range that spans the "@"/"A" boundary folds "A" but not "@".
firstMatchTest(
"(?i)[?-A]", input: "a", match: "a", semanticLevel: semantics)
firstMatchTest(
"(?i)[?-A]", input: "`", match: nil, semanticLevel: semantics)
// The letter ends of each range still fold.
for (pattern, input) in [
("(?i)[A]", "a"), ("(?i)[a]", "A"),
("(?i)[Z]", "z"), ("(?i)[z]", "Z"),
] {
firstMatchTest(
pattern, input: input, match: input, semanticLevel: semantics)
}
}
}

Expand Down
Loading