TUTORIAL EXERCISE (WEEK 2) QUESTION 1.
GIVEN:
Three Python programs (q1.py, q2.py, q3.py) solving the same
problem.
Three test suites (t1, t2, t3) that tests them.
It is known that q1.py passes all three, q2.py fails all three and q3.py fails t1 and t2 but passes t3.
Three test suites (t1, t2, t3) that tests them.
It is known that q1.py passes all three, q2.py fails all three and q3.py fails t1 and t2 but passes t3.
PREPARATION
(OR THE LET’S PART):
Let’s consider the results of the programs going through the
test suites as a set like so:
program = {t1 results, t2 results, t3 results}
If the result of the test suite with the program is a pass, the element in the set will read Pass; if the result is a fail, the element will read Fail.
Let’s create set A as a constant
set A = {Pass, Pass, Pass}
Let’s say that q1.py = set B, q2.py = set C, q3.py = set D
set B = {Pass, Pass, Pass}
set C = {Fail, Fail, Fail}
set D = {Fail, Fail, Pass}
a) All three python programs pass all three test suites (FALSE)
program = {t1 results, t2 results, t3 results}
If the result of the test suite with the program is a pass, the element in the set will read Pass; if the result is a fail, the element will read Fail.
Let’s create set A as a constant
set A = {Pass, Pass, Pass}
Let’s say that q1.py = set B, q2.py = set C, q3.py = set D
set B = {Pass, Pass, Pass}
set C = {Fail, Fail, Fail}
set D = {Fail, Fail, Pass}
a) All three python programs pass all three test suites (FALSE)
Test q1.py: all({x in A for x in B}). It should return True
because set A = set B.
Test q2.py: all({x in A for x in C}). It should return False because set A ≠ set C.
Test q3.py: all({x in A for x in D}). It should return False because set A ≠ set D.
Test q2.py: all({x in A for x in C}). It should return False because set A ≠ set C.
Test q3.py: all({x in A for x in D}). It should return False because set A ≠ set D.
Since set C and set D violates the conditions and we need all of
them to fit the condition, the statement ∀ x ∈ {B, C, D}, x =
{Pass, Pass, Pass} is FALSE. (i.e look at q2.py & q3.py)
b) Some of the three python programs pass all
three test suites (TRUE)
Test q1.py: all({x in A for x in B}). It should return True because set A = set B.
Test q2.py: all({x in A for x in C}). It should return False because set A ≠ set C.
Test q3.py: all({x in A for x in D}). It should return False because set A ≠ set D.
Test q1.py: all({x in A for x in B}). It should return True because set A = set B.
Test q2.py: all({x in A for x in C}). It should return False because set A ≠ set C.
Test q3.py: all({x in A for x in D}). It should return False because set A ≠ set D.
Since set B fits the conditions and we are only looking for one or
more that fits the conditions, the statement ∃ x ∈
{B, C, D}, x = {Pass, Pass, Pass} is TRUE. (i.e look at q1.py)
c) All three python programs don’t pass all
three test suites (that is, each fails at least one test suite) (FALSE)
Test q1.py: not all({x in A for x in B}). It should return False because set A = set B.
Test q2.py: not all({x in A for x in C}). It should return True because set A ≠ set C.
Test q3.py: not all({x in A for x in D}). It should return True because set A ≠ set D.
Test q1.py: not all({x in A for x in B}). It should return False because set A = set B.
Test q2.py: not all({x in A for x in C}). It should return True because set A ≠ set C.
Test q3.py: not all({x in A for x in D}). It should return True because set A ≠ set D.
Since set B violates the conditions and we need all of them to
fit the conditions, the statement ∀ x ∈ {B, C, D}, x ≠ {Pass, Pass, Pass} is FALSE. (i.e look at
q1.py)
d) Some of
the three python programs don’t pass all three test suites (that is, some fail
at least one test suite) (TRUE)
Test q1.py: not all({x in A for x in B}). It should return False
because set A = set B.
Test q2.py: not all({x in A for x in C}). It should return True because set A ≠ set C.
Test q3.py: not all({x in A for x in D}). It should return True because set A ≠ set D.
Since set C and set D
fit the conditions and we’re only looking for one or more that fits the
conditions, the statement ∃ x ∈ {B, C, D}, x ≠ {Pass, Pass,
Pass} is TRUE. (i.e look at
q2.py & q3.py)
Test q2.py: not all({x in A for x in C}). It should return True because set A ≠ set C.
Test q3.py: not all({x in A for x in D}). It should return True because set A ≠ set D.
No comments:
Post a Comment