mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-27 04:49:20 +00:00
214 lines
5.8 KiB
Plaintext
214 lines
5.8 KiB
Plaintext
NEW
|
||
PREFIX
|
||
AUTO 4,1
|
||
#!/BIN/SH
|
||
#
|
||
# This script tests all the variants of the AND and OR Logic in IFs
|
||
#
|
||
ECHO "\f\n\n If AND (AND) OR (OR) Tests"
|
||
ECHO "\n\nThis Performs Several Complex IF logic tests"
|
||
ECHO
|
||
ECHO "Begin IF AND OR Tests"
|
||
ECHO
|
||
IF [ -N $Log ]
|
||
ECHO "Begin IF AND OR Tests" >> ${Log}
|
||
ELSE
|
||
SET T = 0
|
||
SET F = 0
|
||
SET P = 0
|
||
FI
|
||
# First test AND True True
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] AND [ "A" = "A" ]
|
||
Echo " Test 1 AND True True : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 1 AND True True : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 1 AND True True : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 1 AND True True : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 2nd test AND True False
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] AND [ "A" = "b" ]
|
||
Echo " Test 2 AND True False : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 2 AND True False : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 2 AND True False : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 2 AND True False : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 3rd test AND False True
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] AND [ "A" = "A" ]
|
||
Echo " Test 3 AND False True : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 3 AND False True : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 3 AND False True : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 3 AND False True : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 4th test AND False False
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] AND [ "A" = "b" ]
|
||
Echo " Test 4 AND False False : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 4 AND False False : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 4 AND False False : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 4 AND False False : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 5th test OR True True
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] OR [ "A" = "A" ]
|
||
Echo " Test 5 OR True True : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 5 OR True True : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 5 OR True True : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 5 OR True True : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 6th test OR True False
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] OR [ "A" = "b" ]
|
||
Echo " Test 6 OR True False : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 6 OR True False : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 6 OR True False : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 6 OR True False : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 7th test OR False True
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] OR [ "A" = "A" ]
|
||
Echo " Test 7 OR False True : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 7 OR False True : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 7 OR False True : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 7 OR False True : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 8th test OR False False
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] OR [ "A" = "b" ]
|
||
Echo " Test 8 OR False False : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 8 OR False False : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 8 OR False False : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 8 OR False False : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 9th test AND True True True
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] AND [ "A" = "A" ] AND [ 1 -LT 7 ]
|
||
Echo " Test 9 AND Tru Tru Tru : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 9 AND Tru Tru Tru : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 9 AND Tru Tru Tru : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 9 AND Tru Tru Tru : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 10th test AND True True False
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] AND [ "A" = "A" ] AND [ 7 -LT 1 ]
|
||
Echo " Test 10 AND Tru Tru Fal : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 AND Tru Tru Fal : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 10 AND Tru Tru Fal : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 10 AND Tru Tru Fal : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 11th test AND True False False
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] AND [ "A" = "b" ] AND [ 7 -LT 1 ]
|
||
Echo " Test 11 AND Tru Fal Fal : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 11 AND Tru Fal Fal : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 11 AND Tru Fal Fal : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 11 AND Tru Fal Fal : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 12th test AND True False True
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] AND [ "A" = "b" ] AND [ 1 -LT 7 ]
|
||
Echo " Test 12 AND Tru Fal Tru : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 12 AND Tru Fal Tru : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 12 AND Tru Fal Tru : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 12 AND Tru Fal Tru : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
MAN
|
||
TEXT /MAKE/USR/SHARE/TESTS/IFANDORTEST
|
||
|
||
|
||
this tests the IF [] AND [] and IF [] OR []
|
||
|
||
we should test all of --> true true | true false | false true | false false variants
|
||
|
||
|
||
need to write a subs standalone script that I call with . subs
|
||
and then can get rid of with SET -F
|
||
|
||
EXIT, or EXIT <exp>
|
||
EXIT $RC + 1 works
|