This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Import version.pm 0.9914 from CPAN
[perl5.git] / cpan / Digest-MD5 / t / clone.t
CommitLineData
ac70dec1
JH
1#!perl -w
2
3print "1..6\n";
4
5use strict;
6use Digest::MD5 qw(md5_hex);
7
8my $a = Digest::MD5->new;
9$a->add("a");
10my $b = $a->clone;
11
12print "not " unless $b->clone->hexdigest eq md5_hex("a");
13print "ok 1\n";
14
15$a->add("a");
16print "not " unless $a->hexdigest eq md5_hex("aa");
17print "ok 2\n";
18
19print "not " unless $a->hexdigest eq md5_hex("");
20print "ok 3\n";
21
22$b->add("b");
23print "not " unless $b->clone->hexdigest eq md5_hex("ab");
24print "ok 4\n";
25
26$b->add("c");
27print "not " unless $b->clone->hexdigest eq md5_hex("abc");
28print "ok 5\n";
29
30# Test that cloning picks up the correct class for subclasses.
31{
32 package MD5;
33 @MD5::ISA = qw(Digest::MD5);
34}
35
36$a = MD5->new;
37$a->add("a");
38$b = $a->clone;
39
40print "not " unless ref($b) eq "MD5" && $b->add("b")->hexdigest eq md5_hex("ab");
41print "ok 6\n";