forked from pointfreeco/swift-custom-dump
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mocks.swift
124 lines (101 loc) · 2.26 KB
/
Mocks.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import CustomDump
import Foundation
class RecursiveFoo { var foo: RecursiveFoo? }
class RepeatedObject {
class Child {
let grandchild: Grandchild
init(id: String) {
grandchild = Grandchild(id: id)
}
}
class Grandchild {
let id: String
init(id: String) {
self.id = id
}
}
let child: Child
let grandchild: Grandchild
init(id: String) {
child = Child(id: id)
grandchild = child.grandchild
}
}
class UserClass {
let id: Int, name: String
init(id: Int, name: String) {
self.id = id
self.name = name
}
}
enum Enum {
case foo
case bar(Int)
case baz(fizz: Double, buzz: String)
case fizz(Double, buzz: String)
case fu(bar: Int)
}
enum Namespaced {
class Class {
var x: Int
init(x: Int) { self.x = x }
}
enum Enum { case x(Int) }
struct Struct { var x: Int }
}
struct Button: CustomDumpReflectable {
var customDumpMirror: Mirror {
.init(
self,
children: [
"cancel": (
action: Any?.none,
label: "Cancel"
)
],
displayStyle: .enum
)
}
}
struct Email: Equatable { let subject: String, body: String }
struct Foo { struct Bar {} }
struct FriendlyUser: Equatable {
var id: Int
var name: String
var friends: [FriendlyUser]
}
struct ID: Hashable, RawRepresentable { let rawValue: String }
struct Wrapper<RawValue>: CustomDumpRepresentable {
let rawValue: RawValue
var customDumpValue: Any {
self.rawValue
}
}
struct LoginState: CustomDumpReflectable {
var email = "", password = "", token: String
var customDumpMirror: Mirror {
.init(
self,
children: [
"email": self.email,
"password": Redacted(rawValue: self.password),
],
displayStyle: .struct
)
}
}
struct NestedDate { var date: Date? }
struct NeverEqual: Equatable { static func == (lhs: Self, rhs: Self) -> Bool { false } }
struct NeverEqualUser: Equatable {
let id: Int
let name: String
static func == (lhs: Self, rhs: Self) -> Bool { false }
}
struct Pair { let driver: User, passenger: User }
struct Redacted<RawValue>: CustomDumpStringConvertible {
var rawValue: RawValue
var customDumpDescription: String {
"<redacted>"
}
}
struct User: Equatable, Identifiable { var id: Int, name: String }