How to use beIdenticalToMatcher method of func class

Best Nimble code snippet using func.beIdenticalToMatcher

Run Nimble automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

BeIdenticalTo.swift

Source: BeIdenticalTo.swift Github

copy
1import Foundation
2
3
4/// A Nimble matcher that succeeds when the actual value is the same instance
5/// as the expected instance.
6public func beIdenticalTo<T: AnyObject>(expected: T?) -> NonNilMatcherFunc<T> {
7    return NonNilMatcherFunc { actualExpression, failureMessage in
8        let actual = try actualExpression.evaluate()
9        failureMessage.actualValue = "\(identityAsString(actual))"
10        failureMessage.postfixMessage = "be identical to \(identityAsString(expected))"
11        return actual === expected && actual !== nil
12    }
13}
14
15public func ===<T: AnyObject>(lhs: Expectation<T>, rhs: T?) {
16    lhs.to(beIdenticalTo(rhs))
17}
18public func !==<T: AnyObject>(lhs: Expectation<T>, rhs: T?) {
19    lhs.toNot(beIdenticalTo(rhs))
20}
21
22extension NMBObjCMatcher {
23    public class func beIdenticalToMatcher(expected: NSObject?) -> NMBObjCMatcher {
24        return NMBObjCMatcher(canMatchNil: false) { actualExpression, failureMessage in
25            return try! beIdenticalTo(expected).matches(actualExpression, failureMessage: failureMessage)
26        }
27    }
28}
29
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)