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
  • [Internal] matcher fatal error handler

    Declaration

    Swift

    public static var fatalErrorHandler: (String, StaticString, UInt) -> Void
  • 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

    matcher

    other matcher instance

  • Undocumented

    Declaration

    Swift

    public func set(file: StaticString?, line: UInt?)
  • Undocumented

    Declaration

    Swift

    public func setupCorrentFileAndLine(file: StaticString = #file, line: UInt = #line)
  • Undocumented

    Declaration

    Swift

    public func clearFileAndLine()
  • Undocumented

    Declaration

    Swift

    public func onFatalFailure(_ message: String)
  • 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

    valueType

    compared type

    match

    comparator 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

    valueType

    Type.Type.self

  • Register default comparatot for Equatable types. Required for generic mocks to work.

    Declaration

    Swift

    public func register<T>(_ valueType: T.Type) where T : Equatable

    Parameters

    valueType

    Equatable 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

    valueType

    compared type

    Return Value

    comparator closure

  • Default Sequence comparator, compares count, and then depending on sequence type:

    • for Arrays, elements will be compared element by element (verifying order as well)
    • other Sequences would be treated as unordered, so every element has to have matching element

    Declaration

    Swift

    public func comparator<T>(for valueType: T.Type) -> ((T, T) -> Bool)? where T : Sequence

    Parameters

    valueType

    Sequence 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 : Equatable

    Parameters

    valueType

    Equatable 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 : Sequence

    Parameters

    valueType

    Equatable Sequence type

    Return Value

    comparator closure

  • Undocumented

    See more

    Declaration

    Swift

    public struct ComparisonResult
  • Undocumented

    See more

    Declaration

    Swift

    public struct ParameterComparisonResult