????TDD??????

??????????????????Test Driven Development?? TDD??????????????????Extreme Programming??XP????XP???1999????????????????????????????XP???????2??????Junit??????XP????????????????Junit??Kent Beck??Eric Gamma??λ???????????????д?????ū???????????03??XP??????????????TDD??????

?????? ?д??δ?????????д??????????

?????? ??????????????в???????д????

?????? ???????????????????????????????

?????? ???????????????£????????

????ruby??????TDD???????

?????????????????????x??y????????????????????????б????????????

classTC_Point < Test::Unit::TestCase 

02   @@valid_points= [[1??2]?? [0??0]] 

03   @@invalid_points= [[nil??3]?? [3??nil]?? [1?? -2]?? [-1??2]?? [1.5??2]?? [35??5.66778]] 

04   deftest_valid_point

05     @@valid_points.eachdo|point| 

06       p = Point.new(point[0]?? point[1]) 

07       assert(p.row == point[0])

08       assert(p.column == point[1]) 

09     end 

10   end 

11   deftest_invalid_point 

12     @@invalid_points.eachdo|point| 

13       assert_raise RuntimeErrordo 

14         p = Point.new(point[0]?? point[1]) 

15       end

16    end

17   end

18 end 
 


???????????????к????Point?????д????

classPoint 

02   attr_reader:row??:column 

03   definitialize(row?? column) 

04     if!row.is_a?(Integer)or!column.is_a?(Integer) 

05       raise"row #{row} and column #{column} must be integer" 

06     end 

07     ifrow<0orcolumn<0 

08       raise"row #{row} and column #{column} must be >= 0" 

09     end 

10     @row= row 

11     @column= column 

12   end 

13 end
 


????????????в?????????????????Point??δ????????????????????????д???????????????????????????????????????Point????????????????????????????й????