@@ -873,6 +873,31 @@ func test_numericBitPatterns_to_floatingPointTypes() {
873
873
}
874
874
}
875
875
876
+ func testNSNumberBridgeAnyHashable( ) {
877
+ var dict = [ AnyHashable : Any] ( )
878
+ for i in - Int( UInt8 . min) ... Int ( UInt8 . max) {
879
+ dict [ i] = " \( i) "
880
+ }
881
+
882
+ // When bridging a dictionary to NSDictionary, we should be able to access
883
+ // the keys through either an Int (the original type boxed in AnyHashable)
884
+ // or NSNumber (the type Int bridged to).
885
+ let ns_dict = dict as NSDictionary
886
+ for i in - Int( UInt8 . min) ... Int ( UInt8 . max) {
887
+ guard let value = ns_dict [ i] as? String else {
888
+ expectUnreachable ( " Unable to look up value by Int key. " )
889
+ continue
890
+ }
891
+
892
+ guard let ns_value = ns_dict [ NSNumber ( value: i) ] as? String else {
893
+ expectUnreachable ( " Unable to look up value by NSNumber key. " )
894
+ continue
895
+ }
896
+
897
+ expectEqual ( value, ns_value)
898
+ }
899
+ }
900
+
876
901
nsNumberBridging. test ( " Bridge Int8 " ) { testNSNumberBridgeFromInt8 ( ) }
877
902
nsNumberBridging. test ( " Bridge UInt8 " ) { testNSNumberBridgeFromUInt8 ( ) }
878
903
nsNumberBridging. test ( " Bridge Int16 " ) { testNSNumberBridgeFromInt16 ( ) }
@@ -887,4 +912,5 @@ nsNumberBridging.test("Bridge Float") { testNSNumberBridgeFromFloat() }
887
912
nsNumberBridging. test ( " Bridge Double " ) { testNSNumberBridgeFromDouble ( ) }
888
913
nsNumberBridging. test ( " Bridge CGFloat " ) { testNSNumberBridgeFromCGFloat ( ) }
889
914
nsNumberBridging. test ( " bitPattern to exactly " ) { test_numericBitPatterns_to_floatingPointTypes ( ) }
915
+ nsNumberBridging. test ( " Bridge AnyHashable " ) { testNSNumberBridgeAnyHashable ( ) }
890
916
runAllTests ( )
0 commit comments