Skip to content

Commit aa57652

Browse files
committed
Add Equatable for everything.
1 parent 10e1483 commit aa57652

File tree

3 files changed

+90
-1
lines changed

3 files changed

+90
-1
lines changed

CoreLayout.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
301AB6C81EB1A00D0053C287 /* TrifectaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301AB6BD1EB1A00D0053C287 /* TrifectaTests.swift */; };
3434
301AB6C91EB1A00D0053C287 /* ViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301AB6BE1EB1A00D0053C287 /* ViewTests.swift */; };
3535
301AB6CA1EB1A00D0053C287 /* WrapTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 301AB6BF1EB1A00D0053C287 /* WrapTests.swift */; };
36+
30B2A69D1F175D2200D9D9B6 /* Layout+Equatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30B2A69C1F175D2200D9D9B6 /* Layout+Equatable.swift */; };
3637
30B6C6801F1292CF0048AB1F /* FlexibleSizeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30B6C67F1F1292CF0048AB1F /* FlexibleSizeTests.swift */; };
3738
30B6C6841F12A0680048AB1F /* AbsoluteSizeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30B6C6831F12A0680048AB1F /* AbsoluteSizeTests.swift */; };
3839
30B6C6861F12A1130048AB1F /* RelativeSizeTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30B6C6851F12A1130048AB1F /* RelativeSizeTests.swift */; };
@@ -81,6 +82,7 @@
8182
301AB6BD1EB1A00D0053C287 /* TrifectaTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TrifectaTests.swift; sourceTree = "<group>"; };
8283
301AB6BE1EB1A00D0053C287 /* ViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewTests.swift; sourceTree = "<group>"; };
8384
301AB6BF1EB1A00D0053C287 /* WrapTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WrapTests.swift; sourceTree = "<group>"; };
85+
30B2A69C1F175D2200D9D9B6 /* Layout+Equatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Layout+Equatable.swift"; sourceTree = "<group>"; };
8486
30B6C67F1F1292CF0048AB1F /* FlexibleSizeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlexibleSizeTests.swift; sourceTree = "<group>"; };
8587
30B6C6831F12A0680048AB1F /* AbsoluteSizeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AbsoluteSizeTests.swift; sourceTree = "<group>"; };
8688
30B6C6851F12A1130048AB1F /* RelativeSizeTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RelativeSizeTests.swift; sourceTree = "<group>"; };
@@ -222,6 +224,7 @@
222224
301AB6741EB032710053C287 /* Layout+ComputedLayoutConvertible.swift */,
223225
301AB6761EB032710053C287 /* Layoutable.swift */,
224226
30B805B31EB1A680007B9D52 /* View+Layoutable.swift */,
227+
30B2A69C1F175D2200D9D9B6 /* Layout+Equatable.swift */,
225228
);
226229
name = computing;
227230
sourceTree = "<group>";
@@ -353,6 +356,7 @@
353356
301AB67C1EB032710053C287 /* ComputedLayout.swift in Sources */,
354357
301AB6861EB032710053C287 /* Layoutable.swift in Sources */,
355358
301AB6971EB032B30053C287 /* Yoga.c in Sources */,
359+
30B2A69D1F175D2200D9D9B6 /* Layout+Equatable.swift in Sources */,
356360
301AB6951EB032B30053C287 /* YGNodeList.c in Sources */,
357361
);
358362
runOnlyForDeploymentPostprocessing = 0;

CoreLayout/Layout+Equatable.swift

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//
2+
// Layout+Equatable.swift
3+
// CoreLayout
4+
//
5+
// Created by Jake Marsh on 7/13/17.
6+
// Copyright © 2017 Jake Marsh. All rights reserved.
7+
//
8+
9+
extension Layout : Equatable {
10+
public static func ==(lhs: Layout, rhs: Layout) -> Bool {
11+
return lhs.identifier == rhs.identifier &&
12+
lhs.container == rhs.container &&
13+
lhs.overriddenPosition == rhs.overriddenPosition &&
14+
lhs.size == rhs.size &&
15+
lhs.margin == rhs.margin &&
16+
lhs.padding == rhs.padding &&
17+
lhs.border == rhs.border &&
18+
lhs.isIncludedInLayout == rhs.isIncludedInLayout &&
19+
lhs.children == rhs.children
20+
}
21+
}
22+
23+
extension ContainerBehavior : Equatable {
24+
public static func ==(lhs: ContainerBehavior, rhs: ContainerBehavior) -> Bool {
25+
return lhs.primaryAxis == rhs.primaryAxis &&
26+
lhs.primaryAxis == rhs.primaryAxis &&
27+
lhs.primaryAxisDistribution == rhs.primaryAxisDistribution &&
28+
lhs.secondaryAxisDistribution == rhs.secondaryAxisDistribution &&
29+
lhs.secondaryAxisDistributionWhenWrapping == rhs.secondaryAxisDistributionWhenWrapping &&
30+
lhs.shouldWrap == rhs.shouldWrap &&
31+
lhs.overflow == rhs.overflow
32+
}
33+
34+
}
35+
36+
extension WidthAndOrHeight : Equatable {
37+
public static func ==(lhs: WidthAndOrHeight, rhs: WidthAndOrHeight) -> Bool {
38+
return lhs.width == rhs.width && lhs.height == rhs.height
39+
}
40+
}
41+
42+
extension SizeBehavior : Equatable {
43+
public static func ==(lhs: SizeBehavior, rhs: SizeBehavior) -> Bool {
44+
func modeIsEqual() -> Bool {
45+
switch (lhs.mode, rhs.mode) {
46+
case (.flexibleShrinksButDoesntGrow, .flexible),
47+
(.flexibleShrinksButDoesntGrow, .absolute),
48+
(.flexibleShrinksButDoesntGrow, .relative),
49+
(.flexible, .flexibleShrinksButDoesntGrow),
50+
(.flexible, .absolute),
51+
(.flexible, .relative),
52+
(.absolute, .flexibleShrinksButDoesntGrow),
53+
(.absolute, .flexible),
54+
(.absolute, .relative),
55+
(.relative, .flexibleShrinksButDoesntGrow),
56+
(.relative, .flexible),
57+
(.relative, .absolute):
58+
return false
59+
60+
case (.flexibleShrinksButDoesntGrow, .flexibleShrinksButDoesntGrow),
61+
(.relative, .relative):
62+
return true
63+
64+
case (.absolute(let width, let height), .absolute(let width2, let height2)):
65+
return width == width2 && height == height2
66+
67+
case (.flexible(let units), .flexible(let units2)):
68+
return units == units2
69+
}
70+
}
71+
72+
return modeIsEqual() &&
73+
lhs.minimum == rhs.minimum &&
74+
lhs.maximum == rhs.maximum
75+
}
76+
}
77+
78+
extension Edges : Equatable {
79+
public static func ==(lhs: Edges, rhs: Edges) -> Bool {
80+
return lhs.top == rhs.top &&
81+
lhs.leading == rhs.leading &&
82+
lhs.trailing == rhs.trailing &&
83+
lhs.bottom == rhs.bottom
84+
}
85+
}

CoreLayout/infrastructure/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.0.2</string>
18+
<string>0.0.3</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

0 commit comments

Comments
 (0)