shell: enable more tests which are passing now

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2021-09-25 22:25:19 +02:00
parent d84a604830
commit 62e433131b
6 changed files with 103 additions and 71 deletions

View File

@ -43,40 +43,60 @@ Format: 'expected actual'
4 4 4 4
29 29 29 29
5 5 5 5
unary plus, minus
-4 -4 -4 -4
4 4 4 4
conditional expressions
1 1 1 1
32 32 32 32
32 32 32 32
1 1 1 1
1 1 1 1
32 32 32 32
check that the unevaluated part of the ternary operator does not do evaluation or assignment
20 20 20 20
30 30 30 30
20 20 20 20
30 30 30 30
./arith.tests: line 117: arithmetic syntax error check precedence of assignment vs. conditional operator
./arith.tests: line 116: arithmetic syntax error
check precedence of assignment vs. conditional operator
associativity of assignment-operator operator
6 6 6 6
6,5,3 6,5,3 6,5,3 6,5,3
octal, hex
263 263 263 263
255 255 255 255
40 40 40 40
./arith.tests: line 163: arithmetic syntax error other bases
./arith.tests: line 165: divide by zero 10 10
./arith.tests: let: line 166: arithmetic syntax error 10 10
./arith.tests: line 167: arithmetic syntax error 10 10
./arith.tests: let: line 168: arithmetic syntax error 10 10
10 10
10 10
36 36
36 36
62 62
63 63
missing number after base
0 0
./arith.tests: line 162: arithmetic syntax error
./arith.tests: line 164: divide by zero
./arith.tests: let: line 165: arithmetic syntax error
./arith.tests: line 166: arithmetic syntax error
./arith.tests: let: line 167: arithmetic syntax error
abc abc
def def
ghi ghi
./arith.tests: line 191: arithmetic syntax error ./arith.tests: line 190: arithmetic syntax error
16 16 16 16
./arith.tests: line 196: arithmetic syntax error ./arith.tests: line 195: arithmetic syntax error
./arith.tests: line 197: malformed ?: operator ./arith.tests: line 196: malformed ?: operator
./arith.tests: line 198: arithmetic syntax error ./arith.tests: line 197: arithmetic syntax error
9 9 9 9
./arith.tests: line 205: arithmetic syntax error ./arith.tests: line 204: arithmetic syntax error
./arith.tests: line 208: arithmetic syntax error ./arith.tests: line 207: arithmetic syntax error
9 9 9 9
9 9 9 9
9 9 9 9
@ -98,11 +118,11 @@ ghi
4 4 4 4
4 4 4 4
7 7 7 7
./arith.tests: line 257: arithmetic syntax error ./arith.tests: line 256: arithmetic syntax error
./arith.tests: line 258: arithmetic syntax error
./arith.tests: line 259: arithmetic syntax error ./arith.tests: line 259: arithmetic syntax error
./arith.tests: line 260: arithmetic syntax error ./arith.tests: line 261: arithmetic syntax error
./arith.tests: line 262: arithmetic syntax error ./arith.tests: line 262: arithmetic syntax error
./arith.tests: line 263: arithmetic syntax error
4 4 4 4
7 7 7 7
-7 -7 -7 -7
@ -140,9 +160,13 @@ ghi
-7 -7
7 7
7 7
-7 -7
-7 -7
7 7
7 7
8 12 8 12
./arith.tests: line 290: arithmetic syntax error ./arith.tests: line 289: arithmetic syntax error
42 42
42 42
42 42
./arith.tests: line 302: a[b[c]d]=e: not found ./arith.tests: line 301: a[b[c]d]=e: not found

View File

