|
4 | 4 | describe "getopt" -Tag 'Scoop' { |
5 | 5 | it 'handle short option with required argument missing' { |
6 | 6 | $null, $null, $err = getopt '-x' 'x:' '' |
7 | | - $err | should be 'Option -x requires an argument.' |
| 7 | + $err | should -be 'Option -x requires an argument.' |
8 | 8 |
|
9 | 9 | $null, $null, $err = getopt '-xy' 'x:y' '' |
10 | | - $err | should be 'Option -x requires an argument.' |
| 10 | + $err | should -be 'Option -x requires an argument.' |
11 | 11 | } |
12 | 12 |
|
13 | 13 | it 'handle long option with required argument missing' { |
14 | 14 | $null, $null, $err = getopt '--arb' '' 'arb=' |
15 | | - $err | should be 'Option --arb requires an argument.' |
| 15 | + $err | should -be 'Option --arb requires an argument.' |
16 | 16 | } |
17 | 17 |
|
18 | 18 | it 'handle unrecognized short option' { |
19 | 19 | $null, $null, $err = getopt '-az' 'a' '' |
20 | | - $err | should be 'Option -z not recognized.' |
| 20 | + $err | should -be 'Option -z not recognized.' |
21 | 21 | } |
22 | 22 |
|
23 | 23 | it 'handle unrecognized long option' { |
24 | 24 | $null, $null, $err = getopt '--non-exist' '' '' |
25 | | - $err | should be 'Option --non-exist not recognized.' |
| 25 | + $err | should -be 'Option --non-exist not recognized.' |
26 | 26 |
|
27 | 27 | $null, $null, $err = getopt '--global','--another' 'abc:de:' 'global','one' |
28 | | - $err | should be 'Option --another not recognized.' |
| 28 | + $err | should -be 'Option --another not recognized.' |
29 | 29 | } |
30 | 30 |
|
31 | 31 | it 'remaining args returned' { |
32 | 32 | $opt, $rem, $err = getopt '-g','rem' 'g' '' |
33 | | - $err | should be $null |
34 | | - $opt.g | should be $true |
35 | | - $rem | should not be $null |
36 | | - $rem.length | should be 1 |
37 | | - $rem[0] | should be 'rem' |
| 33 | + $err | should -benullorempty |
| 34 | + $opt.g | should -betrue |
| 35 | + $rem | should -not -benullorempty |
| 36 | + $rem.length | should -be 1 |
| 37 | + $rem[0] | should -be 'rem' |
38 | 38 | } |
39 | 39 |
|
40 | 40 | it 'get a long flag and a short option with argument' { |
41 | 41 | $a = "--global -a 32bit test" -split ' ' |
42 | 42 | $opt, $rem, $err = getopt $a 'ga:' 'global','arch=' |
43 | 43 |
|
44 | | - $err | should be $null |
45 | | - $opt.global | should be $true |
46 | | - $opt.a | should be '32bit' |
| 44 | + $err | should -benullorempty |
| 45 | + $opt.global | should -betrue |
| 46 | + $opt.a | should -be '32bit' |
47 | 47 | } |
48 | 48 |
|
49 | 49 | it 'handles regex characters' { |
50 | 50 | $a = "-?" |
51 | | - { $opt, $rem, $err = getopt $a 'ga:' 'global' 'arch=' } | should not throw |
52 | | - { $null, $null, $null = getopt $a '?:' 'help' | should not throw } |
| 51 | + { $opt, $rem, $err = getopt $a 'ga:' 'global' 'arch=' } | should -not -throw |
| 52 | + { $null, $null, $null = getopt $a '?:' 'help' | should -not -throw } |
53 | 53 | } |
54 | 54 |
|
55 | 55 | it 'handles short option without required argument' { |
56 | 56 | $null, $null, $err = getopt '-x' 'x' '' |
57 | | - $err | should be $null |
| 57 | + $err | should -benullorempty |
58 | 58 | } |
59 | 59 |
|
60 | 60 | it 'handles long option without required argument' { |
61 | 61 | $opt, $null, $err = getopt '--long-arg' '' 'long-arg' |
62 | | - $err | should be $null |
63 | | - $opt."long-arg" | should be $true |
| 62 | + $err | should -benullorempty |
| 63 | + $opt."long-arg" | should -betrue |
64 | 64 | } |
65 | 65 |
|
66 | 66 | it 'handles long option with required argument' { |
67 | 67 | $opt, $null, $err = getopt '--long-arg', 'test' '' 'long-arg=' |
68 | | - $err | should be $null |
69 | | - $opt."long-arg" | should be "test" |
| 68 | + $err | should -benullorempty |
| 69 | + $opt."long-arg" | should -be "test" |
70 | 70 | } |
71 | 71 | } |
0 commit comments