Skip to content
This repository was archived by the owner on Jul 4, 2020. It is now read-only.

Commit cd1025f

Browse files
committed
Add test suite
1 parent fbe2b9b commit cd1025f

File tree

4 files changed

+287
-6
lines changed

4 files changed

+287
-6
lines changed

β€ŽShortcutsSwift.xcodeproj/project.pbxproj

Lines changed: 131 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
5502001621D10C9200CE7544 /* ShortcutsSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5502001521D10C9200CE7544 /* ShortcutsSwiftTests.swift */; };
11+
5502001821D10C9200CE7544 /* ShortcutsSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5502FF8621D0F06500CE7544 /* ShortcutsSwift.framework */; };
1012
5502FFD721D0F1A400CE7544 /* ShortcutShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5502FFC221D0F1A300CE7544 /* ShortcutShareViewController.swift */; };
1113
5502FFD821D0F1A400CE7544 /* ActionOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5502FFC321D0F1A300CE7544 /* ActionOutput.swift */; };
1214
5502FFD921D0F1A400CE7544 /* InterpolatedText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5502FFC421D0F1A300CE7544 /* InterpolatedText.swift */; };
@@ -31,7 +33,20 @@
3133
5502FFF321D0F58400CE7544 /* ShortcutsSwift.playgroundbook in Resources */ = {isa = PBXBuildFile; fileRef = 5502FFF221D0F58400CE7544 /* ShortcutsSwift.playgroundbook */; };
3234
/* End PBXBuildFile section */
3335

36+
/* Begin PBXContainerItemProxy section */
37+
5502001921D10C9200CE7544 /* PBXContainerItemProxy */ = {
38+
isa = PBXContainerItemProxy;
39+
containerPortal = 5502FF7D21D0F06500CE7544 /* Project object */;
40+
proxyType = 1;
41+
remoteGlobalIDString = 5502FF8521D0F06500CE7544;
42+
remoteInfo = ShortcutsSwift;
43+
};
44+
/* End PBXContainerItemProxy section */
45+
3446
/* Begin PBXFileReference section */
47+
5502001321D10C9200CE7544 /* ShortcutsSwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ShortcutsSwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
48+
5502001521D10C9200CE7544 /* ShortcutsSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShortcutsSwiftTests.swift; sourceTree = "<group>"; };
49+
5502001721D10C9200CE7544 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3550
5502FF8621D0F06500CE7544 /* ShortcutsSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ShortcutsSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3651
5502FFC221D0F1A300CE7544 /* ShortcutShareViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShortcutShareViewController.swift; sourceTree = "<group>"; };
3752
5502FFC321D0F1A300CE7544 /* ActionOutput.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionOutput.swift; sourceTree = "<group>"; };
@@ -58,6 +73,14 @@
5873
/* End PBXFileReference section */
5974

