lukeh
(Luke Howard)
December 30, 2015, 7:15am
1
Whilst implementing XCTests for NSKeyedUnarchiver, I noticed some issues with equality.
Let’s say I have the following simple Swift program:
import SwiftFoundation
let url1 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com "))!
let url2 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com "))!
print("\(url1.isEqual(url2))")
print("\(url1 == url2)")
It returns false for both, as opposed to true on OS X Foundation.
NSObject() implements Equatable in terms of isEqual; that’s fine, but apart from __NSCFType the bridged types do not implement isEqual:. It seems that hash, isEqual and description need to be pasted in for the bridged types, à la CF_CLASSIMPLEMENTATION.
I feel though I may be missing something – I would have thought TestFoundation would depend on the equality operator working :)
— Luke
lukeh
(Luke Howard)
December 30, 2015, 7:28am
2
Proposed fix:
committed 07:27AM - 30 Dec 15 UTC
Also tracking in [SR-414].
···
On 30 Dec 2015, at 6:15 PM, Luke Howard via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:
import SwiftFoundation
let url1 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
let url2 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
print("\(url1.isEqual(url2))")
print("\(url1 == url2)")
--
www.lukehoward.com
soundcloud.com/lukehoward
Hi Luke,
Your proposed fix seems reasonable to me. Did you submit it as a PR too?
Thanks,
- Tony
···
On Dec 29, 2015, at 11:28 PM, Luke Howard via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:
Proposed fix:
[SR-414] isEqual/hash/description for bridged CF objects · lhoward/swift-corelibs-foundation@fe5dcce · GitHub
Also tracking in [SR-414].
On 30 Dec 2015, at 6:15 PM, Luke Howard via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:
import SwiftFoundation
let url1 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
let url2 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
print("\(url1.isEqual(url2))")
print("\(url1 == url2)")
--
www.lukehoward.com <http://www.lukehoward.com/> ;
soundcloud.com/lukehoward
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
Actually I think we already got this one integrated.
···
On Jan 4, 2016, at 12:58 PM, Tony Parker via swift-corelibs-dev <swift-corelibs-dev@swift.org> wrote:
Hi Luke,
Your proposed fix seems reasonable to me. Did you submit it as a PR too?
Thanks,
- Tony
On Dec 29, 2015, at 11:28 PM, Luke Howard via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:
Proposed fix:
[SR-414] isEqual/hash/description for bridged CF objects · lhoward/swift-corelibs-foundation@fe5dcce · GitHub
Also tracking in [SR-414].
On 30 Dec 2015, at 6:15 PM, Luke Howard via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:
import SwiftFoundation
let url1 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
let url2 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
print("\(url1.isEqual(url2))")
print("\(url1 == url2)")
--
www.lukehoward.com <http://www.lukehoward.com/> ;
soundcloud.com/lukehoward <http://soundcloud.com/lukehoward> ;
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
Cool, thanks Philippe and Luke!
- Tony
···
On Jan 4, 2016, at 12:59 PM, Philippe Hausler <phausler@apple.com> wrote:
Actually I think we already got this one integrated.
On Jan 4, 2016, at 12:58 PM, Tony Parker via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:
Hi Luke,
Your proposed fix seems reasonable to me. Did you submit it as a PR too?
Thanks,
- Tony
On Dec 29, 2015, at 11:28 PM, Luke Howard via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:
Proposed fix:
[SR-414] isEqual/hash/description for bridged CF objects · lhoward/swift-corelibs-foundation@fe5dcce · GitHub
Also tracking in [SR-414].
On 30 Dec 2015, at 6:15 PM, Luke Howard via swift-corelibs-dev <swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>> wrote:
import SwiftFoundation
let url1 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
let url2 = NSURL(string: "foo.xml", relativeToURL:NSURL(string: "https://www.example.com <https://www.example.com/>"\ ))!
print("\(url1.isEqual(url2))")
print("\(url1 == url2)")
--
www.lukehoward.com <http://www.lukehoward.com/> ;
soundcloud.com/lukehoward <http://soundcloud.com/lukehoward> ;
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
_______________________________________________
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org <mailto:swift-corelibs-dev@swift.org>
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev