summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-04-27 07:38:17 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-04-27 07:38:17 +0000
commit0ea4badca0069846e0da75feed0fdb587e8fc275 (patch)
treee55a31af16b9d127ea316e65051cc595bac8807c /lib
parentab6cc5a958ed09927cf4f23825dac453d405148b (diff)
downloadperl-0ea4badca0069846e0da75feed0fdb587e8fc275.tar.gz
Add Dave Mitchell's test case for fields.
p4raw-id: //depot/perl@19350
Diffstat (limited to 'lib')
-rwxr-xr-xlib/fields.t26
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');
+}
+
+