On Thursday, June 19, 2003, at 10:52 AM, Fergal Daly wrote:
On Thursday 19 June 2003 15:15, Enrico Sorcinelli wrote:[...]Why not to hack into Test::More in order to improve it and fix its bugs?
Test::More is often used and I think that your patches will be welcome!
I did, my patches were accepted by Michael Schwern months ago but he hasn't
released a new version, I think he's pretty busy at the moment.
Anyway, Test::Deep does huge amounts more than Test::More.
Simple usage is much like is_deeply(): cmp_deeply($hash, { a=> [1, 2, 3], b => \'hello'});
More advanced features: cmp_deeply($set, set(1, 2, 3, 4));
will make sure that $set is an array ref which is setwise equal to (1, 2, 3,
4) so any of the following would be ok: [1, 2, 3, 4] or [4, 2, 3, 1] or [4,
4, 3, 2, 4, 2, 1, 3, 2, 1]
cmp_deepy($hash, { set1 => set(1, 2, 3, 4), set2 => set(5, 6, 7, 8), } );
makes sure that $hash has 2 keys and that $hash->{"set1"} is setwise equal to (1, 2, 3, 4) and $hash->{"set2"} is setwise equal to (5..8)
Hi Fergal,
I just read the rest of this thread after sending my previous message.
I have a couple of comments. First, I think that the setwise capabilities are neat, I don't think I'd have much use for them myself but they seem to take a certain task and make it easier. I recommend something like a Test::Setwise namespace for that stuff. The bag stuff could go there quite nicely too - even though sets and bags are different people tend to think of them as close relatives.
Second, I find it very confusing that all these different capabilities are happening inside one cmp_deeply() function. In Perl it's much more common to use the function/operator to indicate how comparisons will be done - for example, <=> vs. cmp, or == vs. eq. I would much rather see these things broken up into their own functions.
-Ken