1# $Id: 05dtype.t,v 0.18 2006/10/08 03:37:29 ray Exp $ 2# Before `make install' is performed this script should be runnable with 3# `make test'. After `make install' it should work as `perl test.pl' 4 5######################### We start with some black magic to print on failure. 6 7# Change 1..1 below to 1..last_test_to_print . 8# (It may become useful if the test is moved to ./t subdirectory.) 9 10BEGIN { $| = 1; print "1..2\n"; } 11END {print "not ok 1\n" unless $loaded;} 12use Clone; 13$loaded = 1; 14print "ok 1\n"; 15 16######################### End of black magic. 17 18# Insert your test code below (better if it prints "ok 13" 19# (correspondingly "not ok 13") depending on the success of chunk 13 20# of the test code): 21 22use Data::Dumper; 23eval 'use Storable qw( dclone )'; 24if ($@) 25{ 26 print "ok 2 # skipping Storable not found\n"; 27 exit; 28} 29# use Storable qw( dclone ); 30 31$^W = 0; 32$test = 2; 33 34sub ok { printf("ok %d\n", $test++); } 35sub not_ok { printf("not ok %d\n", $test++); } 36 37use strict; 38 39package Test::Hash; 40 41@Test::Hash::ISA = qw( Clone ); 42 43sub new() 44{ 45 my ($class) = @_; 46 my $self = {}; 47 $self->{x} = 0; 48 $self->{x} = {value => 1}; 49 bless $self, $class; 50} 51 52package main; 53 54my ($master, $clone1); 55 56my $a = Test::Hash->new(); 57 58my $b = $a->clone; 59my $c = dclone($a); 60 61Dumper($a, $b) eq Dumper($a, $c) ? ok() : not_ok; 62# print Dumper($a, $b); 63# print Dumper($a, $c); 64