@@ -15,8 +15,8 @@ import ArgumentParserTestHelpers
1515
1616final class MathExampleTests : XCTestCase {
1717 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 " )
2020 }
2121
2222 func testMath_Help( ) throws {
@@ -37,9 +37,9 @@ final class MathExampleTests: XCTestCase {
3737 See 'math help <subcommand>' for detailed help.
3838 """
3939
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)
4343 }
4444
4545 func testMath_AddHelp( ) throws {
@@ -57,14 +57,14 @@ final class MathExampleTests: XCTestCase {
5757 -h, --help Show help information.
5858 """
5959
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)
6363
6464 // 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)
6868 }
6969
7070 func testMath_StatsMeanHelp( ) throws {
@@ -82,9 +82,9 @@ final class MathExampleTests: XCTestCase {
8282 -h, --help Show help information.
8383 """
8484
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)
8888 }
8989
9090 func testMath_StatsQuantilesHelp( ) throws {
@@ -109,15 +109,15 @@ final class MathExampleTests: XCTestCase {
109109
110110 // The "quantiles" subcommand's run() method is unimplemented, so it
111111 // just generates the help text.
112- AssertExecuteCommand ( command: " math stats quantiles " , expected: helpText)
112+ try AssertExecuteCommand ( command: " math stats quantiles " , expected: helpText)
113113
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)
117117 }
118118
119119 func testMath_CustomValidation( ) throws {
120- AssertExecuteCommand (
120+ try AssertExecuteCommand (
121121 command: " math stats average --kind mode " ,
122122 expected: """
123123 Error: Please provide at least one value to calculate the mode.
@@ -128,38 +128,38 @@ final class MathExampleTests: XCTestCase {
128128 }
129129
130130 func testMath_Versions( ) throws {
131- AssertExecuteCommand (
131+ try AssertExecuteCommand (
132132 command: " math --version " ,
133133 expected: " 1.0.0 " )
134- AssertExecuteCommand (
134+ try AssertExecuteCommand (
135135 command: " math stats --version " ,
136136 expected: " 1.0.0 " )
137- AssertExecuteCommand (
137+ try AssertExecuteCommand (
138138 command: " math stats average --version " ,
139139 expected: " 1.5.0-alpha " )
140140 }
141141
142142 func testMath_ExitCodes( ) throws {
143- AssertExecuteCommand (
143+ try AssertExecuteCommand (
144144 command: " math stats quantiles --test-success-exit-code " ,
145145 expected: " " ,
146146 exitCode: . success)
147- AssertExecuteCommand (
147+ try AssertExecuteCommand (
148148 command: " math stats quantiles --test-failure-exit-code " ,
149149 expected: " " ,
150150 exitCode: . failure)
151- AssertExecuteCommand (
151+ try AssertExecuteCommand (
152152 command: " math stats quantiles --test-validation-exit-code " ,
153153 expected: " " ,
154154 exitCode: . validationFailure)
155- AssertExecuteCommand (
155+ try AssertExecuteCommand (
156156 command: " math stats quantiles --test-custom-exit-code 42 " ,
157157 expected: " " ,
158158 exitCode: ExitCode ( 42 ) )
159159 }
160160
161161 func testMath_Fail( ) throws {
162- AssertExecuteCommand (
162+ try AssertExecuteCommand (
163163 command: " math --foo " ,
164164 expected: """
165165 Error: Unknown option '--foo'
@@ -168,7 +168,7 @@ final class MathExampleTests: XCTestCase {
168168 """ ,
169169 exitCode: . validationFailure)
170170
171- AssertExecuteCommand (
171+ try AssertExecuteCommand (
172172 command: " math ZZZ " ,
173173 expected: """
174174 Error: The value 'ZZZ' is invalid for '<values>'
@@ -183,45 +183,45 @@ final class MathExampleTests: XCTestCase {
183183// MARK: - Completion Script
184184
185185extension MathExampleTests {
186- func testMath_CompletionScript( ) {
187- AssertExecuteCommand (
186+ func testMath_CompletionScript( ) throws {
187+ try AssertExecuteCommand (
188188 command: " math --generate-completion-script=bash " ,
189189 expected: bashCompletionScriptText)
190- AssertExecuteCommand (
190+ try AssertExecuteCommand (
191191 command: " math --generate-completion-script bash " ,
192192 expected: bashCompletionScriptText)
193- AssertExecuteCommand (
193+ try AssertExecuteCommand (
194194 command: " math --generate-completion-script=zsh " ,
195195 expected: zshCompletionScriptText)
196- AssertExecuteCommand (
196+ try AssertExecuteCommand (
197197 command: " math --generate-completion-script zsh " ,
198198 expected: zshCompletionScriptText)
199- AssertExecuteCommand (
199+ try AssertExecuteCommand (
200200 command: " math --generate-completion-script=fish " ,
201201 expected: fishCompletionScriptText)
202- AssertExecuteCommand (
202+ try AssertExecuteCommand (
203203 command: " math --generate-completion-script fish " ,
204204 expected: fishCompletionScriptText)
205205 }
206206
207- func testMath_CustomCompletion( ) {
208- AssertExecuteCommand (
207+ func testMath_CustomCompletion( ) throws {
208+ try AssertExecuteCommand (
209209 command: " math ---completion stats quantiles -- --custom " ,
210210 expected: """
211211 hello
212212 helicopter
213213 heliotrope
214214 """ )
215215
216- AssertExecuteCommand (
216+ try AssertExecuteCommand (
217217 command: " math ---completion stats quantiles -- --custom h " ,
218218 expected: """
219219 hello
220220 helicopter
221221 heliotrope
222222 """ )
223223
224- AssertExecuteCommand (
224+ try AssertExecuteCommand (
225225 command: " math ---completion stats quantiles -- --custom a " ,
226226 expected: """
227227 aardvark
0 commit comments