import SwiftLintCore

internal struct NSObjectPreferIsEqualRuleExamples {
    static let nonTriggeringExamples: [Example] = #examples([
        // NSObject subclass without ==
        """
        class AClass: NSObject {
        }
        """,
        // @objc class without ==
        """
        @objc class AClass: SomeNSObjectSubclass {
        }
        """,
        // Class with == which does not subclass NSObject
        """
        class AClass: Equatable {
            static func == (lhs: AClass, rhs: AClass) -> Bool {
                return true
            }
        """,
        // NSObject subclass implementing isEqual
        """
        class AClass: NSObject {
            override func isEqual(_ object: Any?) -> Bool {
                return true
            }
        }
        """,
        // @objc class implementing isEqual
        """
        @objc class AClass: SomeNSObjectSubclass {
            override func isEqual(_ object: Any?) -> Bool {
                return false
            }
        }
        """,
        // NSObject subclass implementing == with different signature
        """
        class AClass: NSObject {
            static func == (lhs: AClass, rhs: BClass) -> Bool {
                return true
            }
        }
        """,
        // Equatable struct
        """
        struct AStruct: Equatable {
            static func == (lhs: AStruct, rhs: AStruct) -> Bool {
                return false
            }
        }
        """,
        // Equatable enum
        """
        enum AnEnum: Equatable {
            static func == (lhs: AnEnum, rhs: AnEnum) -> Bool {
                return true
            }
        }
        """,
        // Nested class is not itself inheriting from NSObject
        """
        class C: NSObject {
            class NestedClass {
                static func == (lhs: NestedClass, rhs: NestedClass) -> Bool {
                    return false
                }
            }
        }
        """.asExample(excludeFromDocumentation: true),
        // Enum inside nested class inheriting from NSObject
        """
        public final class A: NSObject {
            public enum B: Equatable {
                case c

                public func hash(into hasher: inout Hasher) {
                    filename.original.hash(into: &hasher)
                }

                public static func == (lhs: B, rhs: B) -> Bool {
                    return true
                }
            }
        }
        """.asExample(excludeFromDocumentation: true),
    ])

    static let triggeringExamples: [Example] = #examples([
        // NSObject subclass implementing ==
        """
        class AClass: NSObject {
            ↓static func == (lhs: AClass, rhs: AClass) -> Bool {
                return false
            }
        }
        """,
        // @objc class implementing ==
        """
        @objc class AClass: SomeOtherNSObjectSubclass {
            ↓static func == (lhs: AClass, rhs: AClass) -> Bool {
                return true
            }
        }
        """,
        // Equatable NSObject subclass implementing ==
        """
        class AClass: NSObject, Equatable {
            ↓static func == (lhs: AClass, rhs: AClass) -> Bool {
                return false
            }
        }
        """,
        // NSObject subclass overriding isEqual and implementing ==
        """
        class AClass: NSObject {
            override func isEqual(_ object: Any?) -> Bool {
                guard let other = object as? AClass else {
                    return false
                }
                return true
            }

            ↓static func == (lhs: AClass, rhs: AClass) -> Bool {
                return false
            }
        }
        """,
        // Nested @objc class implementing ==
        """
        class C {
            @objc class NestedClass {
                ↓static func == (lhs: NestedClass, rhs: NestedClass) -> Bool {
                    return false
                }
            }
        }
        struct S {
            @objcMembers class NestedClass {
                ↓static func == (lhs: NestedClass, rhs: NestedClass) -> Bool {
                    return false
                }
            }
        }
        enum E {
            struct S {
                @objc class NestedClass {
                    ↓static func == (lhs: NestedClass, rhs: NestedClass) -> Bool {
                        return false
                    }
                }
            }
        }
        extension E {
            @objc class NestedClass {
                ↓static func == (lhs: NestedClass, rhs: NestedClass) -> Bool {
                    return false
                }
            }
        }
        """.asExample(excludeFromDocumentation: true),
    ])
}
