14.7. ExerciseThe answers for all exercises can be found in Section A.12. 14.7.1. Exercise [60 min]Write a module distribution, starting from the tests first. Your goal is to create a module My::List::Util that exports two routines on request: sum and shuffle. The sum routine takes a list of values and returns the numeric sum. The shuffle routine takes a list of values and randomly shuffles the ordering, returning the list. Start with sum. Write the tests, and then add the code. You'll know you're done when the tests pass. Now include tests for shuffle, and then add the implementation for shuffle. Be sure to update the documentation and MANIFEST file as you go along. If you can pair up with someone on this exercise, even better. One of you writes the test for sum and the implementation code for shuffle, and the other does the opposite. Swap the t/* files, and see if you can locate any errors! Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|