Fix preferFileMacro case-sensitivity bug

This commit is contained in:
Nick Lockwood
2025-07-14 09:00:38 +01:00
committed by Cal Stephens
parent be767fc1ce
commit f5dad6938c
2 changed files with 8 additions and 2 deletions
+2 -2
View File
@@ -101,9 +101,9 @@ class OptionDescriptor {
type = .binary(true: trueValues, false: falseValues)
toOptions = { value, options in
switch value.lowercased() {
case let value where trueValues.contains(value):
case let value where trueValues.contains(where: { value == $0.lowercased() }):
options[keyPath: keyPath] = true
case let value where falseValues.contains(value):
case let value where falseValues.contains(where: { value == $0.lowercased() }):
options[keyPath: keyPath] = false
default:
throw FormatError.options("")
+6
View File
@@ -349,4 +349,10 @@ class OptionDescriptorTests: XCTestCase {
let options2 = FormatOptions(selfRequired: ["baz", "bar", "foo"])
XCTAssertEqual(options1.description, options2.description)
}
func testFileMacroCase() {
let argument = "#fileID"
var options: FormatOptions = .default
XCTAssertNoThrow(try Descriptors.preferFileMacro.toOptions(argument, &options))
}
}