Re: [code-review] Please review String::FlexMatch
Marcel GrĂ¼nauer <[email protected]> Mon, 8 Sep 2003 10:02:50 +0200
| Newsgroups | gmane.comp.lang.perl.code-review-ladder |
|---|---|
| Message-ID | <[email protected]> |
On Montag, September 8, 2003, at 01:04 Uhr, Fergal Daly wrote:
> You could avoid the conversion step by contructing the Test::Deep::*
> objects
> directly. re() is just a shortcut wrapper which calls
> Test::Deep::Regex->new() and similarly for all the others. So
> something like
>
> !perl/Test::Deep::Regex
> val: /blah/
This constructs a string, as does the similar thing with ::Code:
#!/usr/bin/perl
use YAML;
use Data::Dumper;
print Dumper Load do { local $/; <DATA> };
__DATA__
foo: !perl/Test::Deep::Regexp
val: '/bl.*?a[hm]/'
bar: !perl/Test::Deep::Code
val: sub { 1 }
==>
$VAR1 = {
'bar' => bless( {
'val' => 'sub { 1 }'
}, 'Test::Deep::Code' ),
'foo' => bless( {
'val' => '/bl.*?a[hm]/'
}, 'Test::Deep::Regexp' )
};
I.e., the constructor (and hence init()) isn't called.
You'd have to qr// and eval (for regex and code, respectively)
when getting the attribute value as well, as String::FlexMatch does. You
could add that to Test::Deep so it lends itself more easily to
data-driven
deep testing.
> I might actually deprecate eq_deeply() because it's a misleading name,
> it's
> not really equality at all,
The function itself is useful; you need it to test two things you don't
expect to be equal. So maybe just rename it.
Marcel