Re: [Perlunit-devel] the old 'ok' chestnut
Status: Beta
Brought to you by:
mca1001
From: Adam S. <ad...@sp...> - 2001-11-12 15:28:50
|
Piers Cawley (pdc...@bo...) wrote: > "Hans Donner" <han...@us...> writes: > > > I think you're at risk that youre co-workers will keep using the > > ok() tests instead of the $self->assert. I think they better write > > th ok wrapper themselves, instead of providing it if they want to > > keep the ok. Nah, they'll use assert() for new stuff if I tell 'em too, and I don't see the point of writing the wrapper locally, since the Test.pm API is well documented. > Maybe if we provide our own 'ok' wrapper, but have it throw a > 'DEPRECATED' warning the first time it's called in any program run. > > Test::Unit::Assert::ok is deprecated, please consider moving over > to using Test::Unit::Assert::assert_equals and friends when > writing PerlUnit tests. > > If we just make that happen once per run in a way that can be > overridden (by the user defining a constant OK_IS_OK or something) > then we get the message across. Attribute::Deprecated handles this quite nicely, although it doesn't seem to allow the user to override. Worth submitting a patch to the author, I would have thought. Overriding via some sugar like use deprecated 'ok'; would be pretty cute. > BTW, why didn't we want 'ok'? I think the original objection was that test code should distinguish between the different types of equality. Your new overloading stuff solves this very nicely though, I think. > Note too that if 'ok' is going to be a wrapper round assert_equals then > it's going to fail in the case 'ok $got, qr/$expected_pattern/' > because assert_equals doesn't do regex matching (because when all's > said and done 'matches a regex' is a strange definition of 'equals') It's a kind of multiplexing wrapper around assert() and assert_equals(), so the regex matching should work fine too. I've already committed to Assert.pm if you want to have a look. It's not finished yet. |