Skip to content

Deliverable #5

Paradox2100 edited this page Nov 23, 2015 · 1 revision

Deliverable #5

###Team Silver Bullets

For this deliverable, our team injected five different faults into the code, one for each of the five methods we tested.

add(x,y)

Pre-faults Post-faults For the add(x,y) method, we added a fault to return the absolute value of the addition results. This not only made the expected negative results positive, it also ended up converting the value to contain a floating point! This was unforeseen, and caused other tests to fail that we expected to pass.

Changes :

#fault inserted: added abs method to return value

return abs(x + y)

sub(x,y)

Pre-faults Post-faults We removed the if statement that would convert values to decimals.

Changes :

#fault inserted: took away if statement so it would not convert values to decimals.

#if isinstance(x, _Decimal) or isinstance(y, _Decimal):

# x = _d(x)

# y = _d(y)

return x - y

mul(x,y)

Pre-faults Post-faults For this method, we indented the return statement to be included in an if statement. The if statement checks if either number is a decimal. Indenting it causes Python to return nothing when the method is called, if the if statement isn’t checked.

Changes :

if isinstance(x, _Decimal) or isinstance(y, _Decimal):

`x = _d(x)`

`y = _d(y)`

`#fault inserted: indented return statement.`

`return x * y`

div(x,y)

Pre-faults Post-faults We changed the clause to check for is ‘y’ is a 0 to check if ‘x’ is a 0. This causes the test to return an incorrect result when attempting to divide by zero. In test 16, we expect a ValueError, however they have a clause in there that returns ‘x’ if the ‘y’ is a 0. In test 17, a ValueError is thrown, since that is the result when it checks to see if the ‘x’ value is 0.

Changes :

if x == 0 or x == 0.0:#fault insert changed y to x

mod(x,y)

Pre-faults Post-faults For the mod function, we removed the clause that checks if ‘y’ is an integer. This allows us to mod by decimal numbers, which the program wasn’t allowing us to do before. While this is added functionality, it is still technically a fault from what we expected the program to return.

Changes:

#if is_int(y):

return x % y

#else:

`#raise ValueError(_('Can only calculate x modulo <integer>'))`
Clone this wiki locally