Mockingbird Documentation 0.18.0

Function first​Arg(_:​)

public func firstArg<T>(_ matcher: @autoclosure () -> T) -> T  

Specifies the first argument position for an argument matcher.

You must provide an explicit argument position when using argument matchers on an Objective-C method with multiple value type parameters.

@objc class Bird: NSObject {
  @objc dynamic func chirp(volume: Int, duration: Int) {}
}

given(bird.chirp(volume: firstArg(any()),
                 duration: secondArg(any()))).will {
  print($0 as! Int, $1 as! Int)
}

bird.chirp(42, 9001)  // Prints 42, 9001

This is equivalent to the verbose form of declaring an argument position.

given(bird.chirp(volume: arg(any(), at: 0),
                 duration: arg(any(), at: 1))).will {
  print($0 as! Int, $1 as! Int)
}

Parameters

matcher @autoclosure () -> T

An argument matcher.