@@ -15,8 +15,8 @@ import ArgumentParserTestHelpers
15
15
16
16
final class MathExampleTests : XCTestCase {
17
17
func testMath_Simple( ) throws {
18
- AssertExecuteCommand ( command: " math 1 2 3 4 5 " , expected: " 15 " )
19
- AssertExecuteCommand ( command: " math multiply 1 2 3 4 5 " , expected: " 120 " )
18
+ try AssertExecuteCommand ( command: " math 1 2 3 4 5 " , expected: " 15 " )
19
+ try AssertExecuteCommand ( command: " math multiply 1 2 3 4 5 " , expected: " 120 " )
20
20
}
21
21
22
22
func testMath_Help( ) throws {
@@ -37,9 +37,9 @@ final class MathExampleTests: XCTestCase {
37
37
See 'math help <subcommand>' for detailed help.
38
38
"""
39
39
40
- AssertExecuteCommand ( command: " math -h " , expected: helpText)
41
- AssertExecuteCommand ( command: " math --help " , expected: helpText)
42
- AssertExecuteCommand ( command: " math help " , expected: helpText)
40
+ try AssertExecuteCommand ( command: " math -h " , expected: helpText)
41
+ try AssertExecuteCommand ( command: " math --help " , expected: helpText)
42
+ try AssertExecuteCommand ( command: " math help " , expected: helpText)
43
43
}
44
44
45
45
func testMath_AddHelp( ) throws {
@@ -57,14 +57,14 @@ final class MathExampleTests: XCTestCase {
57
57
-h, --help Show help information.
58
58
"""
59
59
60
- AssertExecuteCommand ( command: " math add -h " , expected: helpText)
61
- AssertExecuteCommand ( command: " math add --help " , expected: helpText)
62
- AssertExecuteCommand ( command: " math help add " , expected: helpText)
60
+ try AssertExecuteCommand ( command: " math add -h " , expected: helpText)
61
+ try AssertExecuteCommand ( command: " math add --help " , expected: helpText)
62
+ try AssertExecuteCommand ( command: " math help add " , expected: helpText)
63
63
64
64
// Verify that extra help flags are ignored.
65
- AssertExecuteCommand ( command: " math help add -h " , expected: helpText)
66
- AssertExecuteCommand ( command: " math help add -help " , expected: helpText)
67
- AssertExecuteCommand ( command: " math help add --help " , expected: helpText)
65
+ try AssertExecuteCommand ( command: " math help add -h " , expected: helpText)
66
+ try AssertExecuteCommand ( command: " math help add -help " , expected: helpText)
67
+ try AssertExecuteCommand ( command: " math help add --help " , expected: helpText)
68
68
}
69
69
70
70
func testMath_StatsMeanHelp( ) throws {
@@ -82,9 +82,9 @@ final class MathExampleTests: XCTestCase {
82
82
-h, --help Show help information.
83
83
"""
84
84
85
- AssertExecuteCommand ( command: " math stats average -h " , expected: helpText)
86
- AssertExecuteCommand ( command: " math stats average --help " , expected: helpText)
87
- AssertExecuteCommand ( command: " math help stats average " , expected: helpText)
85
+ try AssertExecuteCommand ( command: " math stats average -h " , expected: helpText)
86
+ try AssertExecuteCommand ( command: " math stats average --help " , expected: helpText)
87
+ try AssertExecuteCommand ( command: " math help stats average " , expected: helpText)
88
88
}
89
89
90
90
func testMath_StatsQuantilesHelp( ) throws {
@@ -109,15 +109,15 @@ final class MathExampleTests: XCTestCase {
109
109
110
110
// The "quantiles" subcommand's run() method is unimplemented, so it
111
111
// just generates the help text.
112
- AssertExecuteCommand ( command: " math stats quantiles " , expected: helpText)
112
+ try AssertExecuteCommand ( command: " math stats quantiles " , expected: helpText)
113
113
114
- AssertExecuteCommand ( command: " math stats quantiles -h " , expected: helpText)
115
- AssertExecuteCommand ( command: " math stats quantiles --help " , expected: helpText)
116
- AssertExecuteCommand ( command: " math help stats quantiles " , expected: helpText)
114
+ try AssertExecuteCommand ( command: " math stats quantiles -h " , expected: helpText)
115
+ try AssertExecuteCommand ( command: " math stats quantiles --help " , expected: helpText)
116
+ try AssertExecuteCommand ( command: " math help stats quantiles " , expected: helpText)
117
117
}
118
118
119
119
func testMath_CustomValidation( ) throws {
120
- AssertExecuteCommand (
120
+ try AssertExecuteCommand (
121
121
command: " math stats average --kind mode " ,
122
122
expected: """
123
123
Error: Please provide at least one value to calculate the mode.
@@ -128,38 +128,38 @@ final class MathExampleTests: XCTestCase {
128
128
}
129
129
130
130
func testMath_Versions( ) throws {
131
- AssertExecuteCommand (
131
+ try AssertExecuteCommand (
132
132
command: " math --version " ,
133
133
expected: " 1.0.0 " )
134
- AssertExecuteCommand (
134
+ try AssertExecuteCommand (
135
135
command: " math stats --version " ,
136
136
expected: " 1.0.0 " )
137
- AssertExecuteCommand (
137
+ try AssertExecuteCommand (
138
138
command: " math stats average --version " ,
139
139
expected: " 1.5.0-alpha " )
140
140
}
141
141
142
142
func testMath_ExitCodes( ) throws {
143
- AssertExecuteCommand (
143
+ try AssertExecuteCommand (
144
144
command: " math stats quantiles --test-success-exit-code " ,
145
145
expected: " " ,
146
146
exitCode: . success)
147
- AssertExecuteCommand (
147
+ try AssertExecuteCommand (
148
148
command: " math stats quantiles --test-failure-exit-code " ,
149
149
expected: " " ,
150
150
exitCode: . failure)
151
- AssertExecuteCommand (
151
+ try AssertExecuteCommand (
152
152
command: " math stats quantiles --test-validation-exit-code " ,
153
153
expected: " " ,
154
154
exitCode: . validationFailure)
155
- AssertExecuteCommand (
155
+ try AssertExecuteCommand (
156
156
command: " math stats quantiles --test-custom-exit-code 42 " ,
157
157
expected: " " ,
158
158
exitCode: ExitCode ( 42 ) )
159
159
}
160
160
161
161
func testMath_Fail( ) throws {
162
- AssertExecuteCommand (
162
+ try AssertExecuteCommand (
163
163
command: " math --foo " ,
164
164
expected: """
165
165
Error: Unknown option '--foo'
@@ -168,7 +168,7 @@ final class MathExampleTests: XCTestCase {
168
168
""" ,
169
169
exitCode: . validationFailure)
170
170
171
- AssertExecuteCommand (
171
+ try AssertExecuteCommand (
172
172
command: " math ZZZ " ,
173
173
expected: """
174
174
Error: The value 'ZZZ' is invalid for '<values>'
@@ -183,45 +183,45 @@ final class MathExampleTests: XCTestCase {
183
183
// MARK: - Completion Script
184
184
185
185
extension MathExampleTests {
186
- func testMath_CompletionScript( ) {
187
- AssertExecuteCommand (
186
+ func testMath_CompletionScript( ) throws {
187
+ try AssertExecuteCommand (
188
188
command: " math --generate-completion-script=bash " ,
189
189
expected: bashCompletionScriptText)
190
- AssertExecuteCommand (
190
+ try AssertExecuteCommand (
191
191
command: " math --generate-completion-script bash " ,
192
192
expected: bashCompletionScriptText)
193
- AssertExecuteCommand (
193
+ try AssertExecuteCommand (
194
194
command: " math --generate-completion-script=zsh " ,
195
195
expected: zshCompletionScriptText)
196
- AssertExecuteCommand (
196
+ try AssertExecuteCommand (
197
197
command: " math --generate-completion-script zsh " ,
198
198
expected: zshCompletionScriptText)
199
- AssertExecuteCommand (
199
+ try AssertExecuteCommand (
200
200
command: " math --generate-completion-script=fish " ,
201
201
expected: fishCompletionScriptText)
202
- AssertExecuteCommand (
202
+ try AssertExecuteCommand (
203
203
command: " math --generate-completion-script fish " ,
204
204
expected: fishCompletionScriptText)
205
205
}
206
206
207
- func testMath_CustomCompletion( ) {
208
- AssertExecuteCommand (
207
+ func testMath_CustomCompletion( ) throws {
208
+ try AssertExecuteCommand (
209
209
command: " math ---completion stats quantiles -- --custom " ,
210
210
expected: """
211
211
hello
212
212
helicopter
213
213
heliotrope
214
214
""" )
215
215
216
- AssertExecuteCommand (
216
+ try AssertExecuteCommand (
217
217
command: " math ---completion stats quantiles -- --custom h " ,
218
218
expected: """
219
219
hello
220
220
helicopter
221
221
heliotrope
222
222
""" )
223
223
224
- AssertExecuteCommand (
224
+ try AssertExecuteCommand (
225
225
command: " math ---completion stats quantiles -- --custom a " ,
226
226
expected: """
227
227
aardvark
0 commit comments