@@ -2,6 +2,7 @@ import core::*;
2
2
3
3
use std;
4
4
import opt = std:: getopts;
5
+ import result:: { err, ok} ;
5
6
6
7
tag fail_type {
7
8
argument_missing;
@@ -30,7 +31,7 @@ fn test_reqopt_long() {
30
31
let opts = [ opt:: reqopt ( "test" ) ] ;
31
32
let rs = opt:: getopts ( args, opts) ;
32
33
alt rs {
33
- opt : : success ( m) {
34
+ ok ( m) {
34
35
assert ( opt:: opt_present ( m, "test" ) ) ;
35
36
assert ( opt:: opt_str ( m, "test" ) == "20" ) ;
36
37
}
@@ -44,7 +45,7 @@ fn test_reqopt_long_missing() {
44
45
let opts = [ opt:: reqopt ( "test" ) ] ;
45
46
let rs = opt:: getopts ( args, opts) ;
46
47
alt rs {
47
- opt : : failure ( f) { check_fail_type ( f, option_missing) ; }
48
+ err ( f) { check_fail_type ( f, option_missing) ; }
48
49
_ { fail; }
49
50
}
50
51
}
@@ -55,7 +56,7 @@ fn test_reqopt_long_no_arg() {
55
56
let opts = [ opt:: reqopt ( "test" ) ] ;
56
57
let rs = opt:: getopts ( args, opts) ;
57
58
alt rs {
58
- opt : : failure ( f) { check_fail_type ( f, argument_missing) ; }
59
+ err ( f) { check_fail_type ( f, argument_missing) ; }
59
60
_ { fail; }
60
61
}
61
62
}
@@ -66,7 +67,7 @@ fn test_reqopt_long_multi() {
66
67
let opts = [ opt:: reqopt ( "test" ) ] ;
67
68
let rs = opt:: getopts ( args, opts) ;
68
69
alt rs {
69
- opt : : failure ( f) { check_fail_type ( f, option_duplicated) ; }
70
+ err ( f) { check_fail_type ( f, option_duplicated) ; }
70
71
_ { fail; }
71
72
}
72
73
}
@@ -77,7 +78,7 @@ fn test_reqopt_short() {
77
78
let opts = [ opt:: reqopt ( "t" ) ] ;
78
79
let rs = opt:: getopts ( args, opts) ;
79
80
alt rs {
80
- opt : : success ( m) {
81
+ ok ( m) {
81
82
assert ( opt:: opt_present ( m, "t" ) ) ;
82
83
assert ( opt:: opt_str ( m, "t" ) == "20" ) ;
83
84
}
@@ -91,7 +92,7 @@ fn test_reqopt_short_missing() {
91
92
let opts = [ opt:: reqopt ( "t" ) ] ;
92
93
let rs = opt:: getopts ( args, opts) ;
93
94
alt rs {
94
- opt : : failure ( f) { check_fail_type ( f, option_missing) ; }
95
+ err ( f) { check_fail_type ( f, option_missing) ; }
95
96
_ { fail; }
96
97
}
97
98
}
@@ -102,7 +103,7 @@ fn test_reqopt_short_no_arg() {
102
103
let opts = [ opt:: reqopt ( "t" ) ] ;
103
104
let rs = opt:: getopts ( args, opts) ;
104
105
alt rs {
105
- opt : : failure ( f) { check_fail_type ( f, argument_missing) ; }
106
+ err ( f) { check_fail_type ( f, argument_missing) ; }
106
107
_ { fail; }
107
108
}
108
109
}
@@ -113,7 +114,7 @@ fn test_reqopt_short_multi() {
113
114
let opts = [ opt:: reqopt ( "t" ) ] ;
114
115
let rs = opt:: getopts ( args, opts) ;
115
116
alt rs {
116
- opt : : failure ( f) { check_fail_type ( f, option_duplicated) ; }
117
+ err ( f) { check_fail_type ( f, option_duplicated) ; }
117
118
_ { fail; }
118
119
}
119
120
}
@@ -126,7 +127,7 @@ fn test_optopt_long() {
126
127
let opts = [ opt:: optopt ( "test" ) ] ;
127
128
let rs = opt:: getopts ( args, opts) ;
128
129
alt rs {
129
- opt : : success ( m) {
130
+ ok ( m) {
130
131
assert ( opt:: opt_present ( m, "test" ) ) ;
131
132
assert ( opt:: opt_str ( m, "test" ) == "20" ) ;
132
133
}
@@ -140,7 +141,7 @@ fn test_optopt_long_missing() {
140
141
let opts = [ opt:: optopt ( "test" ) ] ;
141
142
let rs = opt:: getopts ( args, opts) ;
142
143
alt rs {
143
- opt : : success ( m) { assert ( !opt:: opt_present ( m, "test" ) ) ; }
144
+ ok ( m) { assert ( !opt:: opt_present ( m, "test" ) ) ; }
144
145
_ { fail; }
145
146
}
146
147
}
@@ -151,7 +152,7 @@ fn test_optopt_long_no_arg() {
151
152
let opts = [ opt:: optopt ( "test" ) ] ;
152
153
let rs = opt:: getopts ( args, opts) ;
153
154
alt rs {
154
- opt : : failure ( f) { check_fail_type ( f, argument_missing) ; }
155
+ err ( f) { check_fail_type ( f, argument_missing) ; }
155
156
_ { fail; }
156
157
}
157
158
}
@@ -162,7 +163,7 @@ fn test_optopt_long_multi() {
162
163
let opts = [ opt:: optopt ( "test" ) ] ;
163
164
let rs = opt:: getopts ( args, opts) ;
164
165
alt rs {
165
- opt : : failure ( f) { check_fail_type ( f, option_duplicated) ; }
166
+ err ( f) { check_fail_type ( f, option_duplicated) ; }
166
167
_ { fail; }
167
168
}
168
169
}
@@ -173,7 +174,7 @@ fn test_optopt_short() {
173
174
let opts = [ opt:: optopt ( "t" ) ] ;
174
175
let rs = opt:: getopts ( args, opts) ;
175
176
alt rs {
176
- opt : : success ( m) {
177
+ ok ( m) {
177
178
assert ( opt:: opt_present ( m, "t" ) ) ;
178
179
assert ( opt:: opt_str ( m, "t" ) == "20" ) ;
179
180
}
@@ -187,7 +188,7 @@ fn test_optopt_short_missing() {
187
188
let opts = [ opt:: optopt ( "t" ) ] ;
188
189
let rs = opt:: getopts ( args, opts) ;
189
190
alt rs {
190
- opt : : success ( m) { assert ( !opt:: opt_present ( m, "t" ) ) ; }
191
+ ok ( m) { assert ( !opt:: opt_present ( m, "t" ) ) ; }
191
192
_ { fail; }
192
193
}
193
194
}
@@ -198,7 +199,7 @@ fn test_optopt_short_no_arg() {
198
199
let opts = [ opt:: optopt ( "t" ) ] ;
199
200
let rs = opt:: getopts ( args, opts) ;
200
201
alt rs {
201
- opt : : failure ( f) { check_fail_type ( f, argument_missing) ; }
202
+ err ( f) { check_fail_type ( f, argument_missing) ; }
202
203
_ { fail; }
203
204
}
204
205
}
@@ -209,7 +210,7 @@ fn test_optopt_short_multi() {
209
210
let opts = [ opt:: optopt ( "t" ) ] ;
210
211
let rs = opt:: getopts ( args, opts) ;
211
212
alt rs {
212
- opt : : failure ( f) { check_fail_type ( f, option_duplicated) ; }
213
+ err ( f) { check_fail_type ( f, option_duplicated) ; }
213
214
_ { fail; }
214
215
}
215
216
}
@@ -222,7 +223,7 @@ fn test_optflag_long() {
222
223
let opts = [ opt:: optflag ( "test" ) ] ;
223
224
let rs = opt:: getopts ( args, opts) ;
224
225
alt rs {
225
- opt : : success ( m) { assert ( opt:: opt_present ( m, "test" ) ) ; }
226
+ ok ( m) { assert ( opt:: opt_present ( m, "test" ) ) ; }
226
227
_ { fail; }
227
228
}
228
229
}
@@ -233,7 +234,7 @@ fn test_optflag_long_missing() {
233
234
let opts = [ opt:: optflag ( "test" ) ] ;
234
235
let rs = opt:: getopts ( args, opts) ;
235
236
alt rs {
236
- opt : : success ( m) { assert ( !opt:: opt_present ( m, "test" ) ) ; }
237
+ ok ( m) { assert ( !opt:: opt_present ( m, "test" ) ) ; }
237
238
_ { fail; }
238
239
}
239
240
}
@@ -244,7 +245,7 @@ fn test_optflag_long_arg() {
244
245
let opts = [ opt:: optflag ( "test" ) ] ;
245
246
let rs = opt:: getopts ( args, opts) ;
246
247
alt rs {
247
- opt : : failure ( f) {
248
+ err ( f) {
248
249
log_err opt:: fail_str ( f) ;
249
250
check_fail_type ( f, unexpected_argument) ;
250
251
}
@@ -258,7 +259,7 @@ fn test_optflag_long_multi() {
258
259
let opts = [ opt:: optflag ( "test" ) ] ;
259
260
let rs = opt:: getopts ( args, opts) ;
260
261
alt rs {
261
- opt : : failure ( f) { check_fail_type ( f, option_duplicated) ; }
262
+ err ( f) { check_fail_type ( f, option_duplicated) ; }
262
263
_ { fail; }
263
264
}
264
265
}
@@ -269,7 +270,7 @@ fn test_optflag_short() {
269
270
let opts = [ opt:: optflag ( "t" ) ] ;
270
271
let rs = opt:: getopts ( args, opts) ;
271
272
alt rs {
272
- opt : : success ( m) { assert ( opt:: opt_present ( m, "t" ) ) ; }
273
+ ok ( m) { assert ( opt:: opt_present ( m, "t" ) ) ; }
273
274
_ { fail; }
274
275
}
275
276
}
@@ -280,7 +281,7 @@ fn test_optflag_short_missing() {
280
281
let opts = [ opt:: optflag ( "t" ) ] ;
281
282
let rs = opt:: getopts ( args, opts) ;
282
283
alt rs {
283
- opt : : success ( m) { assert ( !opt:: opt_present ( m, "t" ) ) ; }
284
+ ok ( m) { assert ( !opt:: opt_present ( m, "t" ) ) ; }
284
285
_ { fail; }
285
286
}
286
287
}
@@ -291,7 +292,7 @@ fn test_optflag_short_arg() {
291
292
let opts = [ opt:: optflag ( "t" ) ] ;
292
293
let rs = opt:: getopts ( args, opts) ;
293
294
alt rs {
294
- opt : : success ( m) {
295
+ ok ( m) {
295
296
// The next variable after the flag is just a free argument
296
297
297
298
assert ( m. free [ 0 ] == "20" ) ;
@@ -306,7 +307,7 @@ fn test_optflag_short_multi() {
306
307
let opts = [ opt:: optflag ( "t" ) ] ;
307
308
let rs = opt:: getopts ( args, opts) ;
308
309
alt rs {
309
- opt : : failure ( f) { check_fail_type ( f, option_duplicated) ; }
310
+ err ( f) { check_fail_type ( f, option_duplicated) ; }
310
311
_ { fail; }
311
312
}
312
313
}
@@ -319,7 +320,7 @@ fn test_optmulti_long() {
319
320
let opts = [ opt:: optmulti ( "test" ) ] ;
320
321
let rs = opt:: getopts ( args, opts) ;
321
322
alt rs {
322
- opt : : success ( m) {
323
+ ok ( m) {
323
324
assert ( opt:: opt_present ( m, "test" ) ) ;
324
325
assert ( opt:: opt_str ( m, "test" ) == "20" ) ;
325
326
}
@@ -333,7 +334,7 @@ fn test_optmulti_long_missing() {
333
334
let opts = [ opt:: optmulti ( "test" ) ] ;
334
335
let rs = opt:: getopts ( args, opts) ;
335
336
alt rs {
336
- opt : : success ( m) { assert ( !opt:: opt_present ( m, "test" ) ) ; }
337
+ ok ( m) { assert ( !opt:: opt_present ( m, "test" ) ) ; }
337
338
_ { fail; }
338
339
}
339
340
}
@@ -344,7 +345,7 @@ fn test_optmulti_long_no_arg() {
344
345
let opts = [ opt:: optmulti ( "test" ) ] ;
345
346
let rs = opt:: getopts ( args, opts) ;
346
347
alt rs {
347
- opt : : failure ( f) { check_fail_type ( f, argument_missing) ; }
348
+ err ( f) { check_fail_type ( f, argument_missing) ; }
348
349
_ { fail; }
349
350
}
350
351
}
@@ -355,7 +356,7 @@ fn test_optmulti_long_multi() {
355
356
let opts = [ opt:: optmulti ( "test" ) ] ;
356
357
let rs = opt:: getopts ( args, opts) ;
357
358
alt rs {
358
- opt : : success ( m) {
359
+ ok ( m) {
359
360
assert ( opt:: opt_present ( m, "test" ) ) ;
360
361
assert ( opt:: opt_str ( m, "test" ) == "20" ) ;
361
362
assert ( opt:: opt_strs ( m, "test" ) [ 0 ] == "20" ) ;
@@ -371,7 +372,7 @@ fn test_optmulti_short() {
371
372
let opts = [ opt:: optmulti ( "t" ) ] ;
372
373
let rs = opt:: getopts ( args, opts) ;
373
374
alt rs {
374
- opt : : success ( m) {
375
+ ok ( m) {
375
376
assert ( opt:: opt_present ( m, "t" ) ) ;
376
377
assert ( opt:: opt_str ( m, "t" ) == "20" ) ;
377
378
}
@@ -385,7 +386,7 @@ fn test_optmulti_short_missing() {
385
386
let opts = [ opt:: optmulti ( "t" ) ] ;
386
387
let rs = opt:: getopts ( args, opts) ;
387
388
alt rs {
388
- opt : : success ( m) { assert ( !opt:: opt_present ( m, "t" ) ) ; }
389
+ ok ( m) { assert ( !opt:: opt_present ( m, "t" ) ) ; }
389
390
_ { fail; }
390
391
}
391
392
}
@@ -396,7 +397,7 @@ fn test_optmulti_short_no_arg() {
396
397
let opts = [ opt:: optmulti ( "t" ) ] ;
397
398
let rs = opt:: getopts ( args, opts) ;
398
399
alt rs {
399
- opt : : failure ( f) { check_fail_type ( f, argument_missing) ; }
400
+ err ( f) { check_fail_type ( f, argument_missing) ; }
400
401
_ { fail; }
401
402
}
402
403
}
@@ -407,7 +408,7 @@ fn test_optmulti_short_multi() {
407
408
let opts = [ opt:: optmulti ( "t" ) ] ;
408
409
let rs = opt:: getopts ( args, opts) ;
409
410
alt rs {
410
- opt : : success ( m) {
411
+ ok ( m) {
411
412
assert ( opt:: opt_present ( m, "t" ) ) ;
412
413
assert ( opt:: opt_str ( m, "t" ) == "20" ) ;
413
414
assert ( opt:: opt_strs ( m, "t" ) [ 0 ] == "20" ) ;
@@ -423,7 +424,7 @@ fn test_unrecognized_option_long() {
423
424
let opts = [ opt:: optmulti ( "t" ) ] ;
424
425
let rs = opt:: getopts ( args, opts) ;
425
426
alt rs {
426
- opt : : failure ( f) { check_fail_type ( f, unrecognized_option) ; }
427
+ err ( f) { check_fail_type ( f, unrecognized_option) ; }
427
428
_ { fail; }
428
429
}
429
430
}
@@ -434,7 +435,7 @@ fn test_unrecognized_option_short() {
434
435
let opts = [ opt:: optmulti ( "test" ) ] ;
435
436
let rs = opt:: getopts ( args, opts) ;
436
437
alt rs {
437
- opt : : failure ( f) { check_fail_type ( f, unrecognized_option) ; }
438
+ err ( f) { check_fail_type ( f, unrecognized_option) ; }
438
439
_ { fail; }
439
440
}
440
441
}
@@ -449,7 +450,7 @@ fn test_combined() {
449
450
opt:: optflag ( "f" ) , opt:: optmulti ( "m" ) , opt:: optopt ( "notpresent" ) ] ;
450
451
let rs = opt:: getopts ( args, opts) ;
451
452
alt rs {
452
- opt : : success ( m) {
453
+ ok ( m) {
453
454
assert ( m. free [ 0 ] == "prog" ) ;
454
455
assert ( m. free [ 1 ] == "free1" ) ;
455
456
assert ( opt:: opt_str ( m, "s" ) == "20" ) ;
0 commit comments