mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-03 12:06:05 +00:00
92 lines
2.0 KiB
Plaintext
92 lines
2.0 KiB
Plaintext
NEW
|
||
PREFIX
|
||
AUTO 4,1
|
||
#!/BIN/SH
|
||
#
|
||
# Tests the While Loop function of shell
|
||
#
|
||
echo "\f\n\n WHILE LOOP Tests"
|
||
echo "\n\nThis script tests the WHILE LOOP construct."
|
||
echo "\nThe First tests an incrementing loop adding up the"
|
||
echo "vaues, in this way it demonstrates creating a Fibonachi"
|
||
echo "number maker. Test 2 is a decremental loop and Test 3"
|
||
echo "mixes the two."
|
||
echo
|
||
IF [ -N $Log ]
|
||
ECHO "Begin WHILE LOOP Tests" >> ${Log}
|
||
ELSE
|
||
SET T = 0
|
||
SET F = 0
|
||
SET P = 0
|
||
FI
|
||
set counter = 1
|
||
set total = 0
|
||
while [ $counter -lt 16 ]
|
||
set total = $total + $counter
|
||
ECHO -N "\e[14;10HTest 1 - Counter : ${count} Total : ${total}"
|
||
set counter = $counter + 1
|
||
loop
|
||
IF [ $total -eq 120 ]
|
||
IF [ -N $Log ]
|
||
SET T = $T + 1
|
||
SET P = $P + 1
|
||
ECHO "WHILE LOOP Test 1 Passed" >> ${Log}
|
||
FI
|
||
ELSE
|
||
IF [ -N $Log ]
|
||
SET T = $T + 1
|
||
SET F = $F + 1
|
||
ECHO "WHILE LOOP Test 1 Failed" >> ${Log}
|
||
FI
|
||
FI
|
||
set counter = 100
|
||
set total = 10000
|
||
while [ $counter -gt 90 ]
|
||
set total = $total - $counter
|
||
ECHO -N "\e[16;10HTest 2 - Counter : ${count} Total : ${total}"
|
||
set counter = $counter - 1
|
||
loop
|
||
IF [ $total -eq 9045 ]
|
||
IF [ -N $Log ]
|
||
SET T = $T + 1
|
||
SET P = $P + 1
|
||
ECHO "WHILE LOOP Test 2 Passed" >> ${Log}
|
||
FI
|
||
ELSE
|
||
IF [ -N $Log ]
|
||
SET T = $T + 1
|
||
SET F = $F + 1
|
||
ECHO "WHILE LOOP Test 2 Failed" >> ${Log}
|
||
FI
|
||
FI
|
||
#
|
||
# This next tests uses the NOT variant of the condition block
|
||
#
|
||
set counter = 0
|
||
set total = 2000
|
||
while ![ $total -eq 0 ]
|
||
set total = $total - 100
|
||
set counter = $counter + 1
|
||
ECHO -N "\e[18;10HTest 3 - Counter : ${count} Total : ${total} "
|
||
loop
|
||
IF [ $counter -eq 20 ]
|
||
IF [ -N $Log ]
|
||
SET T = $T + 1
|
||
SET P = $P + 1
|
||
ECHO "WHILE LOOP Test 3 Passed" >> ${Log}
|
||
FI
|
||
ELSE
|
||
IF [ -N $Log ]
|
||
SET T = $T + 1
|
||
SET F = $F + 1
|
||
ECHO "WHILE LOOP Test 3 Failed" >> ${Log}
|
||
FI
|
||
FI
|
||
ECHO
|
||
ECHO
|
||
IF [ -N $Log ]
|
||
ECHO "End WHILE LOOP Tests" >> ${Log}
|
||
FI
|
||
MAN
|
||
TEXT /MAKE/USR/SHARE/TESTS/WHILETEST
|