diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-27 07:38:17 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-27 07:38:17 +0000 |
commit | 0ea4badca0069846e0da75feed0fdb587e8fc275 (patch) | |
tree | e55a31af16b9d127ea316e65051cc595bac8807c /lib | |
parent | ab6cc5a958ed09927cf4f23825dac453d405148b (diff) | |
download | perl-0ea4badca0069846e0da75feed0fdb587e8fc275.tar.gz |
Add Dave Mitchell's test case for fields.
p4raw-id: //depot/perl@19350
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/fields.t | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/fields.t b/lib/fields.t index c4d5ef61a8..dee94471c1 100755 --- a/lib/fields.t +++ b/lib/fields.t @@ -93,8 +93,10 @@ my %expect = ( 'Foo::Bar::Baz' => 'b1:1,b2:2,b3:3,foo:4,bar:5,baz:6', ); -plan tests => keys(%expect) + 17; +plan tests => keys(%expect) + 21; + my $testno = 0; + while (my($class, $exp) = each %expect) { no strict 'refs'; my $fstr = fstr(\%{$class."::FIELDS"}); @@ -213,3 +215,25 @@ package Test::Version3; use base qw(Has::Version_0); ::is( $Has::Version_0::VERSION, 0, '$VERSION==0 preserved' ); +package Test::FooBar; + +use fields qw(a b c); + +sub new { + my $self = fields::new(shift); + %$self = @_ if @_; + $self; +} + +package main; + +{ + my $x = Test::FooBar->new( a => 1, b => 2); + + is(ref $x, 'Test::FooBar', 'x is a Test::FooBar'); + ok(exists $x->{a}, 'x has a'); + ok(exists $x->{b}, 'x has b'); + is(scalar keys %$x, 2, 'x has two fields'); +} + + |