Skip to content

Commit

Permalink
fix for xcode 7 beta 6
Browse files Browse the repository at this point in the history
  • Loading branch information
cezheng committed Aug 26, 2015
1 parent 04d15f4 commit ab7aca5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
11 changes: 5 additions & 6 deletions PySwiftyRegex/PySwiftyRegex.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ public class re {
return
}

end = advance(string.startIndex, result.range.location)
end = string.startIndex.advancedBy(result.range.location)
results.append(string.substringWithRange(start..<end))
if regex.numberOfCaptureGroups > 0 {
results.extend(MatchObject(string: string, match: result).groups())
results.appendContentsOf(MatchObject(string: string, match: result).groups())
}
splitsLeft--
start = advance(end, result.range.length)
start = end.advancedBy(result.range.length)
}
if start <= string.endIndex {
results.append(string.substringWithRange(start..<string.endIndex))
Expand Down Expand Up @@ -486,9 +486,8 @@ public class re {
if nsrange.location == NSNotFound {
return string.endIndex..<string.endIndex
}

let startIndex = advance(string.startIndex, nsrange.location)
let endIndex = advance(startIndex, nsrange.length)
let startIndex = string.startIndex.advancedBy(nsrange.location)
let endIndex = startIndex.advancedBy(nsrange.length)
return startIndex..<endIndex
}
}
Expand Down
34 changes: 17 additions & 17 deletions PySwiftyRegexTests/ReRegexObjectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, string.startIndex..<advance(string.startIndex, 31))
XCTAssertEqual(match.span(1)!, string.startIndex..<advance(string.startIndex, 4))
XCTAssertEqual(match.span(2)!, advance(string.startIndex, 27)..<advance(string.startIndex, 31))
XCTAssertEqual(match.span()!, string.startIndex..<string.startIndex.advancedBy(31))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.startIndex.advancedBy(4))
XCTAssertEqual(match.span(2)!, string.startIndex.advancedBy(27)..<string.startIndex.advancedBy(31))
}

func testMatchWithRangeSuccess() {
Expand All @@ -62,9 +62,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that on")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, advance(string.startIndex, 4)..<advance(string.startIndex, 38))
XCTAssertEqual(match.span(1)!, advance(string.startIndex, 4)..<advance(string.startIndex, 8))
XCTAssertEqual(match.span(2)!, advance(string.startIndex, 31)..<advance(string.startIndex, 35))
XCTAssertEqual(match.span()!, string.startIndex.advancedBy(4)..<string.startIndex.advancedBy(38))
XCTAssertEqual(match.span(1)!, string.startIndex.advancedBy(4)..<string.startIndex.advancedBy(8))
XCTAssertEqual(match.span(2)!, string.startIndex.advancedBy(31)..<string.startIndex.advancedBy(35))
}

func testMatchFailure() {
Expand All @@ -84,9 +84,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, string.startIndex..<advance(string.startIndex, 31))
XCTAssertEqual(match.span(1)!, string.startIndex..<advance(string.startIndex, 4))
XCTAssertEqual(match.span(2)!, advance(string.startIndex, 27)..<advance(string.startIndex, 31))
XCTAssertEqual(match.span()!, string.startIndex..<string.startIndex.advancedBy(31))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.startIndex.advancedBy(4))
XCTAssertEqual(match.span(2)!, string.startIndex.advancedBy(27)..<string.startIndex.advancedBy(31))
}

func testSearchWithRangeSuccess() {
Expand All @@ -99,9 +99,9 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group()!, "this one is different from that on")
XCTAssertEqual(match.group(1)!, "this")
XCTAssertEqual(match.group(2)!, "that")
XCTAssertEqual(match.span()!, advance(string.startIndex, 4)..<advance(string.startIndex, 38))
XCTAssertEqual(match.span(1)!, advance(string.startIndex, 4)..<advance(string.startIndex, 8))
XCTAssertEqual(match.span(2)!, advance(string.startIndex, 31)..<advance(string.startIndex, 35))
XCTAssertEqual(match.span()!, string.startIndex.advancedBy(4)..<string.startIndex.advancedBy(38))
XCTAssertEqual(match.span(1)!, string.startIndex.advancedBy(4)..<string.startIndex.advancedBy(8))
XCTAssertEqual(match.span(2)!, string.startIndex.advancedBy(31)..<string.startIndex.advancedBy(35))
}

func testSearchNestGroupsSuccess() {
Expand All @@ -116,11 +116,11 @@ class ReRegexObjectTests: XCTestCase {
XCTAssertEqual(match.group(2)!, "this ")
XCTAssertEqual(match.group(3)!, " that that that ")
XCTAssertEqual(match.group(4)!, "that ")
XCTAssertEqual(match.span()!, string.startIndex..<advance(string.startIndex, 52))
XCTAssertEqual(match.span(1)!, string.startIndex..<advance(string.startIndex, 15))
XCTAssertEqual(match.span(2)!, advance(string.startIndex, 10)..<advance(string.startIndex, 15))
XCTAssertEqual(match.span(3)!, advance(string.startIndex, 36)..<advance(string.startIndex, 52))
XCTAssertEqual(match.span(4)!, advance(string.startIndex, 47)..<advance(string.startIndex, 52))
XCTAssertEqual(match.span()!, string.startIndex..<string.startIndex.advancedBy(52))
XCTAssertEqual(match.span(1)!, string.startIndex..<string.startIndex.advancedBy(15))
XCTAssertEqual(match.span(2)!, string.startIndex.advancedBy(10)..<string.startIndex.advancedBy(15))
XCTAssertEqual(match.span(3)!, string.startIndex.advancedBy(36)..<string.startIndex.advancedBy(52))
XCTAssertEqual(match.span(4)!, string.startIndex.advancedBy(47)..<string.startIndex.advancedBy(52))
}

func testFindallSuccess() {
Expand Down

0 comments on commit ab7aca5

Please sign in to comment.