From: Piers Cawley Date: 2001-12-12T21:03:29+09:00 Subject: [ruby-talk:28338] Re: John Roth dolt ( Re: A challenge to proponents of Unit Testing. ) "Kent Beck" writes: > Kent Beck 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?