6075
/* Begin PBXFrameworksBuildPhase section */
76+
5502001021D10C9200CE7544 /* Frameworks */ = {
77+
isa = PBXFrameworksBuildPhase;
78+
buildActionMask = 2147483647;
79+
files = (
80+
5502001821D10C9200CE7544 /* ShortcutsSwift.framework in Frameworks */,
81+
);
82+
runOnlyForDeploymentPostprocessing = 0;
83+
};
6184
5502FF8321D0F06500CE7544 /* Frameworks */ = {
6285
isa = PBXFrameworksBuildPhase;
6386
buildActionMask = 2147483647;
@@ -68,12 +91,22 @@
6891
/* End PBXFrameworksBuildPhase section */
6992

7093
/* Begin PBXGroup section */
94+
5502001421D10C9200CE7544 /* Tests */ = {
95+
isa = PBXGroup;
96+
children = (
97+
5502001521D10C9200CE7544 /* ShortcutsSwiftTests.swift */,
98+
5502001721D10C9200CE7544 /* Info.plist */,
99+
);
100+
path = Tests;
101+
sourceTree = "<group>";
102+
};
71103
5502FF7C21D0F06500CE7544 = {
72104
isa = PBXGroup;
73105
children = (
74106
5502FFF221D0F58400CE7544 /* ShortcutsSwift.playgroundbook */,
75107
5502FFED21D0F2AB00CE7544 /* Helpers */,
76108
5502FFC021D0F1A300CE7544 /* Sources */,
109+
5502001421D10C9200CE7544 /* Tests */,
77110
5502FF8721D0F06500CE7544 /* Products */,
78111
);
79112
sourceTree = "<group>";
@@ -82,23 +115,24 @@
82115
isa = PBXGroup;
83116
children = (
84117
5502FF8621D0F06500CE7544 /* ShortcutsSwift.framework */,
118+
5502001321D10C9200CE7544 /* ShortcutsSwiftTests.xctest */,
85119
);
86120
name = Products;
87121
sourceTree = "<group>";
88122
};
89123
5502FFC021D0F1A300CE7544 /* Sources */ = {
90124
isa = PBXGroup;
91125
children = (
92-
5502FFD621D0F1A400CE7544 /* Action.swift */,
126+
5502FFC121D0F1A300CE7544 /* UI */,
93127
5502FFC321D0F1A300CE7544 /* ActionOutput.swift */,
94-
5502FFC821D0F1A300CE7544 /* Actions */,
95-
5502FFC521D0F1A300CE7544 /* Attachment.swift */,
96-
5502FFD521D0F1A400CE7544 /* BuildShortcut.swift */,
97128
5502FFC421D0F1A300CE7544 /* InterpolatedText.swift */,
98-
5502FFC721D0F1A300CE7544 /* Number.swift */,
129+
5502FFC521D0F1A300CE7544 /* Attachment.swift */,
99130
5502FFC621D0F1A300CE7544 /* PropertyList.swift */,
100-
5502FFC121D0F1A300CE7544 /* UI */,
131+
5502FFC721D0F1A300CE7544 /* Number.swift */,
132+
5502FFC821D0F1A300CE7544 /* Actions */,
101133
5502FFD421D0F1A400CE7544 /* Variable.swift */,
134+
5502FFD521D0F1A400CE7544 /* BuildShortcut.swift */,
135+
5502FFD621D0F1A400CE7544 /* Action.swift */,
102136
);
103137
name = Sources;
104138
path = ShortcutsSwift.playgroundbook/Contents/Sources;
@@ -151,6 +185,24 @@
151185
/* End PBXHeadersBuildPhase section */
152186

153187
/* Begin PBXNativeTarget section */
188+
5502001221D10C9200CE7544 /* ShortcutsSwiftTests */ = {
189+
isa = PBXNativeTarget;
190+
buildConfigurationList = 5502001D21D10C9A00CE7544 /* Build configuration list for PBXNativeTarget "ShortcutsSwiftTests" */;
191+
buildPhases = (
192+
5502000F21D10C9200CE7544 /* Sources */,
193+
5502001021D10C9200CE7544 /* Frameworks */,
194+
5502001121D10C9200CE7544 /* Resources */,
195+
);
196+
buildRules = (
197+
);
198+
dependencies = (
199+
5502001A21D10C9200CE7544 /* PBXTargetDependency */,
200+
);
201+
name = ShortcutsSwiftTests;
202+
productName = ShortcutsSwiftTests;
203+
productReference = 5502001321D10C9200CE7544 /* ShortcutsSwiftTests.xctest */;
204+
productType = "com.apple.product-type.bundle.unit-test";
205+
};
154206
5502FF8521D0F06500CE7544 /* ShortcutsSwift */ = {
155207
isa = PBXNativeTarget;
156208
buildConfigurationList = 5502FF8E21D0F06500CE7544 /* Build configuration list for PBXNativeTarget "ShortcutsSwift" */;
@@ -175,9 +227,13 @@
175227
5502FF7D21D0F06500CE7544 /* Project object */ = {
176228
isa = PBXProject;
177229
attributes = {
230+
LastSwiftUpdateCheck = 1010;
178231
LastUpgradeCheck = 1010;
179232
ORGANIZATIONNAME = "Pandamonia LLC";
180233
TargetAttributes = {
234+
5502001221D10C9200CE7544 = {
235+
CreatedOnToolsVersion = 10.1;
236+
};
181237
5502FF8521D0F06500CE7544 = {
182238
CreatedOnToolsVersion = 10.1;
183239
};
@@ -196,11 +252,19 @@
196252
projectRoot = "";
197253
targets = (
198254
5502FF8521D0F06500CE7544 /* ShortcutsSwift */,
255+
5502001221D10C9200CE7544 /* ShortcutsSwiftTests */,
199256
);
200257
};
201258
/* End PBXProject section */
202259

203260
/* Begin PBXResourcesBuildPhase section */
261+
5502001121D10C9200CE7544 /* Resources */ = {
262+
isa = PBXResourcesBuildPhase;
263+
buildActionMask = 2147483647;
264+
files = (
265+
);
266+
runOnlyForDeploymentPostprocessing = 0;
267+
};
204268
5502FF8421D0F06500CE7544 /* Resources */ = {
205269
isa = PBXResourcesBuildPhase;
206270
buildActionMask = 2147483647;
@@ -212,6 +276,14 @@
212276
/* End PBXResourcesBuildPhase section */
213277

214278
/* Begin PBXSourcesBuildPhase section */
279+
5502000F21D10C9200CE7544 /* Sources */ = {
280+
isa = PBXSourcesBuildPhase;
281+
buildActionMask = 2147483647;
282+
files = (
283+
5502001621D10C9200CE7544 /* ShortcutsSwiftTests.swift in Sources */,
284+
);
285+
runOnlyForDeploymentPostprocessing = 0;
286+
};
215287
5502FF8221D0F06500CE7544 /* Sources */ = {
216288
isa = PBXSourcesBuildPhase;
217289
buildActionMask = 2147483647;
@@ -242,7 +314,51 @@
242314
};
243315
/* End PBXSourcesBuildPhase section */
244316

317+
/* Begin PBXTargetDependency section */
318+
5502001A21D10C9200CE7544 /* PBXTargetDependency */ = {
319+
isa = PBXTargetDependency;
320+
target = 5502FF8521D0F06500CE7544 /* ShortcutsSwift */;
321+
targetProxy = 5502001921D10C9200CE7544 /* PBXContainerItemProxy */;
322+
};
323+
/* End PBXTargetDependency section */
324+
245325
/* Begin XCBuildConfiguration section */
326+
5502001B21D10C9300CE7544 /* Debug */ = {
327+
isa = XCBuildConfiguration;
328+
buildSettings = {
329+
CODE_SIGN_STYLE = Automatic;
330+
DEVELOPMENT_TEAM = "";
331+
INFOPLIST_FILE = Tests/Info.plist;
332+
LD_RUNPATH_SEARCH_PATHS = (
333+
"$(inherited)",
334+
"@executable_path/Frameworks",
335+
"@loader_path/Frameworks",
336+
);
337+
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.ShortcutsSwiftTests;
338+
PRODUCT_NAME = "$(TARGET_NAME)";
339+
SWIFT_VERSION = 4.2;
340+
TARGETED_DEVICE_FAMILY = "1,2";
341+
};
342+
name = Debug;
343+
};
344+
5502001C21D10C9300CE7544 /* Release */ = {
345+
isa = XCBuildConfiguration;
346+
buildSettings = {
347+
CODE_SIGN_STYLE = Automatic;
348+
DEVELOPMENT_TEAM = "";
349+
INFOPLIST_FILE = Tests/Info.plist;
350+
LD_RUNPATH_SEARCH_PATHS = (
351+
"$(inherited)",
352+
"@executable_path/Frameworks",
353+
"@loader_path/Frameworks",
354+
);
355+
PRODUCT_BUNDLE_IDENTIFIER = us.pandamonia.ShortcutsSwiftTests;
356+
PRODUCT_NAME = "$(TARGET_NAME)";
357+
SWIFT_VERSION = 4.2;
358+
TARGETED_DEVICE_FAMILY = "1,2";
359+
};
360+
name = Release;
361+
};
246362
5502FF8C21D0F06500CE7544 /* Debug */ = {
247363
isa = XCBuildConfiguration;
248364
buildSettings = {
@@ -422,6 +538,15 @@
422538
/* End XCBuildConfiguration section */
423539

424540
/* Begin XCConfigurationList section */
541+
5502001D21D10C9A00CE7544 /* Build configuration list for PBXNativeTarget "ShortcutsSwiftTests" */ = {
542+
isa = XCConfigurationList;
543+
buildConfigurations = (
544+
5502001B21D10C9300CE7544 /* Debug */,
545+
5502001C21D10C9300CE7544 /* Release */,
546+
);
547+
defaultConfigurationIsVisible = 0;
548+
defaultConfigurationName = Release;
549+
};
425550
5502FF8021D0F06500CE7544 /* Build configuration list for PBXProject "ShortcutsSwift" */ = {
426551
isa = XCConfigurationList;
427552
buildConfigurations = (
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1010"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "5502FF8521D0F06500CE7544"
18+
BuildableName = "ShortcutsSwift.framework"
19+
BlueprintName = "ShortcutsSwift"
20+
ReferencedContainer = "container:ShortcutsSwift.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
<TestableReference
32+
skipped = "NO">
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "5502001221D10C9200CE7544"
36+
BuildableName = "ShortcutsSwiftTests.xctest"
37+
BlueprintName = "ShortcutsSwiftTests"
38+
ReferencedContainer = "container:ShortcutsSwift.xcodeproj">
39+
</BuildableReference>
40+
</TestableReference>
41+
</Testables>
42+
<MacroExpansion>
43+
<BuildableReference
44+
BuildableIdentifier = "primary"
45+
BlueprintIdentifier = "5502FF8521D0F06500CE7544"
46+
BuildableName = "ShortcutsSwift.framework"
47+
BlueprintName = "ShortcutsSwift"
48+
ReferencedContainer = "container:ShortcutsSwift.xcodeproj">
49+
</BuildableReference>
50+
</MacroExpansion>
51+
<AdditionalOptions>
52+
</AdditionalOptions>
53+
</TestAction>
54+
<LaunchAction
55+
buildConfiguration = "Debug"
56+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
57+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
58+
launchStyle = "0"
59+
useCustomWorkingDirectory = "NO"
60+
ignoresPersistentStateOnLaunch = "NO"
61+
debugDocumentVersioning = "YES"
62+
debugServiceExtension = "internal"
63+
allowLocationSimulation = "YES">
64+
<MacroExpansion>
65+
<BuildableReference
66+
BuildableIdentifier = "primary"
67+
BlueprintIdentifier = "5502FF8521D0F06500CE7544"
68+
BuildableName = "ShortcutsSwift.framework"
69+
BlueprintName = "ShortcutsSwift"
70+
ReferencedContainer = "container:ShortcutsSwift.xcodeproj">
71+
</BuildableReference>
72+
</MacroExpansion>
73+
<AdditionalOptions>
74+
</AdditionalOptions>
75+
</LaunchAction>
76+
<ProfileAction
77+
buildConfiguration = "Release"
78+
shouldUseLaunchSchemeArgsEnv = "YES"
79+
savedToolIdentifier = ""
80+
useCustomWorkingDirectory = "NO"
81+
debugDocumentVersioning = "YES">
82+
<MacroExpansion>
83+
<BuildableReference
84+
BuildableIdentifier = "primary"
85+
BlueprintIdentifier = "5502FF8521D0F06500CE7544"
86+
BuildableName = "ShortcutsSwift.framework"
87+
BlueprintName = "ShortcutsSwift"
88+
ReferencedContainer = "container:ShortcutsSwift.xcodeproj">
89+
</BuildableReference>
90+
</MacroExpansion>
91+
</ProfileAction>
92+
<AnalyzeAction
93+
buildConfiguration = "Debug">
94+
</AnalyzeAction>
95+
<ArchiveAction
96+
buildConfiguration = "Release"
97+
revealArchiveInOrganizer = "YES">
98+
</ArchiveAction>
99+
</Scheme>

β€ŽTests/Info.plist

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>$(DEVELOPMENT_LANGUAGE)</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIdentifier</key>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11+
<key>CFBundleInfoDictionaryVersion</key>
12+
<string>6.0</string>
13+
<key>CFBundleName</key>
14+
<string>$(PRODUCT_NAME)</string>
15+
<key>CFBundlePackageType</key>
16+
<string>BNDL</string>
17+
<key>CFBundleShortVersionString</key>
18+
<string>1.0</string>
19+
<key>CFBundleVersion</key>
20+
<string>1</string>
21+
</dict>
22+
</plist>

β€ŽTests/ShortcutsSwiftTests.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import XCTest
2+
import ShortcutsSwift
3+
4+
class ShortcutsSwiftTests: XCTestCase {
5+
6+
/// Tests that the battery level example compiles.
7+
func testBatteryExample() {
8+
var batteryLevel = Variable.actionOutput()
9+
_ = buildShortcut(
10+
comment("This Shortcut was generated in Swift.") +
11+
getBatteryLevel(&batteryLevel) +
12+
ifLessThan(20, ifTrue: (
13+
setLowPowerMode(true) +
14+
showResult("Your battery is at \(batteryLevel)%, you might want to charge it.")
15+
), ifFalse: (
16+
showResult("Your battery is at \(batteryLevel)%, you're probably fine for now.")
17+
))
18+
)
19+
}
20+
21+
/// Tests that the clap along example compiles.
22+
func testClapAlong() {
23+
_ = buildShortcut(
24+
comment("This Shortcut was generated in Swift.") +
25+
ask(question: "WHAT πŸ‘ DO πŸ‘ YOU πŸ‘ WANT πŸ‘ TO πŸ‘ SAY") +
26+
changeCase(to: .uppercase) +
27+
replaceText("[\\s]", replaceWith: " πŸ‘ ", regularExpression: true) +
28+
chooseFromMenu(items: [
29+
("Share", share()),
30+
("Copy to Clipboard", copyToClipboard()),
31+
])
32+
)
33+
}
34+
35+
}

0 commit comments

Comments
Β (0)