Saturday, May 13, 2006

Simpsons Ruby Mixin

Homerpalooza "I used to be with it, but then they changed what "it" was. Now, what I'm with isn't it, and what's "it" seems weird and scary to me."

Why Aren't My Assertions Counted? "The problem typically comes when you put assertions in your library modules. This isn't hard. All you have to do is put include Test::Unit::Assertions in your module or helper class and then you can include calls to assert, assert_equal and all the other assert methods. It works, except that your assertions aren't counted.

The reason why is that the method add_assertion does the counting. This is automatically called by all the assert methods. When they call the add_assertion method of TestCase, the count shows up in your test results no problem. But the add_assertion method of the Assertions module is just a no op. This is why they don't affect the assertion count. The solution is to add a functional add_assertion method back to your helper module/class that ties back to your test case."

When the language has the []= operator and it can be overloaded is somewhat scary. But when you fix what seems like a bug by changing the behaviour of the underlying class it seems crazy. I'd like to be able to say with certainty that the lack of interfaces is a mistake (or not) just like people seem to consider checked exceptions. Or that the ability to abitrarily add behaviour to existing objects is going to destroy open source and make code unmaintainable.

Why do you need new languages? Everyone knows programming languages attained perfection in 1995. It's a scientific fact.
Post a Comment