@@ -23,9 +23,10 @@ class TestCalendar: XCTestCase {
23
23
( " test_customMirror " , test_customMirror) ,
24
24
( " test_ampmSymbols " , test_ampmSymbols) ,
25
25
( " test_currentCalendarRRstability " , test_currentCalendarRRstability) ,
26
+ ( " test_AnyHashable " , test_AnyHashable) ,
26
27
]
27
28
}
28
-
29
+
29
30
func test_allCalendars( ) {
30
31
for identifier in [
31
32
Calendar . Identifier. buddhist,
@@ -192,13 +193,30 @@ class TestCalendar: XCTestCase {
192
193
XCTAssertEqual ( calendar. firstWeekday, calendarMirror. descendant ( " firstWeekday " ) as? Int )
193
194
XCTAssertEqual ( calendar. minimumDaysInFirstWeek, calendarMirror. descendant ( " minimumDaysInFirstWeek " ) as? Int )
194
195
}
196
+
197
+ func test_AnyHashable( ) {
198
+ let a1 : AnyHashable = Calendar ( identifier: Calendar . Identifier. buddhist)
199
+ let a2 : AnyHashable = NSCalendar ( identifier: NSCalendar . Identifier. buddhist) !
200
+ let b1 : AnyHashable = Calendar ( identifier: Calendar . Identifier. chinese)
201
+ let b2 : AnyHashable = NSCalendar ( identifier: NSCalendar . Identifier. chinese) !
202
+ XCTAssertEqual ( a1, a2)
203
+ XCTAssertEqual ( b1, b2)
204
+ XCTAssertNotEqual ( a1, b1)
205
+ XCTAssertNotEqual ( a1, b2)
206
+ XCTAssertNotEqual ( a2, b1)
207
+ XCTAssertNotEqual ( a2, b2)
208
+
209
+ XCTAssertEqual ( a1. hashValue, a2. hashValue)
210
+ XCTAssertEqual ( b1. hashValue, b2. hashValue)
211
+ }
195
212
}
196
213
197
214
class TestNSDateComponents : XCTestCase {
198
215
199
216
static var allTests : [ ( String , ( TestNSDateComponents ) -> ( ) throws -> Void ) ] {
200
217
return [
201
218
( " test_copyNSDateComponents " , test_copyNSDateComponents) ,
219
+ ( " test_AnyHashable " , test_AnyHashable) ,
202
220
]
203
221
}
204
222
@@ -223,4 +241,22 @@ class TestNSDateComponents: XCTestCase {
223
241
XCTAssertEqual ( components. hour, 12 )
224
242
XCTAssertEqual ( copy. hour, 14 )
225
243
}
244
+
245
+ func test_AnyHashable( ) {
246
+ let d1 = DateComponents ( year: 2018 , month: 8 , day: 1 )
247
+ let d2 = DateComponents ( year: 2014 , month: 6 , day: 2 )
248
+ let a1 : AnyHashable = d1
249
+ let a2 : AnyHashable = d1. _bridgeToObjectiveC ( )
250
+ let b1 : AnyHashable = d2
251
+ let b2 : AnyHashable = d2. _bridgeToObjectiveC ( )
252
+ XCTAssertEqual ( a1, a2)
253
+ XCTAssertEqual ( b1, b2)
254
+ XCTAssertNotEqual ( a1, b1)
255
+ XCTAssertNotEqual ( a1, b2)
256
+ XCTAssertNotEqual ( a2, b1)
257
+ XCTAssertNotEqual ( a2, b2)
258
+
259
+ XCTAssertEqual ( a1. hashValue, a2. hashValue)
260
+ XCTAssertEqual ( b1. hashValue, b2. hashValue)
261
+ }
226
262
}
0 commit comments