Matcher
public class Matcher
Matcher is container class, responsible for storing and resolving comparators for given types.
-
Shared Matcher instance
Declaration
Swift
public static var `default`: Matcher -
Create new clean matcher instance.
Declaration
Swift
public init() -
Creante new matcher instance, copying existing comparator from another instance.
Declaration
Swift
public init(matcher: Matcher)Parameters
matcherother matcher instance
-
Registers comparator for given type T.
Comparator is a closure of
(T,T) -> Bool.When several comparators for same type are registered to common Matcher instance - it will resolve the most receont one.
Declaration
Swift
public func register<T>(_ valueType: T.Type, match: @escaping (T,T) -> Bool)Parameters
valueTypecompared type
matchcomparator closure
-
Registers comparator for type, like comparing Int.self to Int.self. These types of comparators always returns true. Register like:
Matcher.default.register(CustomType.Type.self)Declaration
Swift
public func register<T>(_ valueType: T.Type.Type)Parameters
valueTypeType.Type.self
-
Register sequence comparator, based on elements comparing.
-
Register default comparatot for Equatable types. Required for generic mocks to work.
Declaration
Swift
public func register<T>(_ valueType: T.Type) where T : EquatableParameters
valueTypeEquatable type
-
Returns comparator closure for given type (if any).
Comparator is a closure of
(T,T) -> Bool.When several comparators for same type are registered to common Matcher instance - it will resolve the most receont one.
Declaration
Swift
public func comparator<T>(for valueType: T.Type) -> ((T, T) -> Bool)?Parameters
valueTypecompared type
Return Value
comparator closure
-
Default Sequence comparator, compares count, and then element by element.
Declaration
Swift
public func comparator<T>(for valueType: T.Type) -> ((T, T) -> Bool)? where T : SequenceParameters
valueTypeSequence type
Return Value
comparator closure
-
Default Equatable comparator, compares if elements are equal.
Declaration
Swift
public func comparator<T>(for valueType: T.Type) -> ((T, T) -> Bool)? where T : EquatableParameters
valueTypeEquatable type
Return Value
comparator closure
-
Default Equatable Sequence comparator, compares count, and then for every element equal element.
Declaration
Swift
public func comparator<T>(for valueType: T.Type) -> ((T, T) -> Bool)? where T : Equatable, T : SequenceParameters
valueTypeEquatable Sequence type
Return Value
comparator closure
View on GitHub
Matcher Class Reference