Le 14/4/2005, "Phlip" <phlip_cpp@yahoo.com> a écrit:
>Rubies:
>
>Here's the Ruby 1.8 test\unit version of assert_equal()
>
> def assert_equal(expected, actual, message=nil)
> full_message = build_message(message, <<EOT, expected, actual)
><?> expected but was
><?>.
>EOT
> assert_block(full_message) { expected == actual }
> end
>
>Notice it builds a message even if the assertion passes.
>
>Because assertions passing should be the most common behavior, shouldn't
>that method run like this?
>
> def assert_equal(expected, actual, message=nil)
> assert_block(full_message) do
> if expected == actual then
> ''
> else
> build_message(message, <<EOT, expected, actual)
><?> expected but was
><?>.
>EOT
> end
> end
> end
>
>Then assert_block() should trigger if its block yields a complaint string.
test/unit has a built-in load tester :)
Yes, it would make more sense the other way but
I suspect this is due to simpler implementation
and the idea that assertions do not run in production
code so it does not matter. I can not test it
right now but it does not seem like your code
would actually run since 'full_message' does
not exist?
> Phlip
E
--
No-one expects the Solaris POSIX implementation!