Skip to content

Commit

Permalink
Merge pull request #8 from citizen428/rename-negative-match-operator
Browse files Browse the repository at this point in the history
Rename !=~ to !~
  • Loading branch information
nubbel committed Feb 12, 2016
2 parents 18a10e2 + e9782e5 commit 8d79919
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions VerbalExpressions/VerbalExpressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ extension VerbalExpressions: CustomStringConvertible {
// Match operators
// Adapted from https://gist.github.com/JimRoepcke/d68dd41ee2fedc6a0c67
infix operator =~ { associativity left precedence 140 }
infix operator !=~ { associativity left precedence 140 }
infix operator !~ { associativity left precedence 140 }

public func =~(lhs: String, rhs: VerbalExpressions) -> Bool {
return rhs.test(lhs)
Expand All @@ -265,10 +265,10 @@ public func =~(lhs: VerbalExpressions, rhs: String) -> Bool {
return lhs.test(rhs)
}

public func !=~(lhs: String, rhs: VerbalExpressions) -> Bool {
public func !~(lhs: String, rhs: VerbalExpressions) -> Bool {
return !(lhs =~ rhs)
}

public func !=~(lhs: VerbalExpressions, rhs: String) -> Bool {
public func !~(lhs: VerbalExpressions, rhs: String) -> Bool {
return !(lhs =~ rhs)
}
4 changes: 2 additions & 2 deletions VerbalExpressionsTests/VerbalExpressionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ class VerbalExpressionsTests: XCTestCase {
.startOfLine()
.then("a")

XCTAssert("a" =~ tester, "starts with an a")
XCTAssert("ba" !=~ tester, "doesn't start with an a")
XCTAssert("a" =~ tester, "starts with an a")
XCTAssert("ba" !~ tester, "doesn't start with an a")
}

}

0 comments on commit 8d79919

Please sign in to comment.