CSC151.01 2014F, Class 13: Testing Your Procedures, Revisited
=============================================================

_Overview_

* Quiz.
* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Questions.
* Using testing to assess candidate solutions.
* A problem in testing.
* Some strategies for improving your tests.

Preliminaries
-------------

### Admin

* Continue lab partners from Wednesday.
* Sam may be late to class today.  We'll start with the quiz.
* It's Friday.  There's a Harris party this weekend.  Be thoughtful about
  your choices.  And if you choose to drink, please don't drink to excess.
* If you get weird error messages when using DrRacket, please let me
  know what computer you are on.  (Any other context helps, too.)

### Upcoming Work

* No lab writeup.  But please do read through the rest of the testing lab.
* [Exam 1](../assignments/exam.01.html) due next Tuesday night.
    * The prologue is due tonight (optional, but recommended).
    * We will quickly step through the questions.
    * You are already up to 4 points of extra credit.
* Reading for Monday:
    * [Transforming RGB Colors](../readings/transforming-rgb-reading.html)

### Extra Credit Opportunities

#### Academic

* Convocation next Wednesday
* Campus Town Hall September 30
* CS Table next Thursday: Mathematical Image Synthesis Toolkit

#### Peer Support

* Football Games (???)
* Men's Tennis (???)
* Women's Tennis (at a tournament this weekend)
* Noteworthy, Sat., Sept 27, 3:30 p.m. Herrick
* Science poster session, Sat., Sept. 27, morningish
* Anna Christie, Oct. 9-12 (SB plays Marthy)
* Evan's awesome radio show at 5pm on KDIC.
* Donna's equally awesome radio show midnight Sunday (heading into Monday).

#### Miscellaneous

* Participate in #GrinWell.
* Friends of Drake Library needs help setting up for their annual booksale
  on Thursday, October 2 (conveniently, the same night as Grinnell High
  School's homecoming parade).  You can help a good cause and probably get
  a few free books, too.

### Questions

Using testing to assess candidate solutions
-------------------------------------------

* Testing: Apply the scientific method to programs
    * Hypothesis: Our procedure works
    * Experiments: For *these inputs* I expect *these outputs*.
      Write as prototcol, rather than just working "on the fly"
        * Protocol: "test suite"
    * If they all succeed, we have some confidence
    * If any tests fail, we can reject the procedure
* The lab
    * A good test suite can be applied to *any* procedure that has the
      same goals.
    * A good test suite will let you distinguish between correct and
      incorrect solutions.
    * Goal of lab: Write tests that do this distinguishing.

A problem in testing
--------------------

* Write a good test suite for classify-triangle
* A good test suite will tell us which of the implementations is wrong.
* First test: Equilateral triangle.
* Second test: Non-triangle, hope that we get an error.

Our code
--------

    #lang racket
    (require rackunit)
    (require rackunit/text-ui)
    (require triangles/tri-2200)
    
    (define triangle-tests
      (test-suite 
       "Testing classify-triangle"
       (test-case "not quite an isosceles triangle"
              (check-exn exn:fail? (lambda () (classify-triangle 2 2 5))))
       (test-case "not quite scalene"
              (check-exn exn:fail? (lambda () (classify-triangle 80 60 1))))
       (test-case "zero side length"
              (check-exn exn:fail? (lambda () (classify-triangle 0 0 0))))
       (test-case "an isosceles triangle"
              (check-equal? (classify-triangle 2.0 2.0 3.0) "isosceles"))
       (test-case "an isosceles triangle"
              (check-equal? (classify-triangle 2.0 3.0 2.0) "isosceles"))
       (test-case "an isosceles triangle"
              (check-equal? (classify-triangle 3.0 2.0 2.0) "isosceles"))
       (test-case "a really big equilateral triangle"
              (check-equal? (classify-triangle (expt 2 1000) (expt 2 1000) (expt 2 1000)) "equilateral"))
       (test-case "a really small equilateral triangle"
              (check-equal? (classify-triangle .0000000001 .0000000001 .0000000001 ) "equilateral"))
       (test-case "a scalene triangle"
              (check-equal? (classify-triangle 2 3 4) "scalene"))
       (test-case "unit side length equilateral triangle"
              (check-equal? (classify-triangle 1 1 1) "equilateral"))))
    
