@@ -38,23 +38,33 @@ class TestNotification : TestNotificationSuper {
38
38
let o2 = NSObject ( )
39
39
let values : [ Notification ] = [
40
40
/* 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 ] ) ,
47
48
]
48
49
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
+ ]
50
60
51
61
checkHashable (
52
62
values,
53
63
equalityOracle: { $0 == $1 } ,
54
64
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 ]
58
68
} )
59
69
}
60
70
}
@@ -87,7 +97,7 @@ NotificationTests.test("test_reflexivity_violation")
87
97
Notification ( name: name, object: nil , userInfo: [ " foo " : a] ) ,
88
98
Notification ( name: name, object: nil , userInfo: [ " foo " : b] ) ,
89
99
]
90
- checkHashable ( values)
100
+ checkHashable ( values, equalityOracle : { $0 == $1 } )
91
101
}
92
102
93
103
0 commit comments