"Kent Beck" <kentbeck / my-deja.com> writes:

> Kent Beck <kentbeck / my-deja.com> wrote in message
> news:9v4dab$m80$1 / suaar1ab.prod.compuserve.com...
>> The earlier note that I ignored ill-formed triangles (5,5,11) is
> absolutely
>> correct. I missed those test cases. I'll post the updated code and tests
>> later.
>
> The test is:
>
> TriangleTest>>testIrrational
>     [self evaluate: 1 side: 2 side: 3]
>         on: Exception
>         do: [:ex | ^self].
>     self fail
>
> The fix is:
>
> TriangleTest>>evaluate: aNumber1 side: aNumber2 side: aNumber3
>     | sides |
>     sides := SortedCollection
>         with: aNumber1
>         with: aNumber2
>         with: aNumber3.
>     sides first <= 0 ifTrue: [self fail].
>     (sides at: 1) + (sides at: 2) <= (sides at: 3) ifTrue: [self fail].
                                    ^^
Shouldn't that be '<', otherwise (1,1,2) is a valid triange, which
seems unexpected. 
>     ^sides asSet size


-- 
Piers

   "It is a truth universally acknowledged that a language in
    possession of a rich syntax must be in need of a rewrite."
         -- Jane Austen?