1
0
Fork 0

Map optional boolean return with .map { $0 != 0 }

This commit is contained in:
Brendan Szymanski 2026-07-01 18:27:57 -04:00
parent 2bcaafb3f5
commit 3a033057fb
2 changed files with 10 additions and 1 deletions

View file

@ -604,3 +604,9 @@ func testRecordInGenerateFiles() throws {
#expect(output.contains("canFocus.map { $0 ? 1 : 0 } ?? 0"))
#expect(!output.contains(", canFocus)"))
}
@Test("Optional boolean return is mapped with != 0")
func testOptionalBooleanReturnMapping() {
let result = CodeGenerator.wrapCReturnValue(callExpression: "g_value_get_boolean(&value)", returnType: .optional(.boolean))
#expect(result == "g_value_get_boolean(&value).map { $0 != 0 }")
}