@@ -38,23 +38,33 @@ class TestNotification : TestNotificationSuper {
3838 let o2 = NSObject ( )
3939 let values : [ Notification ] = [
4040 /* 0 */ Notification ( name: . init( " a " ) , object: o1, userInfo: nil ) ,
41- /* 1 */ Notification ( name: . init( " b " ) , object: o1, userInfo: nil ) ,
42- /* 2 */ Notification ( name: . init( " a " ) , object: o2, userInfo: nil ) ,
43- /* 3 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Foo " : 1 ] ) ,
44- /* 4 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Foo " : 2 ] ) ,
45- /* 5 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Bar " : 1 ] ) ,
46- /* 6 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Foo " : 1 , " Bar " : 2 ] ) ,
41+ /* 1 */ Notification ( name: . init( " a " ) , object: o2, userInfo: nil ) ,
42+ /* 2 */ Notification ( name: . init( " b " ) , object: o1, userInfo: nil ) ,
43+ /* 3 */ Notification ( name: . init( " b " ) , object: o2, userInfo: nil ) ,
44+ /* 4 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Foo " : 1 ] ) ,
45+ /* 5 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Foo " : 2 ] ) ,
46+ /* 6 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Bar " : 1 ] ) ,
47+ /* 7 */ Notification ( name: . init( " a " ) , object: o1, userInfo: [ " Foo " : 1 , " Bar " : 2 ] ) ,
4748 ]
4849
49- let hashException : Set < Int > = [ 3 , 4 ]
50+ let hashGroups : [ Int : Int ] = [
51+ 0 : 0 ,
52+ 1 : 0 ,
53+ 2 : 1 ,
54+ 3 : 1 ,
55+ 4 : 2 ,
56+ 5 : 2 ,
57+ 6 : 3 ,
58+ 7 : 4
59+ ]
5060
5161 checkHashable (
5262 values,
5363 equalityOracle: { $0 == $1 } ,
5464 hashEqualityOracle: {
55- // FIXME: Unfortunately cases 3 and 4 above currently hash the
56- // same way, even though they compare different .
57- $0 == $1 || ( hashException . contains ( $0 ) && hashException . contains ( $1 ) )
65+ // FIXME: Unfortunately while we have 8 different notifications,
66+ // three pairs of them have colliding hash encodings .
67+ hashGroups [ $0 ] == hashGroups [ $1 ]
5868 } )
5969 }
6070}
@@ -87,7 +97,7 @@ NotificationTests.test("test_reflexivity_violation")
8797 Notification ( name: name, object: nil , userInfo: [ " foo " : a] ) ,
8898 Notification ( name: name, object: nil , userInfo: [ " foo " : b] ) ,
8999 ]
90- checkHashable ( values)
100+ checkHashable ( values, equalityOracle : { $0 == $1 } )
91101}
92102
93103
0 commit comments