@@ -10,6 +10,9 @@ import StdlibUnittest
1010var ObjectiveCTests = TestSuite ( " ObjectiveC " )
1111
1212class NSObjectWithCustomHashable : NSObject {
13+ var _value : Int
14+ var _hashValue : Int
15+
1316 init ( value: Int , hashValue: Int ) {
1417 self . _value = value
1518 self . _hashValue = hashValue
@@ -20,24 +23,22 @@ class NSObjectWithCustomHashable : NSObject {
2023 return self . _value == other_. _value
2124 }
2225
23- override var hashValue : Int {
26+ override var hash : Int {
2427 return _hashValue
2528 }
26-
27- var _value : Int
28- var _hashValue : Int
2929}
3030
3131ObjectiveCTests . test ( " NSObject/Hashable " ) {
32- let instances : [ ( order: Int , object: NSObject ) ] = [
33- ( 10 , NSObjectWithCustomHashable ( value: 10 , hashValue: 100 ) ) ,
34- ( 10 , NSObjectWithCustomHashable ( value: 10 , hashValue: 100 ) ) ,
35- ( 20 , NSObjectWithCustomHashable ( value: 20 , hashValue: 100 ) ) ,
36- ( 30 , NSObjectWithCustomHashable ( value: 30 , hashValue: 300 ) ) ,
32+ let instances : [ ( order: Int , hashOrder : Int , object: NSObject ) ] = [
33+ ( 10 , 1 , NSObjectWithCustomHashable ( value: 10 , hashValue: 100 ) ) ,
34+ ( 10 , 1 , NSObjectWithCustomHashable ( value: 10 , hashValue: 100 ) ) ,
35+ ( 20 , 1 , NSObjectWithCustomHashable ( value: 20 , hashValue: 100 ) ) ,
36+ ( 30 , 2 , NSObjectWithCustomHashable ( value: 30 , hashValue: 300 ) ) ,
3737 ]
3838 checkHashable (
3939 instances. map { $0. object } ,
40- equalityOracle: { instances [ $0] . order == instances [ $1] . order } )
40+ equalityOracle: { instances [ $0] . order == instances [ $1] . order } ,
41+ hashEqualityOracle: { instances [ $0] . hashOrder == instances [ $1] . hashOrder } )
4142}
4243
4344runAllTests ( )
0 commit comments