diff options
Diffstat (limited to 'shell/ash_test/ash-arith/arith.tests')
-rwxr-xr-x | shell/ash_test/ash-arith/arith.tests | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/shell/ash_test/ash-arith/arith.tests b/shell/ash_test/ash-arith/arith.tests index 746ccab..b9cb8ba 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 )) echo 29 $(( iv += (jv + 9))) echo 5 $(( (iv + 4) % 7 )) -# unary plus, minus +echo unary plus, minus echo -4 $(( +4 - 8 )) echo 4 $(( -4 + 8 )) -# conditional expressions +echo conditional expressions echo 1 $(( 4<5 ? 1 : 32)) echo 32 $(( 4>5 ? 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 32 $(( (2+2)>(2+3) ? 1 : 32)) -# check that the unevaluated part of the ternary operator does not do -# evaluation or assignment +echo check that the unevaluated part of the ternary operator does not do evaluation or assignment x=i+=2 y=j+=2 #ash# declare -i i=1 j=1 @@ -109,20 +108,20 @@ echo 20 $((1 ? 20 : (x+=2))) echo 30 $((0 ? (y+=2) : 30)) #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 #ash# declare -i x=2 x=2 #ashnote# bash reports error but continues, ash aborts - using subshell to 'emulate' bash: ( 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 x=2 # ash says "line NNN: syntax error: 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 i=1 j=2 @@ -130,7 +129,7 @@ k=3 echo 6 $((i += j += k)) echo 6,5,3 $i,$j,$k -# octal, hex +echo octal, hex echo 263 $(( 0x100 | 007 )) echo 255 $(( 0xff )) #ash# echo 255 $(( 16#ff )) @@ -139,25 +138,25 @@ echo 255 $(( 0xff )) echo 40 $(( 8 ^ 32 )) -#ash# # other bases -#ash# echo 10 $(( 16#a )) -#ash# echo 10 $(( 32#a )) -#ash# echo 10 $(( 56#a )) -#ash# echo 10 $(( 64#a )) -#ash# -#ash# echo 10 $(( 16#A )) -#ash# echo 10 $(( 32#A )) -#ash# echo 36 $(( 56#A )) -#ash# echo 36 $(( 64#A )) -#ash# -#ash# echo 62 $(( 64#@ )) -#ash# echo 63 $(( 64#_ )) +echo other bases +echo 10 $(( 16#a )) +echo 10 $(( 32#a )) +echo 10 $(( 56#a )) +echo 10 $(( 64#a )) + +echo 10 $(( 16#A )) +echo 10 $(( 32#A )) +echo 36 $(( 56#A )) +echo 36 $(( 64#A )) + +echo 62 $(( 64#@ )) +echo 63 $(( 64#_ )) #ash# # weird bases (error) #ash# echo $(( 3425#56 )) -#ash# # missing number after base -#ash# echo 0 $(( 2# )) +echo missing number after base +echo 0 $(( 2# )) # these should generate errors ( echo $(( 7 = 43 )) ) |