Skip to content

Commit 126fc14

Browse files
rstacpooleclaude
andcommitted
Split °F temperature assertion to satisfy type-checker
The single-expression `1°F` assertion in testTemperature() exceeds the Swift type-checker's per-expression time budget on the macOS CI toolchain once Quantity becomes a RawRepresentable struct. Break it into typed sub-expressions; arithmetic and assertion are unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 78ffb04 commit 126fc14

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

Tests/UnitsTests/DefinitionTests.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,16 @@ class DefinitionTests: XCTestCase {
263263
// Base unit: kelvin
264264
XCTAssertEqual(Measurement("1K"), 1.measured(in: .kelvin))
265265
try XCTAssertEqual(Measurement("1°C"), (273.15.measured(in: .kelvin) + 1.measured(in: .kelvin)).convert(to: .celsius))
266-
try XCTAssertEqual(XCTUnwrap(Measurement("1°F")), try ((273.15 - (32 * 5.0 / 9.0)).measured(in: .kelvin) + (5.0 / 9.0).measured(in: .kelvin)).convert(to: .fahrenheit), accuracy: 0.0001)
266+
// Broken into sub-expressions with explicit types: as a single expression
267+
// this overflows the type-checker's per-expression budget on some toolchains.
268+
let fahrenheitOffset: Double = 273.15 - (32 * 5.0 / 9.0)
269+
let fahrenheitScale: Double = 5.0 / 9.0
270+
let oneFahrenheit = try fahrenheitOffset.measured(in: .kelvin) + fahrenheitScale.measured(in: .kelvin)
271+
try XCTAssertEqual(
272+
XCTUnwrap(Measurement("1°F")),
273+
oneFahrenheit.convert(to: .fahrenheit),
274+
accuracy: 0.0001
275+
)
267276
try XCTAssertEqual(Measurement("1°R"), (5.0 / 9.0).measured(in: .kelvin).convert(to: .rankine))
268277
}
269278

0 commit comments

Comments
 (0)