diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-25 22:25:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-25 22:35:17 +0200 |
commit | 62e433131b289ea90e465cf0c5f78c8c226fc692 (patch) | |
tree | 2279c66136d95f1b77484aec147608fe458e8095 /shell | |
parent | d84a604830a7ee3f8fb5f3908ae0d54513393a20 (diff) | |
download | busybox-w32-62e433131b289ea90e465cf0c5f78c8c226fc692.tar.gz busybox-w32-62e433131b289ea90e465cf0c5f78c8c226fc692.tar.bz2 busybox-w32-62e433131b289ea90e465cf0c5f78c8c226fc692.zip |
shell: enable more tests which are passing now
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash_test/ash-arith/arith.right | 58 | ||||
-rwxr-xr-x | shell/ash_test/ash-arith/arith.tests | 45 | ||||
-rwxr-xr-x | shell/ash_test/ash-arith/arith2.sub | 14 | ||||
-rw-r--r-- | shell/hush_test/hush-arith/arith.right | 17 | ||||
-rwxr-xr-x | shell/hush_test/hush-arith/arith.tests | 30 | ||||
-rwxr-xr-x | shell/hush_test/hush-arith/arith2.sub | 14 |
6 files changed, 105 insertions, 73 deletions
diff --git a/shell/ash_test/ash-arith/arith.right b/shell/ash_test/ash-arith/arith.right index 99ef825f5..61fcab55e 100644 --- a/shell/ash_test/ash-arith/arith.right +++ b/shell/ash_test/ash-arith/arith.right | |||
@@ -43,40 +43,60 @@ Format: 'expected actual' | |||
43 | 4 4 | 43 | 4 4 |
44 | 29 29 | 44 | 29 29 |
45 | 5 5 | 45 | 5 5 |
46 | unary plus, minus | ||
46 | -4 -4 | 47 | -4 -4 |
47 | 4 4 | 48 | 4 4 |
49 | conditional expressions | ||
48 | 1 1 | 50 | 1 1 |
49 | 32 32 | 51 | 32 32 |
50 | 32 32 | 52 | 32 32 |
51 | 1 1 | 53 | 1 1 |
52 | 1 1 | 54 | 1 1 |
53 | 32 32 | 55 | 32 32 |
56 | check that the unevaluated part of the ternary operator does not do evaluation or assignment | ||
54 | 20 20 | 57 | 20 20 |
55 | 30 30 | 58 | 30 30 |
56 | 20 20 | 59 | 20 20 |
57 | 30 30 | 60 | 30 30 |
58 | ./arith.tests: line 117: arithmetic syntax error | 61 | check precedence of assignment vs. conditional operator |
62 | ./arith.tests: line 116: arithmetic syntax error | ||
63 | check precedence of assignment vs. conditional operator | ||
64 | associativity of assignment-operator operator | ||
59 | 6 6 | 65 | 6 6 |
60 | 6,5,3 6,5,3 | 66 | 6,5,3 6,5,3 |
67 | octal, hex | ||
61 | 263 263 | 68 | 263 263 |
62 | 255 255 | 69 | 255 255 |
63 | 40 40 | 70 | 40 40 |
64 | ./arith.tests: line 163: arithmetic syntax error | 71 | other bases |
65 | ./arith.tests: line 165: divide by zero | 72 | 10 10 |
66 | ./arith.tests: let: line 166: arithmetic syntax error | 73 | 10 10 |
67 | ./arith.tests: line 167: arithmetic syntax error | 74 | 10 10 |
68 | ./arith.tests: let: line 168: arithmetic syntax error | 75 | 10 10 |
76 | 10 10 | ||
77 | 10 10 | ||
78 | 36 36 | ||
79 | 36 36 | ||
80 | 62 62 | ||
81 | 63 63 | ||
82 | missing number after base | ||
83 | 0 0 | ||
84 | ./arith.tests: line 162: arithmetic syntax error | ||
85 | ./arith.tests: line 164: divide by zero | ||
86 | ./arith.tests: let: line 165: arithmetic syntax error | ||
87 | ./arith.tests: line 166: arithmetic syntax error | ||
88 | ./arith.tests: let: line 167: arithmetic syntax error | ||
69 | abc | 89 | abc |
70 | def | 90 | def |
71 | ghi | 91 | ghi |
72 | ./arith.tests: line 191: arithmetic syntax error | 92 | ./arith.tests: line 190: arithmetic syntax error |
73 | 16 16 | 93 | 16 16 |
74 | ./arith.tests: line 196: arithmetic syntax error | 94 | ./arith.tests: line 195: arithmetic syntax error |
75 | ./arith.tests: line 197: malformed ?: operator | 95 | ./arith.tests: line 196: malformed ?: operator |
76 | ./arith.tests: line 198: arithmetic syntax error | 96 | ./arith.tests: line 197: arithmetic syntax error |
77 | 9 9 | 97 | 9 9 |
78 | ./arith.tests: line 205: arithmetic syntax error | 98 | ./arith.tests: line 204: arithmetic syntax error |
79 | ./arith.tests: line 208: arithmetic syntax error | 99 | ./arith.tests: line 207: arithmetic syntax error |
80 | 9 9 | 100 | 9 9 |
81 | 9 9 | 101 | 9 9 |
82 | 9 9 | 102 | 9 9 |
@@ -98,11 +118,11 @@ ghi | |||
98 | 4 4 | 118 | 4 4 |
99 | 4 4 | 119 | 4 4 |
100 | 7 7 | 120 | 7 7 |
101 | ./arith.tests: line 257: arithmetic syntax error | 121 | ./arith.tests: line 256: arithmetic syntax error |
122 | ./arith.tests: line 258: arithmetic syntax error | ||
102 | ./arith.tests: line 259: arithmetic syntax error | 123 | ./arith.tests: line 259: arithmetic syntax error |
103 | ./arith.tests: line 260: arithmetic syntax error | 124 | ./arith.tests: line 261: arithmetic syntax error |
104 | ./arith.tests: line 262: arithmetic syntax error | 125 | ./arith.tests: line 262: arithmetic syntax error |
105 | ./arith.tests: line 263: arithmetic syntax error | ||
106 | 4 4 | 126 | 4 4 |
107 | 7 7 | 127 | 7 7 |
108 | -7 -7 | 128 | -7 -7 |
@@ -140,9 +160,13 @@ ghi | |||
140 | -7 | 160 | -7 |
141 | 7 | 161 | 7 |
142 | 7 | 162 | 7 |
163 | -7 -7 | ||
164 | -7 -7 | ||
165 | 7 7 | ||
166 | 7 7 | ||
143 | 8 12 | 167 | 8 12 |
144 | ./arith.tests: line 290: arithmetic syntax error | 168 | ./arith.tests: line 289: arithmetic syntax error |
145 | 42 | 169 | 42 |
146 | 42 | 170 | 42 |
147 | 42 | 171 | 42 |
148 | ./arith.tests: line 302: a[b[c]d]=e: not found | 172 | ./arith.tests: line 301: a[b[c]d]=e: not found |
diff --git a/shell/ash_test/ash-arith/arith.tests b/shell/ash_test/ash-arith/arith.tests index 746ccab71..b9cb8ba4c 100755 --- a/shell/ash_test/ash-arith/arith.tests +++ b/shell/ash_test/ash-arith/arith.tests | |||
@@ -75,11 +75,11 @@ echo 4 $(( iv &= 4 )) | |||
75 | echo 29 $(( iv += (jv + 9))) | 75 | echo 29 $(( iv += (jv + 9))) |
76 | echo 5 $(( (iv + 4) % 7 )) | 76 | echo 5 $(( (iv + 4) % 7 )) |
77 | 77 | ||
78 | # unary plus, minus | 78 | echo unary plus, minus |
79 | echo -4 $(( +4 - 8 )) | 79 | echo -4 $(( +4 - 8 )) |
80 | echo 4 $(( -4 + 8 )) | 80 | echo 4 $(( -4 + 8 )) |
81 | 81 | ||
82 | # conditional expressions | 82 | echo conditional expressions |
83 | echo 1 $(( 4<5 ? 1 : 32)) | 83 | echo 1 $(( 4<5 ? 1 : 32)) |
84 | echo 32 $(( 4>5 ? 1 : 32)) | 84 | echo 32 $(( 4>5 ? 1 : 32)) |
85 | echo 32 $(( 4>(2+3) ? 1 : 32)) | 85 | echo 32 $(( 4>(2+3) ? 1 : 32)) |
@@ -87,8 +87,7 @@ echo 1 $(( 4<(2+3) ? 1 : 32)) | |||
87 | echo 1 $(( (2+2)<(2+3) ? 1 : 32)) | 87 | echo 1 $(( (2+2)<(2+3) ? 1 : 32)) |
88 | echo 32 $(( (2+2)>(2+3) ? 1 : 32)) | 88 | echo 32 $(( (2+2)>(2+3) ? 1 : 32)) |
89 | 89 | ||
90 | # check that the unevaluated part of the ternary operator does not do | 90 | echo check that the unevaluated part of the ternary operator does not do evaluation or assignment |
91 | # evaluation or assignment | ||
92 | x=i+=2 | 91 | x=i+=2 |
93 | y=j+=2 | 92 | y=j+=2 |
94 | #ash# declare -i i=1 j=1 | 93 | #ash# declare -i i=1 j=1 |
@@ -109,20 +108,20 @@ echo 20 $((1 ? 20 : (x+=2))) | |||
109 | echo 30 $((0 ? (y+=2) : 30)) | 108 | echo 30 $((0 ? (y+=2) : 30)) |
110 | #ash# echo $i,$y # ash mishandles this | 109 | #ash# echo $i,$y # ash mishandles this |
111 | 110 | ||
112 | # check precedence of assignment vs. conditional operator | 111 | echo check precedence of assignment vs. conditional operator |
113 | # should be an error | 112 | # should be an error |
114 | #ash# declare -i x=2 | 113 | #ash# declare -i x=2 |
115 | x=2 | 114 | x=2 |
116 | #ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash: | 115 | #ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash: |
117 | ( y=$((1 ? 20 : x+=2)) ) | 116 | ( y=$((1 ? 20 : x+=2)) ) |
118 | 117 | ||
119 | # check precedence of assignment vs. conditional operator | 118 | echo check precedence of assignment vs. conditional operator |
120 | #ash# declare -i x=2 | 119 | #ash# declare -i x=2 |
121 | x=2 | 120 | x=2 |
122 | # ash says "line NNN: syntax error: 0 ? x+=2 : 20" | 121 | # ash says "line NNN: syntax error: 0 ? x+=2 : 20" |
123 | #ash# echo 20 $((0 ? x+=2 : 20)) | 122 | #ash# echo 20 $((0 ? x+=2 : 20)) |
124 | 123 | ||
125 | # associativity of assignment-operator operator | 124 | echo associativity of assignment-operator operator |
126 | #ash# declare -i i=1 j=2 k=3 | 125 | #ash# declare -i i=1 j=2 k=3 |
127 | i=1 | 126 | i=1 |
128 | j=2 | 127 | j=2 |
@@ -130,7 +129,7 @@ k=3 | |||
130 | echo 6 $((i += j += k)) | 129 | echo 6 $((i += j += k)) |
131 | echo 6,5,3 $i,$j,$k | 130 | echo 6,5,3 $i,$j,$k |
132 | 131 | ||
133 | # octal, hex | 132 | echo octal, hex |
134 | echo 263 $(( 0x100 | 007 )) | 133 | echo 263 $(( 0x100 | 007 )) |
135 | echo 255 $(( 0xff )) | 134 | echo 255 $(( 0xff )) |
136 | #ash# echo 255 $(( 16#ff )) | 135 | #ash# echo 255 $(( 16#ff )) |
@@ -139,25 +138,25 @@ echo 255 $(( 0xff )) | |||
139 | 138 | ||
140 | echo 40 $(( 8 ^ 32 )) | 139 | echo 40 $(( 8 ^ 32 )) |
141 | 140 | ||
142 | #ash# # other bases | 141 | echo other bases |
143 | #ash# echo 10 $(( 16#a )) | 142 | echo 10 $(( 16#a )) |
144 | #ash# echo 10 $(( 32#a )) | 143 | echo 10 $(( 32#a )) |
145 | #ash# echo 10 $(( 56#a )) | 144 | echo 10 $(( 56#a )) |
146 | #ash# echo 10 $(( 64#a )) | 145 | echo 10 $(( 64#a )) |
147 | #ash# | 146 | |
148 | #ash# echo 10 $(( 16#A )) | 147 | echo 10 $(( 16#A )) |
149 | #ash# echo 10 $(( 32#A )) | 148 | echo 10 $(( 32#A )) |
150 | #ash# echo 36 $(( 56#A )) | 149 | echo 36 $(( 56#A )) |
151 | #ash# echo 36 $(( 64#A )) | 150 | echo 36 $(( 64#A )) |
152 | #ash# | 151 | |
153 | #ash# echo 62 $(( 64#@ )) | 152 | echo 62 $(( 64#@ )) |
154 | #ash# echo 63 $(( 64#_ )) | 153 | echo 63 $(( 64#_ )) |
155 | 154 | ||
156 | #ash# # weird bases (error) | 155 | #ash# # weird bases (error) |
157 | #ash# echo $(( 3425#56 )) | 156 | #ash# echo $(( 3425#56 )) |
158 | 157 | ||
159 | #ash# # missing number after base | 158 | echo missing number after base |
160 | #ash# echo 0 $(( 2# )) | 159 | echo 0 $(( 2# )) |
161 | 160 | ||
162 | # these should generate errors | 161 | # these should generate errors |
163 | ( echo $(( 7 = 43 )) ) | 162 | ( echo $(( 7 = 43 )) ) |
diff --git a/shell/ash_test/ash-arith/arith2.sub b/shell/ash_test/ash-arith/arith2.sub index 29f9471d6..8d7918114 100755 --- a/shell/ash_test/ash-arith/arith2.sub +++ b/shell/ash_test/ash-arith/arith2.sub | |||
@@ -46,12 +46,8 @@ echo $(( ---7 )) | |||
46 | echo $(( ++7 )) | 46 | echo $(( ++7 )) |
47 | ( echo $(( ++ + 7 )) ) | 47 | ( echo $(( ++ + 7 )) ) |
48 | 48 | ||
49 | # bash 3.2: -7 | 49 | echo -7 $(( ++-7 )) |
50 | #ash# echo -7 $(( ++-7 )) | 50 | echo -7 $(( ++ - 7 )) |
51 | # bash 3.2: -7 | 51 | |
52 | #ash# echo -7 $(( ++ - 7 )) | 52 | echo 7 $(( +--7 )) |
53 | 53 | echo 7 $(( -- + 7 )) | |
54 | # bash 3.2: 7 | ||
55 | #ash# echo 7 $(( +--7 )) | ||
56 | # bash 3.2: 7 | ||
57 | #ash# echo 7 $(( -- + 7 )) | ||
diff --git a/shell/hush_test/hush-arith/arith.right b/shell/hush_test/hush-arith/arith.right index 2c389caea..a8612295e 100644 --- a/shell/hush_test/hush-arith/arith.right +++ b/shell/hush_test/hush-arith/arith.right | |||
@@ -70,6 +70,19 @@ octal, hex | |||
70 | 263 263 | 70 | 263 263 |
71 | 255 255 | 71 | 255 255 |
72 | 40 40 | 72 | 40 40 |
73 | other bases | ||
74 | 10 10 | ||
75 | 10 10 | ||
76 | 10 10 | ||
77 | 10 10 | ||
78 | 10 10 | ||
79 | 10 10 | ||
80 | 36 36 | ||
81 | 36 36 | ||
82 | 62 62 | ||
83 | 63 63 | ||
84 | missing number after base | ||
85 | 0 0 | ||
73 | hush: arithmetic syntax error | 86 | hush: arithmetic syntax error |
74 | hush: divide by zero | 87 | hush: divide by zero |
75 | hush: can't execute 'let': No such file or directory | 88 | hush: can't execute 'let': No such file or directory |
@@ -149,6 +162,10 @@ hush: arithmetic syntax error | |||
149 | -7 | 162 | -7 |
150 | 7 | 163 | 7 |
151 | 7 | 164 | 7 |
165 | -7 -7 | ||
166 | -7 -7 | ||
167 | 7 7 | ||
168 | 7 7 | ||
152 | 8 12 | 169 | 8 12 |
153 | hush: arithmetic syntax error | 170 | hush: arithmetic syntax error |
154 | 42 | 171 | 42 |
diff --git a/shell/hush_test/hush-arith/arith.tests b/shell/hush_test/hush-arith/arith.tests index a7aded17d..6b707486c 100755 --- a/shell/hush_test/hush-arith/arith.tests +++ b/shell/hush_test/hush-arith/arith.tests | |||
@@ -142,25 +142,25 @@ echo 255 $(( 0xff )) | |||
142 | 142 | ||
143 | echo 40 $(( 8 ^ 32 )) | 143 | echo 40 $(( 8 ^ 32 )) |
144 | 144 | ||
145 | #ash# # other bases | 145 | echo other bases |
146 | #ash# echo 10 $(( 16#a )) | 146 | echo 10 $(( 16#a )) |
147 | #ash# echo 10 $(( 32#a )) | 147 | echo 10 $(( 32#a )) |
148 | #ash# echo 10 $(( 56#a )) | 148 | echo 10 $(( 56#a )) |
149 | #ash# echo 10 $(( 64#a )) | 149 | echo 10 $(( 64#a )) |
150 | #ash# | 150 | |
151 | #ash# echo 10 $(( 16#A )) | 151 | echo 10 $(( 16#A )) |
152 | #ash# echo 10 $(( 32#A )) | 152 | echo 10 $(( 32#A )) |
153 | #ash# echo 36 $(( 56#A )) | 153 | echo 36 $(( 56#A )) |
154 | #ash# echo 36 $(( 64#A )) | 154 | echo 36 $(( 64#A )) |
155 | #ash# | 155 | |
156 | #ash# echo 62 $(( 64#@ )) | 156 | echo 62 $(( 64#@ )) |
157 | #ash# echo 63 $(( 64#_ )) | 157 | echo 63 $(( 64#_ )) |
158 | 158 | ||
159 | #ash# # weird bases (error) | 159 | #ash# # weird bases (error) |
160 | #ash# echo $(( 3425#56 )) | 160 | #ash# echo $(( 3425#56 )) |
161 | 161 | ||
162 | #ash# # missing number after base | 162 | echo missing number after base |
163 | #ash# echo 0 $(( 2# )) | 163 | echo 0 $(( 2# )) |
164 | 164 | ||
165 | # these should generate errors | 165 | # these should generate errors |
166 | ( echo $(( 7 = 43 )) ) | 166 | ( echo $(( 7 = 43 )) ) |
diff --git a/shell/hush_test/hush-arith/arith2.sub b/shell/hush_test/hush-arith/arith2.sub index 29f9471d6..8d7918114 100755 --- a/shell/hush_test/hush-arith/arith2.sub +++ b/shell/hush_test/hush-arith/arith2.sub | |||
@@ -46,12 +46,8 @@ echo $(( ---7 )) | |||
46 | echo $(( ++7 )) | 46 | echo $(( ++7 )) |
47 | ( echo $(( ++ + 7 )) ) | 47 | ( echo $(( ++ + 7 )) ) |
48 | 48 | ||
49 | # bash 3.2: -7 | 49 | echo -7 $(( ++-7 )) |
50 | #ash# echo -7 $(( ++-7 )) | 50 | echo -7 $(( ++ - 7 )) |
51 | # bash 3.2: -7 | 51 | |
52 | #ash# echo -7 $(( ++ - 7 )) | 52 | echo 7 $(( +--7 )) |
53 | 53 | echo 7 $(( -- + 7 )) | |
54 | # bash 3.2: 7 | ||
55 | #ash# echo 7 $(( +--7 )) | ||
56 | # bash 3.2: 7 | ||
57 | #ash# echo 7 $(( -- + 7 )) | ||