Saint Louis University |
Computer Science 1300
|
Dept. of Math & Computer Science |
Topic: Good Software Practices
Related Reading: Chapter 7
Due:
11:00am, Monday, 3 April 2017
ELECTRONICALLY
Please make sure you adhere to the policies on academic integrity.
Exercise 7.5 of the text
Please do this problem electronically. You should be able to see the effect of your documentation by doing help(Point) in the interpreter after loading the definitions.
The original undocumented code can be found here (or as hopper:/public/goldwasser/1300/book/ch06/RobustPoint.py)
Create a file TestFraction.py that uses Python's unittest framework to test the correctness of the book's Fraction class implementation. The original untested code, together with embedded gcd function, can be found here (or piecewise within hopper:/public/goldwasser/1300/book/ch06/).
We will get you started by providing a test for the reduction of fractions within the constructor, and for the additional of fractions (download our TestFraction.py). We would like you to develop a rich set of tests for the following additional behaviors:
Although unintentional, this is a particularly relevant exercise given that the version of Fraction published in the book is flawed! The provision of __eq__ and __lt__ does not suffice for supporting all of the expected comparison operators: <, <=, > >=, ==, !=. Your tests should expose those flaws.
Exercise 7.9 of the text