Skip to content

[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

Merged
merged 12 commits into from
Sep 20, 2017
Merged

[stdlib] Comprehensive array tests #11982

merged 12 commits into from
Sep 20, 2017

Conversation

lancep
Copy link
Contributor

@lancep lancep commented Sep 18, 2017

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

@lancep
Copy link
Contributor Author

lancep commented Sep 18, 2017

@swift-ci please smoke test

@lancep
Copy link
Contributor Author

lancep commented Sep 18, 2017

@swift-ci please smoke test Linux platform

@lancep
Copy link
Contributor Author

lancep commented Sep 18, 2017

@swift-ci please smoke test Linux platform

1 similar comment
@lancep
Copy link
Contributor Author

lancep commented Sep 18, 2017

@swift-ci please smoke test Linux platform

@lancep lancep changed the title Comprehensive array tests [stdlib] Comprehensive array tests Sep 19, 2017
Copy link
Member

@milseman milseman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lancep
Copy link
Contributor Author

lancep commented Sep 19, 2017

@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 }) {
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lancep
Copy link
Contributor Author

lancep commented Sep 19, 2017

@swift-ci please smoke test

@lancep
Copy link
Contributor Author

lancep commented Sep 20, 2017

@swift-ci please smoke test

@lancep
Copy link
Contributor Author

lancep commented Sep 20, 2017

@swift-ci please clean smoke test Linux platform

@lancep lancep merged commit 276f49a into swiftlang:master Sep 20, 2017
@lancep lancep deleted the comprehensiveArrayTests branch September 20, 2017 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants