Skip to content

Commit

Permalink
Merge pull request #7 from ataibarkai/2.0Release/mutatingTryMapNameCh…
Browse files Browse the repository at this point in the history
…ange

mutatingTryMap —> mutateRawValue
  • Loading branch information
ataibarkai authored Nov 14, 2019
2 parents f4752de + c0af143 commit 8cda354
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension SemanticType {
)
}

public mutating func mutatingTryMap(
public mutating func mutateRawValue(
_ mutation: (_ rawValue: inout Spec.RawValue) throws -> ()
) throws {
let mapped = try tryMap { original in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ final class SemanticType_UsabilityExtensionsTests_ErrorfulSemanticTypeTests: XCT
}


func testSuccessfulMutatingTryMap() {
func testSuccessfulMutateRawValue() {
var joe = try! PersonWithShortName(Person(name: "Joe"))
XCTAssertEqual(joe.name, "Joe")
try! joe.mutatingTryMap { person in person.associatedGreeting = person.associatedGreeting.lowercased() }
try! joe.mutateRawValue { person in person.associatedGreeting = person.associatedGreeting.lowercased() }
XCTAssertEqual(joe.associatedGreeting, "hello, my name is joe.")

var joesEmail = try! EmailAddress.create("JonaTHAN@gmail.com").get()
XCTAssertEqual(joesEmail.user, "jonathan")
XCTAssertEqual(joesEmail.host, "gmail.com")
try! joesEmail.mutatingTryMap { email in
try! joesEmail.mutateRawValue { email in
email.removeLast(3)
email.append("nET")
}
Expand All @@ -119,12 +119,12 @@ final class SemanticType_UsabilityExtensionsTests_ErrorfulSemanticTypeTests: XCT
}


func testFailingMutatingTryMap() {
func testFailingMutateRawValue() {
var joe = try! PersonWithShortName(Person(name: "Joe"))

XCTAssertEqual(joe.name, "Joe")
XCTAssertThrowsError(
try joe.mutatingTryMap { person in
try joe.mutateRawValue { person in
person.name.removeLast()
person.name.append(contentsOf: "seph")
}
Expand All @@ -140,7 +140,7 @@ final class SemanticType_UsabilityExtensionsTests_ErrorfulSemanticTypeTests: XCT
XCTAssertEqual(joesEmail.user, "jonathan")
XCTAssertEqual(joesEmail.host, "gmail.com")
XCTAssertThrowsError(
try joesEmail.mutatingTryMap { email in
try joesEmail.mutateRawValue { email in
email.removeLast(10)
}
) { error in
Expand All @@ -159,7 +159,7 @@ final class SemanticType_UsabilityExtensionsTests_ErrorfulSemanticTypeTests: XCT
("testSubscriptAccess", testSubscriptAccess),
("testSuccessfulTryMap", testSuccessfulTryMap),
("testFailingTryMap", testFailingTryMap),
("testSuccessfulMutatingTryMap", testSuccessfulMutatingTryMap),
("testFailingMutatingTryMap", testFailingMutatingTryMap),
("testSuccessfulMutateRawValue", testSuccessfulMutateRawValue),
("testFailingMutateRawValue", testFailingMutateRawValue),
]
}

0 comments on commit 8cda354

Please sign in to comment.