""" Exercise 3.6 from "A primer on..." Implement a function so that a given test function passes. In this case the function itself is trivial, but the exercise is an example of test-driven development, where the test is written first and then the function is written to satisfy the test. """ def double(arg): return arg * 2 def test_double(): assert double(2) == 4 assert double(0.1) == 0.2 assert abs(double(0.1) - 0.2) < 1E-15 assert double([1, 2]) == [1, 2, 1, 2] assert double((1, 2)) == (1, 2, 1, 2) assert double(3+4j) == 6+8j assert double('hello') == 'hellohello' test_double()