Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions Sources/EventType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,22 @@ public func == <E: EventType>(lhs: Event<E>, rhs: Event<E>) -> Bool

public func == <E: EventType>(lhs: Event<E>, rhs: E) -> Bool
{
return lhs.hashValue == rhs.hashValue
switch lhs {
case .Some(let x):
return x == rhs
case .Any:
return false
}
}

public func == <E: EventType>(lhs: E, rhs: Event<E>) -> Bool
{
return lhs.hashValue == rhs.hashValue
switch rhs {
case .Some(let x):
return x == lhs
case .Any:
return false
}
}

// MARK: NoEvent
Expand Down
23 changes: 20 additions & 3 deletions Sources/StateType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,34 @@ extension State: RawRepresentable

public func == <S: StateType>(lhs: State<S>, rhs: State<S>) -> Bool
{
return lhs.hashValue == rhs.hashValue
switch (lhs, rhs) {
case let (.Some(x1), .Some(x2)) where x1 == x2:
return true
case (.Any, .Any):
return true
default:
return false
}
}

public func == <S: StateType>(lhs: State<S>, rhs: S) -> Bool
{
return lhs.hashValue == rhs.hashValue
switch lhs {
case .Some(let x):
return x == rhs
case .Any:
return false
}
}

public func == <S: StateType>(lhs: S, rhs: State<S>) -> Bool
{
return lhs.hashValue == rhs.hashValue
switch rhs {
case .Some(let x):
return x == lhs
case .Any:
return false
}
}

// MARK: Private
Expand Down
2 changes: 1 addition & 1 deletion Sources/Transition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public struct Transition<S: StateType>: Hashable
// for Transition Equatable
public func == <S: StateType>(left: Transition<S>, right: Transition<S>) -> Bool
{
return left.hashValue == right.hashValue
return left.fromState == right.fromState && left.toState == right.toState
}

//--------------------------------------------------
Expand Down