mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-19 12:31:56 +00:00
319 lines
8.8 KiB
Plaintext
319 lines
8.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
|
||
# 13th Test Tru OR Fal OR Fal
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] OR [ 99 -EQ 79 ] OR [ "A" = "b" ]
|
||
Echo " Test 13 Tr OR Fa OR Fa : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 13 Tr OR Fa OR Fa : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 13 Tr OR Fa OR Fa : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 13 Tr OR Fa OR Fa : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 14th Test Fal OR Tru OR Fal
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] OR [ 99 -EQ 99 ] OR [ "A" = "b" ]
|
||
Echo " Test 14 Fa OR Tr OR Fa : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 14 Fa OR Tr OR Fa : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 14 Fa OR Tr OR Fa : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 14 Fa OR Tr OR Fa : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 15th Test Fal OR Fal OR Tru
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] OR [ "A" = "b" ] OR [ 99 -EQ 99 ]
|
||
Echo " Test 15 Fa OR Fa OR Tr : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 15 Fa OR Fa OR Tr : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 15 Fa OR Fa OR Tr : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 15 Fa OR Fa OR Tr : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 16th Test Fal OR Fal OR Fal
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] OR [ "A" = "b" ] OR [ 99 -LT 79 ]
|
||
Echo " Test 16 Fa OR Fa OR Fa : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 12 Fa OR Fa OR Fa : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 16 Fa OR Fa OR Fa : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 16 Fa OR Fa OR Fa : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 17th Test Fal OR Tru AND Tru
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] OR [ "A" = "A" ] AND [ 99 -EQ 99 ]
|
||
Echo " Test 17 Fa OR Tr AND Tr : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 17 Fa OR Tr AND Tr : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 17 Fa OR Tr AND Tr : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 17 Fa OR Tr AND Tr : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
# 18th Test Fal OR Tru AND Fal
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 79 ] OR [ "A" = "A" ] AND [ 99 -LT 79 ]
|
||
Echo " Test 18 Fa OR Tr AND Fa : True : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 18 Fa OR Tr AND Fa : True : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 18 Fa OR Tr AND Fa : False : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 18 Fa OR Tr AND Fa : False : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
FI
|
||
# 19th Test Tru OR Tru AND Fal
|
||
SET T = $T + 1
|
||
IF [ 99 -EQ 99 ] OR [ "A" = "A" ] AND [ 79 -EQ 99 ]
|
||
Echo " Test 19 Tr OR Tr AND Fa : True : PASSED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 19 Tr OR Tr AND Fa : True : PASSED" >> ${Log}
|
||
SET P = $P + 1
|
||
FI
|
||
ELSE
|
||
Echo " Test 19 Tr OR Tr AND Fa : False : FAILED"
|
||
IF [ -N $Log ]
|
||
ECHO "Test 19 Tr OR Tr AND Fa : False : FAILED" >> ${Log}
|
||
SET F = $F + 1
|
||
FI
|
||
FI
|
||
SET A = 123
|
||
SET B = 456
|
||
SET C = "ABC"
|
||
SET D = "DEF"
|
||
SET E = "MNO"
|
||
SET F = "XYZ"
|
||
IF [ $A -lt 100 ] && [ $B -eq 456 ] || [ $C = "ABC" ] && [ $D = "GHI ]
|
||
ECHO HI
|
||
ELSE
|
||
ECHO BYE
|
||
FI # True - HI
|
||
|
||
MAN
|
||
TEXT /MAKE/USR/SHARE/TESTS/IFANDORTEST
|