@ -75,11 +75,11 @@ echo 4 $(( iv &= 4 ))
echo 29 $(( iv += (jv + 9))) echo 29 $(( iv += (jv + 9)))
echo 5 $(( (iv + 4) % 7 )) echo 5 $(( (iv + 4) % 7 ))
# unary plus, minus echo unary plus, minus
echo -4 $(( +4 - 8 )) echo -4 $(( +4 - 8 ))
echo 4 $(( -4 + 8 )) echo 4 $(( -4 + 8 ))
# conditional expressions echo conditional expressions
echo 1 $(( 4<5 ? 1 : 32)) echo 1 $(( 4<5 ? 1 : 32))
echo 32 $(( 4>5 ? 1 : 32)) echo 32 $(( 4>5 ? 1 : 32))
echo 32 $(( 4>(2+3) ? 1 : 32)) echo 32 $(( 4>(2+3) ? 1 : 32))
@ -87,8 +87,7 @@ echo 1 $(( 4<(2+3) ? 1 : 32))
echo 1 $(( (2+2)<(2+3) ? 1 : 32)) echo 1 $(( (2+2)<(2+3) ? 1 : 32))
echo 32 $(( (2+2)>(2+3) ? 1 : 32)) echo 32 $(( (2+2)>(2+3) ? 1 : 32))
# check that the unevaluated part of the ternary operator does not do echo check that the unevaluated part of the ternary operator does not do evaluation or assignment
# evaluation or assignment
x=i+=2 x=i+=2
y=j+=2 y=j+=2
#ash# declare -i i=1 j=1 #ash# declare -i i=1 j=1
@ -109,20 +108,20 @@ echo 20 $((1 ? 20 : (x+=2)))
echo 30 $((0 ? (y+=2) : 30)) echo 30 $((0 ? (y+=2) : 30))
#ash# echo $i,$y # ash mishandles this #ash# echo $i,$y # ash mishandles this
# check precedence of assignment vs. conditional operator echo check precedence of assignment vs. conditional operator
# should be an error # should be an error
#ash# declare -i x=2 #ash# declare -i x=2
x=2 x=2
#ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash: #ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash:
( y=$((1 ? 20 : x+=2)) ) ( y=$((1 ? 20 : x+=2)) )
# check precedence of assignment vs. conditional operator echo check precedence of assignment vs. conditional operator
#ash# declare -i x=2 #ash# declare -i x=2
x=2 x=2
# ash says "line NNN: syntax error: 0 ? x+=2 : 20" # ash says "line NNN: syntax error: 0 ? x+=2 : 20"
#ash# echo 20 $((0 ? x+=2 : 20)) #ash# echo 20 $((0 ? x+=2 : 20))
# associativity of assignment-operator operator echo associativity of assignment-operator operator
#ash# declare -i i=1 j=2 k=3 #ash# declare -i i=1 j=2 k=3
i=1 i=1
j=2 j=2
@ -130,7 +129,7 @@ k=3
echo 6 $((i += j += k)) echo 6 $((i += j += k))
echo 6,5,3 $i,$j,$k echo 6,5,3 $i,$j,$k
# octal, hex echo octal, hex
echo 263 $(( 0x100 | 007 )) echo 263 $(( 0x100 | 007 ))
echo 255 $(( 0xff )) echo 255 $(( 0xff ))
#ash# echo 255 $(( 16#ff )) #ash# echo 255 $(( 16#ff ))
@ -139,25 +138,25 @@ echo 255 $(( 0xff ))
echo 40 $(( 8 ^ 32 )) echo 40 $(( 8 ^ 32 ))
#ash# # other bases echo other bases
#ash# echo 10 $(( 16#a )) echo 10 $(( 16#a ))
#ash# echo 10 $(( 32#a )) echo 10 $(( 32#a ))
#ash# echo 10 $(( 56#a )) echo 10 $(( 56#a ))
#ash# echo 10 $(( 64#a )) echo 10 $(( 64#a ))
#ash#
#ash# echo 10 $(( 16#A )) echo 10 $(( 16#A ))
#ash# echo 10 $(( 32#A )) echo 10 $(( 32#A ))
#ash# echo 36 $(( 56#A )) echo 36 $(( 56#A ))
#ash# echo 36 $(( 64#A )) echo 36 $(( 64#A ))
#ash#
#ash# echo 62 $(( 64#@ )) echo 62 $(( 64#@ ))
#ash# echo 63 $(( 64#_ )) echo 63 $(( 64#_ ))
#ash# # weird bases (error) #ash# # weird bases (error)
#ash# echo $(( 3425#56 )) #ash# echo $(( 3425#56 ))
#ash# # missing number after base echo missing number after base
#ash# echo 0 $(( 2# )) echo 0 $(( 2# ))
# these should generate errors # these should generate errors
( echo $(( 7 = 43 )) ) ( echo $(( 7 = 43 )) )

