[swift-dev] Should we remove _customContainsEquatableElement from stdlib?

Ling Wang an00na at gmail.com
Fri Jan 1 20:11:25 CST 2016


After fumbling for several days and firing a related bug(https://bugs.swift.org/browse/SR-435) I finally submitted the pull request: https://github.com/apple/swift/pull/854.

Thanks for your help!

> On Dec 31, 2015, at 3:49 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:
> 
> On Thu, Dec 31, 2015 at 10:06 PM, Ling Wang <an00na at gmail.com <mailto:an00na at gmail.com>> wrote:
>> Do you mean something like this in validation-test/stdlib/SequenceType.swift.gyb:
>> 
>> SequenceTypeTests.test("Range<Element>.contains/WhereElementIsComparable/dispatch") {
>>  MinimalComparableValue.timesLessWasCalled = 0
>>  let start = 0
>>  let end = 10
>>  let range = Range(start: MinimalComparableValue(start), end: MinimalComparableValue(end))
>>  let count = 20
>>  for test in 0...count {
>>    expectEqual(
>>      test >= start && test < end,
>>      range.contains(MinimalComparableValue(test)))
>>  }
>>  expectEqual(
>>    count * 2, MinimalComparableValue.timesLessWasCalled)
>> }
> 
> Yes, this would be good.
> 
>> There is one issue. MinimalComparableValue doesn’t conform to ForwardIndexType. I’m not sure it is proper for me to add this conformance in an extension because the definition of MinimalComparableValue is “A type that conforms only to `Equatable` and `Comparable`”.
>> 
>> What’s your suggestion?
> 
> I think it would be appropriate to define a special type like
> MinimalComparableValue just for this test since the requirements are
> quite specific (Comparable + ForwardIndexType).
> 
> Dmitri
> 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com <mailto:gribozavr at gmail.com>>*/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20160101/132a9183/attachment.html>


More information about the swift-dev mailing list