Skip to content

Commit 926367b

Browse files
committed
builds site
1 parent bb47f79 commit 926367b

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

06-edges.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,21 @@ <h2><span class="glyphicon glyphicon-pushpin"></span>Consider the fibonacci sequ
8080
<span class="co"># test internal point</span>
8181
obs = fib(<span class="dv">6</span>)
8282
assert_equal(<span class="dv">13</span>, obs)</code></pre>
83-
<p>Different functions will have different edge cases. Often, you need not test for cases that are outside the valid range, unless you want to test that the function fails. In the <code>fib()</code> function negative and noninteger values are not valid inputs. You do not need to have tests for these classes of numbers, unless you want to make sure that the function fails as expected, which is actually quite a good idea. Edge cases are not where the story ends, though, as we will see next.</p>
83+
<p>Different functions will have different edge cases. Often, you need not test for cases that are outside the valid range, unless you want to test that the function fails. In the <code>fib()</code> function negative and noninteger values are not valid inputs. Tests for these classes of numbers serve you well if you want to make sure that the function fails as expected. Indeed, we learned in the assertions section that this is actually quite a good idea.</p>
84+
<section class="challenge panel panel-success">
85+
<div class="panel-heading">
86+
<h2><span class="glyphicon glyphicon-pencil"></span>Test for Graceful Failure</h2>
87+
</div>
88+
<div class="panel-body">
89+
<p>The <code>fib()</code> function should probably return the Python built-in <code>NotImplemented</code> value for negative and noninteger values.</p>
90+
<ol style="list-style-type: decimal">
91+
<li>Create a file called <code>test_fib.py</code></li>
92+
<li>Copy the three tests above into that file.</li>
93+
<li>Write <strong>two new</strong> tests that check for the expected return value (NotImplemented) in each case (for negative input and noninteger input respectively).</li>
94+
</ol>
95+
</div>
96+
</section>
97+
<p>Edge cases are not where the story ends, though, as we will see next.</p>
8498
<h2 id="corner-cases">Corner Cases</h2>
8599
<p>When two or more edge cases are combined, it is called a <em>corner case</em>. If a function is parametrized by two linear and independent variables, a test that is at the extreme of both variables is in a corner. As a demonstration, consider the case of the function <code>(sin(x) / x) * (sin(y) / y)</code>, presented here:</p>
86100
<pre class="sourceCode python"><code class="sourceCode python"><span class="ch">import</span> numpy <span class="ch">as</span> np

06-edges.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,20 @@ def test_fib6():
8080
Different functions will have different edge cases.
8181
Often, you need not test for cases that are outside the valid range, unless you
8282
want to test that the function fails. In the `fib()` function negative and
83-
noninteger values are
84-
not valid inputs. You do not need to have tests for these classes of numbers,
85-
unless you want to make sure that the function fails as expected, which is
86-
actually quite a good idea. Edge cases are not where the story ends, though,
87-
as we will see next.
83+
noninteger values are not valid inputs. Tests for these classes of numbers serve you well if you want to make sure that the function fails as
84+
expected. Indeed, we learned in the assertions section that this is actually quite a good idea.
85+
86+
> ## Test for Graceful Failure {.challenge}
87+
> The `fib()` function should probably return the Python built-in
88+
> `NotImplemented` value for negative and noninteger values.
89+
>
90+
> 1. Create a file called `test_fib.py`
91+
> 2. Copy the three tests above into that file.
92+
> 3. Write **two new** tests that check for the expected return value
93+
> (NotImplemented) in each case (for negative input and noninteger input
94+
> respectively).
95+
96+
Edge cases are not where the story ends, though, as we will see next.
8897

8998
## Corner Cases
9099

0 commit comments

Comments
 (0)