Skip to content

Various minor changes to XCTest-files. #80

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 8 commits into from
Mar 26, 2016
Merged

Various minor changes to XCTest-files. #80

merged 8 commits into from
Mar 26, 2016

Conversation

marcusrossel
Copy link
Contributor

This pull request contains multiple minor changes:

  • Most of them are to the style of comments
  • Some are to the formatting of code
  • Few change actual code

This pull request mainly aims at making the files more consistent, and readable.

`XCTMain` is Swift-specific, and should therefore be surrounded by backticks.
Adding backticks to the literal value `false` seemed coherent with other literal values (like array literals `[1, 2, 3]`).

The change from `Bool` to `Boolean` was made, as the "general [...] expression" is defined as follows: `@autoclosure expression: () throws -> Boolean`. Therefore `Boolean` seems more accurate.
Changed `selectedTestFilter` to use the `guard` statement, in order to reduce nesting of `if let`-statements.

The use of `guard` seems appropriate, as the ultimate goal is to reach `selectedTest.matches` (the previous optional bindings being preconditions for this).
Changed the `map` and `filter` methods, to use trailing closure syntax. This improves the readability, as it  removes unnecessary braces.
- Removed braces, which were placed around the item being switched on. This seems to be more confrom to the general Swift-syntax.
- If the statements in each case fit on one line, I moved them next to the `case .Something:`- label. If not they are all on a second line.
- Removed an unnecessary line break.
- Changed the uses of `map` to use trailing closure syntax, in order to improve readability.
- Removed a redundant annotation
- Added backticks around Swift-specific types in comments
- Split a very long one-line comment into multiple lines.
- Changed very simple if-statements to ternary-operators. This also allows for `let` instead of `var`.
@modocache
Copy link
Contributor

Thanks, @marcusrossel! I'm supportive of many of these changes. 💯

guard let selectedTestName = selectedTestName else { return includeAllFilter() }
guard let selectedTest = SelectedTest(selectedTestName: selectedTestName) else { return excludeAllFilter() }

return selectedTest.matches
Copy link
Contributor

Choose a reason for hiding this comment

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

@briancroom Any opinions here? I find both equally readable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this change! The flatter structure is nice.

Choose a reason for hiding this comment

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

Me too. Shorter and less nested.

@briancroom
Copy link
Contributor

Cool! Thanks for taking the time to look through the code so thoroughly @marcusrossel. I've followed up on a couple points in the comments.

/// This function emits a test failure if the general Bool expression passed
/// to it evaluates to false.
/// This function emits a test failure if the general `Boolean` expression passed
/// to it evaluates to `false`.

Choose a reason for hiding this comment

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

I would suggest either keeping it "Bool" and adding the backticks since that is a type name or changing to Boolean and not adding the backpacks since then it's just prose...

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 understand your point. What I don't understand though is: if Boolean is not a defined type, how can it be used as one?:
@autoclosure expression: () throws -> Boolean

This code was taken from XCTAssert.swift

Choose a reason for hiding this comment

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

You're absolutely right! I forgot about the Boolean protocol as distinct from the Bool concrete type.

Never mind!

Copy link
Contributor

Choose a reason for hiding this comment

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

Possibly contributing to the confusion is the fact that this was previously named BooleanType before the recent Swift 3 stdlib naming changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see. I haven't been aware of that name change.
So, I'll keep the changes, as they were (if that's the consensus).

@modocache
Copy link
Contributor

I think this is good to merge. @mike-ferris-apple, could you ask @swift-ci to please test?

@mike-ferris
Copy link

@swift-ci please test

@modocache modocache merged commit f01b3e2 into swiftlang:master Mar 26, 2016
@modocache
Copy link
Contributor

Thanks, @marcusrossel! And thanks for the reviews everyone!

@marcusrossel
Copy link
Contributor Author

Thanks for helping me out guys/gals.

@marcusrossel marcusrossel deleted the patch-1 branch March 26, 2016 15:12
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.

4 participants