-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Comprehensive array tests #11982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@swift-ci please smoke test |
@swift-ci please smoke test Linux platform |
@swift-ci please smoke test Linux platform |
1 similar comment
@swift-ci please smoke test Linux platform |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@swift-ci please smoke test Linux platform |
expectEqual(24, a1.capacity) | ||
|
||
// Fill up to the limit, no reallocation. | ||
for v in stride(from: 50, through: 240, by: 10).lazy.map({ 1000 + $0 }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is kinda sad that stride does not provide a lazy map
by default...
unsafeBitCast(nsa, to: Int.self), | ||
unsafeBitCast(bridgedBack, to: Int.self)) | ||
|
||
_fixLifetime(nsa) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you figure out the difference between _fixLifetime
and _blackHole
? Previous test uses the latter, and this one – the former.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not, meant to use the latter here.
expectNotEqual(identity2, identity1) | ||
expectEqual(3, a1.count) | ||
expectEqual(1010, a1[0].value) | ||
assert(a2._buffer.capacity < originalCapacity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asserts are not useful in tests. If there is a condition, better check it with one of the expect
functions.
values.append((value as! TestObjCValueTy).value) | ||
} | ||
expectEqual(values, [1010, 1020, 1030]) | ||
// The following is not required by the IteratorProtocol protocol, but |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually... This comment is no longer true. See: https://github.com/apple/swift-evolution/blob/master/proposals/0052-iterator-post-nil-guarantee.md
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please clean smoke test Linux platform |
This brings the Array unit tests up to par with the Dictionary ones
rdar://problem/18272070
Test timings
before:
real 0m13.050s
user 0m12.216s
sys 0m0.959s
after:
real 0m16.882s
user 0m15.828s
sys 0m1.217s