]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/arith3.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / arith3.sub
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 #
14 # this depends on the sequence of random numbers from the internal LCRNG
15 RANDOM=42
16 (( dice[RANDOM%6+1 + RANDOM%6+1]++ ))
17 echo ${dice[6]}
18
19 (( ++dice[RANDOM%6+1 + RANDOM%6+1] ))
20 echo ${dice[7]}
21
22 v=4
23 DIND=20
24
25 (( dice[DIND%6 + 1]=v ))
26 echo ${dice[3]}
27 (( dice[DIND/v]+=2 ))
28
29 RANDOM=42
30
31 (( dice[RANDOM%6+1 + RANDOM%6+1]+=v ))
32 echo ${dice[6]}
33
34 (( dice[RANDOM%6+1 + RANDOM%6+1]-=v ))
35 echo ${dice[7]}
36
37 (( dice[RANDOM%6+1 + RANDOM%6+1]+=2 ))
38 echo ${dice[8]}
39
40 (( dice[RANDOM%6+1 + RANDOM%6+1]*=2 ))
41 echo ${dice[5]}
42
43 unset dice1 dice2
44 RANDOM=42
45
46 for i in {1..5000}; do ((dice1[$RANDOM%6+1 + $RANDOM%6+1]++)); done;
47 unset t; for i in ${dice1[@]}; do ((t+=i)); done; echo $t
48
49 foo="${dice1[@]}"
50
51 RANDOM=42
52
53 for i in {1..5000}; do ((dice2[RANDOM%6+1 + RANDOM%6+1]++)); done;
54 unset t; for i in ${dice2[@]}; do ((t+=i)); done; echo $t
55
56 bar="${dice2[@]}"
57
58 if [ "$foo" != "$bar" ]; then
59 echo "random sequences differ"
60 fi