Rebases and remove duplicate tests

This commit is contained in:
Ornithologist Coder
2018-02-13 11:13:43 +01:00
committed by Marcelo Fabri
parent fd9c9f5fa5
commit 237c7eeef1
3 changed files with 32 additions and 14 deletions
+4 -1
View File
@@ -794,7 +794,10 @@ The next release will require Swift 4.0 or higher to build.
#### Enhancements
* None.
* Adds `xct_specific_matcher` opt-in rule to enforce specific matchers
over `XCTAssertEqual` and `XCTAssertNotEqual`.
[Ornithologist Coder](https://github.com/ornithocoder)
[#1874](https://github.com/realm/SwiftLint/issues/1874)
#### Bug Fixes
+4 -1
View File
@@ -1346,7 +1346,10 @@ extension XCTSpecificMatcherRuleTests {
("testNotEqualNil", testNotEqualNil),
("testEqualNilNil", testEqualNilNil),
("testEqualTrueTrue", testEqualTrueTrue),
("testEqualFalseFalse", testEqualFalseFalse)
("testEqualFalseFalse", testEqualFalseFalse),
("testNotEqualNilNil", testNotEqualNilNil),
("testNotEqualTrueTrue", testNotEqualTrueTrue),
("testNotEqualFalseFalse", testNotEqualFalseFalse)
]
}
@@ -20,43 +20,49 @@ class XCTSpecificMatcherRuleTests: XCTestCase {
func testEqualTrue() {
let string = "XCTAssertEqual(a, true)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
}
func testEqualFalse() {
let string = "XCTAssertEqual(a, false)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
}
func testEqualNil() {
let string = "XCTAssertEqual(a, nil)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertNil' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertNil' instead.")
}
func testNotEqualTrue() {
let string = "XCTAssertNotEqual(a, true)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
}
func testNotEqualFalse() {
let string = "XCTAssertNotEqual(a, false)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
}
func testNotEqualNil() {
let string = "XCTAssertNotEqual(a, nil)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertNotNil' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertNotNil' instead.")
}
// MARK: - Additional Tests
@@ -64,43 +70,49 @@ class XCTSpecificMatcherRuleTests: XCTestCase {
func testEqualNilNil() {
let string = "XCTAssertEqual(nil, nil)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertNil' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertNil' instead.")
}
func testEqualTrueTrue() {
let string = "XCTAssertEqual(true, true)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
}
func testEqualFalseFalse() {
let string = "XCTAssertEqual(false, false)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
}
func testNotEqualNilNil() {
let string = "XCTAssertNotEqual(nil, nil)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertNotNil' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertNotNil' instead.")
}
func testNotEqualTrueTrue() {
let string = "XCTAssertNotEqual(true, true)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertFalse' instead.")
}
func testNotEqualFalseFalse() {
let string = "XCTAssertNotEqual(false, false)"
let violations = self.violations(string)
XCTAssertEqual(violations.count, 1)
XCTAssertEqual(violations.first!.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
XCTAssertEqual(violations.first?.reason, "Prefer the specific matcher 'XCTAssertTrue' instead.")
}
private func violations(_ string: String) -> [StyleViolation] {