@@ -215,6 +215,35 @@ final class NonincrementalCompilationTests: XCTestCase {
215215 XCTAssertEqual ( sn. nanoseconds, 8000 )
216216 }
217217
218+ func testZeroDuration( ) {
219+ XCTAssertEqual ( TimePoint . zero, TimePoint . seconds ( 0 ) )
220+ XCTAssertEqual ( TimePoint . zero, TimePoint . nanoseconds ( 0 ) )
221+ }
222+
223+ func testDurationSecondsArithmetic( ) {
224+ let x = TimePoint . seconds ( 1 )
225+ XCTAssertEqual ( TimePoint . zero + x, x)
226+ XCTAssertEqual ( x + TimePoint. zero, x)
227+ XCTAssertEqual ( x - TimePoint. zero, x)
228+
229+ let y = TimePoint . nanoseconds ( 1 )
230+ let z = TimePoint . nanoseconds ( 2_000_000 )
231+ XCTAssertEqual ( x + ( y + z) , ( x + y) + z)
232+ }
233+
234+ func testDurationComparison( ) {
235+ let x = TimePoint . seconds ( 1 )
236+ let y = TimePoint . nanoseconds ( 500 )
237+
238+ XCTAssertEqual ( x < y, !( x >= y) )
239+ }
240+
241+ func testDurationOverflow( ) {
242+ XCTAssertEqual ( TimePoint . nanoseconds ( 1_000_000_000 ) , TimePoint . seconds ( 1 ) )
243+ XCTAssertEqual ( TimePoint . nanoseconds ( 500_000_000 ) + TimePoint. nanoseconds ( 500_000_000 ) , TimePoint . seconds ( 1 ) )
244+ XCTAssertEqual ( TimePoint . nanoseconds ( 1_500_000_000 ) + TimePoint. nanoseconds ( 500_000_000 ) , TimePoint . seconds ( 2 ) )
245+ }
246+
218247 func testReadAndWriteBuildRecord( ) throws {
219248 let version = " Apple Swift version 5.1 (swiftlang-1100.0.270.13 clang-1100.0.33.7) "
220249 let options = " abbbfbcaf36b93e58efaadd8271ff142 "
0 commit comments