View File

@ -46,12 +46,8 @@ echo $(( ---7 ))
echo $(( ++7 )) echo $(( ++7 ))
( echo $(( ++ + 7 )) ) ( echo $(( ++ + 7 )) )
# bash 3.2: -7 echo -7 $(( ++-7 ))
#ash# echo -7 $(( ++-7 )) echo -7 $(( ++ - 7 ))
# bash 3.2: -7
#ash# echo -7 $(( ++ - 7 ))
# bash 3.2: 7 echo 7 $(( +--7 ))
#ash# echo 7 $(( +--7 )) echo 7 $(( -- + 7 ))
# bash 3.2: 7
#ash# echo 7 $(( -- + 7 ))

View File

@ -70,6 +70,19 @@ octal, hex
263 263 263 263
255 255 255 255
40 40 40 40
other bases
10 10
10 10
10 10
10 10
10 10
10 10
36 36
36 36
62 62
63 63
missing number after base
0 0
hush: arithmetic syntax error hush: arithmetic syntax error
hush: divide by zero hush: divide by zero
hush: can't execute 'let': No such file or directory hush: can't execute 'let': No such file or directory
@ -149,6 +162,10 @@ hush: arithmetic syntax error
-7 -7
7 7
7 7
-7 -7
-7 -7
7 7
7 7
8 12 8 12
hush: arithmetic syntax error hush: arithmetic syntax error
42 42

View File

@ -142,25 +142,25 @@ echo 255 $(( 0xff ))
echo 40 $(( 8 ^ 32 )) echo 40 $(( 8 ^ 32 ))
#ash# # other bases echo other bases
#ash# echo 10 $(( 16#a )) echo 10 $(( 16#a ))
#ash# echo 10 $(( 32#a )) echo 10 $(( 32#a ))
#ash# echo 10 $(( 56#a )) echo 10 $(( 56#a ))
#ash# echo 10 $(( 64#a )) echo 10 $(( 64#a ))
#ash#
#ash# echo 10 $(( 16#A )) echo 10 $(( 16#A ))
#ash# echo 10 $(( 32#A )) echo 10 $(( 32#A ))
#ash# echo 36 $(( 56#A )) echo 36 $(( 56#A ))
#ash# echo 36 $(( 64#A )) echo 36 $(( 64#A ))
#ash#
#ash# echo 62 $(( 64#@ )) echo 62 $(( 64#@ ))
#ash# echo 63 $(( 64#_ )) echo 63 $(( 64#_ ))
#ash# # weird bases (error) #ash# # weird bases (error)
#ash# echo $(( 3425#56 )) #ash# echo $(( 3425#56 ))
#ash# # missing number after base echo missing number after base
#ash# echo 0 $(( 2# )) echo 0 $(( 2# ))
# these should generate errors # these should generate errors
( echo $(( 7 = 43 )) ) ( echo $(( 7 = 43 )) )

View File

@ -46,12 +46,8 @@ echo $(( ---7 ))
echo $(( ++7 )) echo $(( ++7 ))
( echo $(( ++ + 7 )) ) ( echo $(( ++ + 7 )) )
# bash 3.2: -7 echo -7 $(( ++-7 ))
#ash# echo -7 $(( ++-7 )) echo -7 $(( ++ - 7 ))
# bash 3.2: -7
#ash# echo -7 $(( ++ - 7 ))
# bash 3.2: 7 echo 7 $(( +--7 ))
#ash# echo 7 $(( +--7 )) echo 7 $(( -- + 7 ))
# bash 3.2: 7
#ash# echo 7 $(( -- + 7 ))