Skip to content

Commit

Permalink
change operator precedence
Browse files Browse the repository at this point in the history
  • Loading branch information
nghialv committed Jun 1, 2015
1 parent 08ef460 commit 51aad15
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Future/Future.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,19 @@ infix operator <^> {
// Left associativity
associativity left

// Using the same `precedence` value with Swiftz's operator
precedence 140
// precedence
precedence 150
}

/*
infix operator >>- {
// Left associativity
associativity left

// Using the same `precedence` value with Swiftz's operator
precedence 140
// Using the same `precedence` value in antitypical/Result
precedence 100
}
*/

// Operator for `map`
public func <^> <T, U, Error> (future: Future<T, Error>, transform: T -> U) -> Future<U, Error> {
Expand Down
26 changes: 26 additions & 0 deletions FutureTests/FutureFunctionalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,32 @@ extension FutureFunctionalTests {
}
}

func testMapFlatMapOperators() {
let f = requestString("12345") <^> { count($0) } >>- requestStringFromNumber

checkFutureShouldNotBeCompleted(f)

f.onComplete { result in
switch result {
case .Success(let bv): XCTAssertEqual(bv.value, "5", "Future should return 5 as a String")
case .Failure(let be): XCTAssertFalse(true, "Future should not be failed")
}
}
}

func testFlatMapMapOperators() {
let f = requestString("12345") >>- requestStringLenght <^> { "\($0)" }

checkFutureShouldNotBeCompleted(f)

f.onComplete { result in
switch result {
case .Success(let bv): XCTAssertEqual(bv.value, "5", "Future should return 5 as a String")
case .Failure(let be): XCTAssertFalse(true, "Future should not be failed")
}
}
}

func testFilter() {
let noSuchElementError = NSError(domain: "noSuchElement", code: 1, userInfo: nil)

Expand Down

0 comments on commit 51aad15

Please sign in to comment.