Clone-Choose-0.010/0000755000175000017500000000000013262627106013317 5ustar stefanstefanClone-Choose-0.010/MANIFEST0000644000175000017500000000323313262627106014451 0ustar stefanstefanChanges lib/Clone/Choose.pm Makefile.PL MANIFEST This list of files MANIFEST.SKIP README.md t/02-load-with-clone.t t/03-load-with-storable.t t/04-load-with-clone-pp.t t/08-import-fail.t t/Auto/MR/00-load.t t/Auto/MR/01-simple.t t/Auto/MR/05-scalar.t t/Auto/MR/06-array.t t/Auto/MR/07-hash.t t/Auto/MR/09-get_backends.t t/Auto/NoMR/00-load.t t/Auto/NoMR/01-simple.t t/Auto/NoMR/05-scalar.t t/Auto/NoMR/06-array.t t/Auto/NoMR/07-hash.t t/Auto/NoMR/09-get_backends.t t/Clone/MR/00-load.t t/Clone/MR/01-simple.t t/Clone/MR/05-scalar.t t/Clone/MR/06-array.t t/Clone/MR/07-hash.t t/Clone/MR/09-get_backends.t t/Clone/NoMR/00-load.t t/Clone/NoMR/01-simple.t t/Clone/NoMR/05-scalar.t t/Clone/NoMR/06-array.t t/Clone/NoMR/07-hash.t t/Clone/NoMR/09-get_backends.t t/ClonePP/MR/00-load.t t/ClonePP/MR/01-simple.t t/ClonePP/MR/05-scalar.t t/ClonePP/MR/06-array.t t/ClonePP/MR/07-hash.t t/ClonePP/MR/09-get_backends.t t/ClonePP/NoMR/00-load.t t/ClonePP/NoMR/01-simple.t t/ClonePP/NoMR/05-scalar.t t/ClonePP/NoMR/06-array.t t/ClonePP/NoMR/07-hash.t t/ClonePP/NoMR/09-get_backends.t t/inline/00-load.t t/inline/01-simple.t t/inline/05-scalar.t t/inline/06-array.t t/inline/07-hash.t t/inline/09-get_backends.t t/Storable/MR/00-load.t t/Storable/MR/01-simple.t t/Storable/MR/05-scalar.t t/Storable/MR/06-array.t t/Storable/MR/07-hash.t t/Storable/MR/09-get_backends.t t/Storable/NoMR/00-load.t t/Storable/NoMR/01-simple.t t/Storable/NoMR/05-scalar.t t/Storable/NoMR/06-array.t t/Storable/NoMR/07-hash.t t/Storable/NoMR/09-get_backends.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Clone-Choose-0.010/MANIFEST.SKIP0000644000175000017500000000052313262102051015200 0ustar stefanstefan\B\.svn\b \B\.git\b \.gitignore$ .travis.yml \.[Bb][Aa][Kk]$ \.orig$ \.old$ \.tdy$ \.tmp$ \..*swp ^Makefile$ ^Build$ ^Build\.bat$ \.Inline/.* _Inline/.* \.bak$ \.tar$ \.tgz$ \.tar\.gz$ ^mess/ ^tmp/ ^testdata/ ^blib/ ^sandbox/ ^pm_to_blib$ ^cover_db/ ^_build/.* ~$ .*\.planner ^\..* Clone-Choose-.* \bxt Sandbox ^MYMETA\.json$ ^MYMETA\..*$ Clone-Choose-0.010/META.yml0000644000175000017500000000162013262627106014567 0ustar stefanstefan--- abstract: 'Choose appropriate clone utility' author: - 'Jens Rehsack ' - 'Stefan Hermes ' build_requires: Test::More: '0.9' Test::Without::Module: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Clone-Choose no_index: directory: - t - inc recommends: Module::Runtime: '0' requires: Storable: '0' perl: v5.8.1 resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Clone-Choose homepage: https://metacpan.org/release/Clone-Choose license: http://dev.perl.org/licenses/ repository: https://github.com:perl5-utils/Clone-Choose.git version: '0.010' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Clone-Choose-0.010/Changes0000644000175000017500000000267013262626712014621 0ustar stefanstefanRevision history for Clone-Choose 0.010 2018-04-09 - Fix test if Module::Runtime not installed. Should fix RT#125045 reported by Slaven Rezić. 0.009 2018-04-07 - Added testcase for importing an unsupported backend function. - Added testcase for the get_backends() function. - Added testcase for when Module::Runtime is not available. 0.008 2017-10-27 - Prove whether all prerequisites are available for a particular backend before the test starts. 0.007 2017-10-27 - Fix simple test to not fail if preselected backend is not found. 0.006 2017-10-26 - Use inline test templates to ńot fail if . is not in @INC. - Do more tests with the different backends. 0.005 2017-10-24 - avoid distributing Sandbox - fixes GH issue#2 reported by Slaven Rezić 0.004 2017-10-24 - Added get_backends() function which returns a list of currently supported backends. - Extended testing for the different clone() providing backends. - Introduce environment variable CLONE_CHOOSE_PREFERRED_BACKEND to let you preselect your favourite backend. 0.003 2017-10-16 - Introduce a backend() debug helper to help identifying issues depending on underlying 0.002 2017-10-05 - When using Clone.pm enforce minimum version 0.10. - Fix bug which caused clone() not to be exported in the correct namespace. 0.001 2017-09-27 - First version, released on an unsuspecting world. Clone-Choose-0.010/Makefile.PL0000644000175000017500000001301213262136033015260 0ustar stefanstefanuse strict; use warnings; use 5.008001; use ExtUtils::MakeMaker; my %RUN_DEPS = ($] < 5.007003 ? ('Clone::PP' => 0) : ('Storable' => 0)); my %CONFIGURE_DEPS = ( 'ExtUtils::MakeMaker' => 0, ); my %BUILD_DEPS = (); my %TEST_DEPS = ( 'Test::More' => 0.90, 'Test::Without::Module' => 0, ); if (-d 'Sandbox') { unless (grep { $_ eq '.' } @INC) { use lib '.'; } eval "use Sandbox::Tumble ();"; $@ and die $@; eval "use File::Path ();"; File::Path->import; -d 't/Auto' and rmtree('t/Auto'); -d 't/Clone' and rmtree('t/Clone'); -d 't/Storable' and rmtree('t/Storable'); -d 't/ClonePP' and rmtree('t/ClonePP'); Sandbox::Tumble->tumble(qw(t)); } WriteMakefile1( MIN_PERL_VERSION => '5.008001', META_MERGE => { 'meta-spec' => {version => 2}, dynamic_config => 1, resources => { homepage => 'https://metacpan.org/release/Clone-Choose', repository => { url => 'https://github.com:perl5-utils/Clone-Choose.git', web => 'https://github.com/perl5-utils/Clone-Choose', type => 'git', }, bugtracker => { web => 'http://rt.cpan.org/Public/Dist/Display.html?Name=Clone-Choose', mailto => 'bug-Clone-Choose@rt.cpan.org', }, license => 'http://dev.perl.org/licenses/', }, prereqs => { develop => { requires => { 'Test::CPAN::Changes' => 0, 'Test::CheckManifest' => 0, 'Module::CPANTS::Analyse' => '0.96', 'Test::Kwalitee' => 0, 'Test::Pod' => 0, 'Test::Pod::Coverage' => 0, 'Test::Pod::Spelling::CommonMistakes' => 0, 'Test::Spelling' => 0, 'Test::Perl::Critic' => 0, 'Test::PerlTidy' => 0, 'Test::WriteVariants' => '0.014', }, }, configure => { requires => {%CONFIGURE_DEPS}, }, build => {requires => {%BUILD_DEPS}}, test => { requires => {%TEST_DEPS}, suggests => { 'Clone' => 0.10, 'Clone::PP' => 0, 'Storable' => 0 } }, runtime => { requires => { %RUN_DEPS, perl => '5.8.1', }, recommends => { 'Module::Runtime' => 0, }, }, }, }, NAME => 'Clone::Choose', VERSION_FROM => 'lib/Clone/Choose.pm', ABSTRACT_FROM => 'lib/Clone/Choose.pm', LICENSE => 'perl', AUTHOR => [q{Jens Rehsack }, q{Stefan Hermes }], CONFIGURE_REQUIRES => \%CONFIGURE_DEPS, PREREQ_PM => \%RUN_DEPS, BUILD_REQUIRES => \%BUILD_DEPS, TEST_REQUIRES => \%TEST_DEPS, test => {TESTS => join(' ', 't/Auto/*/*.t', 't/*.t', 't/Clone/*/*.t', 't/Storable/*/*.t', 't/ClonePP/*/*.t', 'xt/*.t')}, (-d "Sandbox" ? (realclean => {FILES => join(' ', 't/Auto/', 't/Clone', 't/Storable', 't/ClonePP', 'M*.bak')}) : ()), ); sub WriteMakefile1 { # originally written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade. my %params = @_; my $eumm_version = $ExtUtils::MakeMaker::VERSION; $eumm_version = eval $eumm_version; die "EXTRA_META is deprecated" if (exists($params{EXTRA_META})); die "License not specified" if (!exists($params{LICENSE})); $params{TEST_REQUIRES} and $eumm_version < 6.6303 and $params{BUILD_REQUIRES} = {%{$params{BUILD_REQUIRES} || {}}, %{delete $params{TEST_REQUIRES}}}; #EUMM 6.5502 has problems with BUILD_REQUIRES $params{BUILD_REQUIRES} and $eumm_version < 6.5503 and $params{PREREQ_PM} = {%{$params{PREREQ_PM} || {}}, %{delete $params{BUILD_REQUIRES}}}; ref $params{AUTHOR} and "ARRAY" eq ref $params{AUTHOR} and $eumm_version < 6.5702 and $params{AUTHOR} = join(", ", @{$params{AUTHOR}}); delete $params{CONFIGURE_REQUIRES} if ($eumm_version < 6.52); delete $params{MIN_PERL_VERSION} if ($eumm_version < 6.48); delete $params{META_MERGE} if ($eumm_version < 6.46); delete $params{META_ADD}{prereqs} if ($eumm_version < 6.58); delete $params{META_ADD}{'meta-spec'} if ($eumm_version < 6.58); delete $params{META_ADD} if ($eumm_version < 6.46); delete $params{LICENSE} if ($eumm_version < 6.31); delete $params{AUTHOR} if ($] < 5.005); delete $params{ABSTRACT_FROM} if ($] < 5.005); delete $params{BINARY_LOCATION} if ($] < 5.005); # more or less taken from Moose' Makefile.PL if ($params{CONFLICTS}) { my $ok = CheckConflicts(%params); exit(0) if ($params{PREREQ_FATAL} and not $ok); my $cpan_smoker = grep { $_ =~ m/(?:CR_SMOKER|CPAN_REPORTER|AUTOMATED_TESTING)/ } keys %ENV; unless ($cpan_smoker || $ENV{PERL_MM_USE_DEFAULT}) { sleep 4 unless ($ok); } delete $params{CONFLICTS}; } WriteMakefile(%params); } Clone-Choose-0.010/t/0000755000175000017500000000000013262627106013562 5ustar stefanstefanClone-Choose-0.010/t/ClonePP/0000755000175000017500000000000013262627106015062 5ustar stefanstefanClone-Choose-0.010/t/ClonePP/MR/0000755000175000017500000000000013262627106015400 5ustar stefanstefanClone-Choose-0.010/t/ClonePP/MR/00-load.t0000644000175000017500000000121713262627061016722 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/ClonePP/MR/05-scalar.t0000644000175000017500000000157013262627061017257 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/ClonePP/MR/07-hash.t0000644000175000017500000000374413262627061016744 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/ClonePP/MR/01-simple.t0000644000175000017500000000110113262627061017265 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/ClonePP/MR/06-array.t0000644000175000017500000000316513262627061017133 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/ClonePP/MR/09-get_backends.t0000644000175000017500000000121013262627061020416 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/ClonePP/NoMR/0000755000175000017500000000000013262627106015675 5ustar stefanstefanClone-Choose-0.010/t/ClonePP/NoMR/00-load.t0000644000175000017500000000127613262627061017224 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/ClonePP/NoMR/05-scalar.t0000644000175000017500000000164713262627061017561 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/ClonePP/NoMR/07-hash.t0000644000175000017500000000402313262627061017230 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/ClonePP/NoMR/01-simple.t0000644000175000017500000000116013262627061017567 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/ClonePP/NoMR/06-array.t0000644000175000017500000000324413262627061017426 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/ClonePP/NoMR/09-get_backends.t0000644000175000017500000000126713262627061020727 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone::PP"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/Auto/0000755000175000017500000000000013262627106014472 5ustar stefanstefanClone-Choose-0.010/t/Auto/MR/0000755000175000017500000000000013262627106015010 5ustar stefanstefanClone-Choose-0.010/t/Auto/MR/00-load.t0000644000175000017500000000102313262627061016325 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/Auto/MR/05-scalar.t0000644000175000017500000000137413262627061016671 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/Auto/MR/07-hash.t0000644000175000017500000000355013262627061016347 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/Auto/MR/01-simple.t0000644000175000017500000000070513262627061016706 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/Auto/MR/06-array.t0000644000175000017500000000277113262627061016545 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/Auto/MR/09-get_backends.t0000644000175000017500000000101413262627061020030 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/Auto/NoMR/0000755000175000017500000000000013262627106015305 5ustar stefanstefanClone-Choose-0.010/t/Auto/NoMR/00-load.t0000644000175000017500000000110213262627061016620 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/Auto/NoMR/05-scalar.t0000644000175000017500000000145313262627061017164 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/Auto/NoMR/07-hash.t0000644000175000017500000000362713262627061016651 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/Auto/NoMR/01-simple.t0000644000175000017500000000076413262627061017210 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/Auto/NoMR/06-array.t0000644000175000017500000000305013262627061017031 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/Auto/NoMR/09-get_backends.t0000644000175000017500000000107313262627061020332 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/02-load-with-clone.t0000644000175000017500000000041513165434762017162 0ustar stefanstefan#!perl use strict; use warnings; use Test::More; eval "use Clone;"; $@ and plan skip_all => "No Clone found. Can't prove load successfull with :Clone."; use_ok("Clone::Choose", qw(:Clone)) || plan skip_all => "Couldn't use Clone::Choose qw(:Clone)."; done_testing; Clone-Choose-0.010/t/Clone/0000755000175000017500000000000013262627106014622 5ustar stefanstefanClone-Choose-0.010/t/Clone/MR/0000755000175000017500000000000013262627106015140 5ustar stefanstefanClone-Choose-0.010/t/Clone/MR/00-load.t0000644000175000017500000000121313262627061016456 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/Clone/MR/05-scalar.t0000644000175000017500000000156413262627061017022 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/Clone/MR/07-hash.t0000644000175000017500000000374013262627061016500 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/Clone/MR/01-simple.t0000644000175000017500000000107513262627061017037 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/Clone/MR/06-array.t0000644000175000017500000000316113262627061016667 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/Clone/MR/09-get_backends.t0000644000175000017500000000120413262627061020161 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/Clone/NoMR/0000755000175000017500000000000013262627106015435 5ustar stefanstefanClone-Choose-0.010/t/Clone/NoMR/00-load.t0000644000175000017500000000127213262627061016760 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/Clone/NoMR/05-scalar.t0000644000175000017500000000164313262627061017315 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/Clone/NoMR/07-hash.t0000644000175000017500000000401713262627061016773 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/Clone/NoMR/01-simple.t0000644000175000017500000000115413262627061017332 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/Clone/NoMR/06-array.t0000644000175000017500000000324013262627061017162 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/Clone/NoMR/09-get_backends.t0000644000175000017500000000126313262627061020463 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Clone"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/inline/0000755000175000017500000000000013262627106015040 5ustar stefanstefanClone-Choose-0.010/t/inline/00-load.t0000644000175000017500000000071513174361543016366 0ustar stefanstefanuse Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/inline/05-scalar.t0000644000175000017500000000126613174361543016723 0ustar stefanstefanuse Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/inline/07-hash.t0000644000175000017500000000344213174361543016401 0ustar stefanstefanuse Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/inline/01-simple.t0000644000175000017500000000057713174573267016757 0ustar stefanstefanuse Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/inline/06-array.t0000644000175000017500000000266313174361543016577 0ustar stefanstefanuse Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/inline/09-get_backends.t0000644000175000017500000000070613262627031020064 0ustar stefanstefanuse Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/04-load-with-clone-pp.t0000644000175000017500000000044113165435100017563 0ustar stefanstefan#!perl use strict; use warnings; use Test::More; eval "use Clone::PP;"; $@ and plan skip_all => "No Clone::PP found. Can't prove load successfull with :Clone::PP."; use_ok("Clone::Choose", qw(:Clone::PP)) || plan skip_all => "Couldn't use Clone::Choose qw(:Clone::PP)."; done_testing; Clone-Choose-0.010/t/03-load-with-storable.t0000644000175000017500000000043613165435050017670 0ustar stefanstefan#! perl use strict; use warnings; use Test::More; eval "use Storable;"; $@ and plan skip_all => "No Storable found. Can't prove load successfully with :Storable."; use_ok("Clone::Choose", qw(:Storable)) || plan skip_all => "Couldn't use Clone::Choose qw(:Storable)."; done_testing; Clone-Choose-0.010/t/Storable/0000755000175000017500000000000013262627106015335 5ustar stefanstefanClone-Choose-0.010/t/Storable/MR/0000755000175000017500000000000013262627106015653 5ustar stefanstefanClone-Choose-0.010/t/Storable/MR/00-load.t0000644000175000017500000000121613262627061017174 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/Storable/MR/05-scalar.t0000644000175000017500000000156713262627061017540 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/Storable/MR/07-hash.t0000644000175000017500000000374313262627061017216 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/Storable/MR/01-simple.t0000644000175000017500000000110013262627061017537 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/Storable/MR/06-array.t0000644000175000017500000000316413262627061017405 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/Storable/MR/09-get_backends.t0000644000175000017500000000120713262627061020677 0ustar stefanstefan#!perl use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/Storable/NoMR/0000755000175000017500000000000013262627106016150 5ustar stefanstefanClone-Choose-0.010/t/Storable/NoMR/00-load.t0000644000175000017500000000127513262627061017476 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; use_ok('Clone::Choose') || BAIL_OUT "Couldn't load Clone::Choose"; } diag("Testing Clone::Choose $Clone::Choose::VERSION, Perl $], $^X"); my $backend = Clone::Choose->backend; diag("Using backend $backend version " . $backend->VERSION); done_testing; Clone-Choose-0.010/t/Storable/NoMR/05-scalar.t0000644000175000017500000000164613262627061020033 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $string = "Scalar"; $string = \$string; my $cloned_string = clone $string; ok(refaddr $string != refaddr $cloned_string, "Scalar String"); my $numeric = 3.141; $numeric = \$numeric; my $cloned_numeric = clone $numeric; ok(refaddr $numeric != refaddr $cloned_numeric, "Scalar Numeric"); my $undef = undef; $undef = \$undef; my $cloned_undef = clone $undef; ok(refaddr $undef != refaddr $cloned_undef, "Scalar Undef"); done_testing; Clone-Choose-0.010/t/Storable/NoMR/07-hash.t0000644000175000017500000000402213262627061017502 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $hash = { level => 0, href => { level => 1, href => { level => 2, href => {level => 3}, }, }, }; my $cloned_hash = clone $hash; ok(refaddr $hash != refaddr $cloned_hash, "Clone depth 0"); ok(refaddr($hash->{href}) != refaddr($cloned_hash->{href}), "Clone depth 1"); ok(refaddr($hash->{href}->{href}) != refaddr($cloned_hash->{href}->{href}), "Clone depth 2"); ok(refaddr($hash->{href}->{href}->{href}) != refaddr($cloned_hash->{href}->{href}->{href}), "Clone depth 3"); ok($hash->{level} == $cloned_hash->{level}, "Hash value depth 0"); ok($hash->{href}->{level} == $cloned_hash->{href}->{level}, "Hash value depth 1"); ok($hash->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{level}, "Hash value depth 2"); ok($hash->{href}->{href}->{href}->{level} == $cloned_hash->{href}->{href}->{href}->{level}, "Hash value depth 3"); ok($hash->{level} == 0, "Hash value sanity depth 0"); ok($hash->{href}->{level} == 1, "Hash value sanity depth 1"); ok($hash->{href}->{href}->{level} == 2, "Hash value sanity depth 2"); ok($hash->{href}->{href}->{href}->{level} == 3, "Hash value sanity depth 3"); my $empty_hash = {}; my $cloned_empty_hash = clone $empty_hash; ok(refaddr $empty_hash != refaddr $cloned_empty_hash, "Empty hash clone"); done_testing; Clone-Choose-0.010/t/Storable/NoMR/01-simple.t0000644000175000017500000000115713262627061020050 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my %src = ( simple => "yeah", ary => [qw(foo bar)], hash => {foo => "bar"} ); my $tgt = clone(\%src); is_deeply(\%src, $tgt); done_testing; Clone-Choose-0.010/t/Storable/NoMR/06-array.t0000644000175000017500000000324313262627061017700 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Scalar::Util qw(refaddr); use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my $array = [1, ["two", [3, ["four"],],],]; my $cloned_array = clone $array; ok(refaddr $array != refaddr $cloned_array, "Clone depth 0"); ok(refaddr($array->[1]) != refaddr($cloned_array->[1]), "Clone depth 1"); ok(refaddr($array->[1][1]) != refaddr($cloned_array->[1][1]), "Clone depth 2"); ok(refaddr($array->[1][1][1]) != refaddr($cloned_array->[1][1][1]), "Clone depth 3"); ok($array->[0] == $cloned_array->[0], "Array value depth 0"); ok($array->[1][0] eq $cloned_array->[1][0], "Array value depth 1"); ok($array->[1][1][0] == $cloned_array->[1][1][0], "Array value depth 2"); ok($array->[1][1][1][0] eq $cloned_array->[1][1][1][0], "Array value depth 3"); ok($cloned_array->[0] == 1, "Array value sanity depth 0"); ok($cloned_array->[1][0] eq "two", "Array value sanity depth 1"); ok($cloned_array->[1][1][0] == 3, "Array value sanity depth 2"); ok($cloned_array->[1][1][1][0] eq "four", "Array value sanity depth 3"); my $empty_array = []; my $cloned_empty_array = clone $empty_array; ok(refaddr $empty_array != refaddr $cloned_empty_array, "Empty array clone"); done_testing; Clone-Choose-0.010/t/Storable/NoMR/09-get_backends.t0000644000175000017500000000126613262627061021201 0ustar stefanstefan#!perl use Test::Without::Module ("Module::Runtime"); use strict ("subs", "vars", "refs"); use warnings ("all"); BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} = "Storable"; } END { delete $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} } # for VMS use Test::More; BEGIN { $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and eval "use $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; 1;"; $@ and plan skip_all => "No $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} found."; } use Clone::Choose; my @backends = Clone::Choose->get_backends; my $backend = Clone::Choose->backend; ok($ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $backend eq $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} or grep { m/^$backend$/ } @backends); done_testing; Clone-Choose-0.010/t/08-import-fail.t0000644000175000017500000000055413262626671016431 0ustar stefanstefan#!perl use strict; use warnings; use Test::More; eval "use Module::Runtime;"; $@ and plan skip_all => "Module::Runtime not found. Skipping test."; Module::Runtime->import("use_module"); eval { use_module("Clone::Choose")->import("no_clone"); }; my $e = $@; like($e, qr/no_clone is not exportable by Clone::Choose/, "unknown function imported"); done_testing; Clone-Choose-0.010/META.json0000644000175000017500000000441713262627106014746 0ustar stefanstefan{ "abstract" : "Choose appropriate clone utility", "author" : [ "Jens Rehsack ", "Stefan Hermes " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Clone-Choose", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "develop" : { "requires" : { "Module::CPANTS::Analyse" : "0.96", "Test::CPAN::Changes" : "0", "Test::CheckManifest" : "0", "Test::Kwalitee" : "0", "Test::Perl::Critic" : "0", "Test::PerlTidy" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "Test::Pod::Spelling::CommonMistakes" : "0", "Test::Spelling" : "0", "Test::WriteVariants" : "0.014" } }, "runtime" : { "recommends" : { "Module::Runtime" : "0" }, "requires" : { "Storable" : "0", "perl" : "v5.8.1" } }, "test" : { "requires" : { "Test::More" : "0.9", "Test::Without::Module" : "0" }, "suggests" : { "Clone" : "0.1", "Clone::PP" : "0", "Storable" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "mailto" : "bug-Clone-Choose@rt.cpan.org", "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Clone-Choose" }, "homepage" : "https://metacpan.org/release/Clone-Choose", "license" : [ "http://dev.perl.org/licenses/" ], "repository" : { "type" : "git", "url" : "https://github.com:perl5-utils/Clone-Choose.git", "web" : "https://github.com/perl5-utils/Clone-Choose" } }, "version" : "0.010", "x_serialization_backend" : "JSON::PP version 2.97000" } Clone-Choose-0.010/README.md0000644000175000017500000000757513173641363014616 0ustar stefanstefan# NAME Clone::Choose - Choose appropriate clone utility # SYNOPSIS use Clone::Choose; my $data = { value => 42, href => { set => [ 'foo', 'bar' ], value => 'baz', }, }; my $cloned_data = clone $data; # it's also possible to use Clone::Choose and pass a clone preference use Clone::Choose qw(:Storable); # DESCRIPTION `Clone::Choose` checks several different modules which provides a `clone()` function and selects an appropriate one. The default preference is Clone Storable Clone::PP This list might evolve in future. Please see ["EXPORTS"](#exports) how to pick a particular one. # EXPORTS `Clone::Choose` exports `clone()` by default. One can explicitly import `clone` by using use Clone::Choose qw(clone); or pick a particular `clone` implementation use Clone::Choose qw(:Storable clone); The exported implementation is resolved dynamically, which means that any using module can either rely on the default backend preference or choose a particular one. It is also possible to select a particular `clone` backend by setting the environment variable CLONE\_CHOOSE\_PREFERRED\_BACKEND to your preferred backend. This also means, an already chosen import can't be modified like use Clone::Choose qw(clone :Storable); When one seriously needs different clone implementations, our _recommended_ way to use them would be: use Clone::Choose (); # do not import my ($xs_clone, $st_clone); { local @Clone::Choose::BACKENDS = (Clone => "clone"); $xs_clone = Clone::Choose->can("clone"); } { local @Clone::Choose::BACKENDS = (Storable => "dclone"); $st_clone = Clone::Choose->can("clone"); } Don't misinterpret _recommended_ - modifying `@Clone::Choose::BACKENDS` has a lot of pitfalls and is unreliable beside such small examples. Do not hesitate open a request with an appropriate proposal for choosing implementations dynamically. The use of `@Clone::Choose::BACKENDS` is discouraged and will be deprecated as soon as anyone provides a better idea. # PACKAGE METHODS ## backend `backend` tells the caller about the dynamic chosen backend: use Clone::Choose; say Clone::Choose->backend; # Clone This method currently exists for debug purposes only. ## get\_backends `get_backends` returns a list of the currently supported backends. # AUTHOR Jens Rehsack Stefan Hermes # BUGS Please report any bugs or feature requests to `bug-Clone-Choose at rt.cpan.org`, or through the web interface at [http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Clone-Choose](http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Clone-Choose). I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. # SUPPORT You can find documentation for this module with the perldoc command. perldoc Clone::Choose You can also look for information at: - RT: CPAN's request tracker [http://rt.cpan.org/NoAuth/Bugs.html?Dist=Clone-Choose](http://rt.cpan.org/NoAuth/Bugs.html?Dist=Clone-Choose) - AnnoCPAN: Annotated CPAN documentation [http://annocpan.org/dist/Clone-Choose](http://annocpan.org/dist/Clone-Choose) - CPAN Ratings [http://cpanratings.perl.org/d/Clone-Choose](http://cpanratings.perl.org/d/Clone-Choose) - Search CPAN [http://search.cpan.org/dist/Clone-Choose/](http://search.cpan.org/dist/Clone-Choose/) # LICENSE AND COPYRIGHT Copyright 2017 Jens Rehsack Copyright 2017 Stefan Hermes This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. # SEE ALSO [Clone](https://metacpan.org/pod/Clone), [Clone::PP](https://metacpan.org/pod/Clone::PP), [Storable](https://metacpan.org/pod/Storable) Clone-Choose-0.010/lib/0000755000175000017500000000000013262627106014065 5ustar stefanstefanClone-Choose-0.010/lib/Clone/0000755000175000017500000000000013262627106015125 5ustar stefanstefanClone-Choose-0.010/lib/Clone/Choose.pm0000644000175000017500000001671413262626712016716 0ustar stefanstefanpackage Clone::Choose; use strict; use warnings; use Carp (); our $VERSION = "0.010"; $VERSION = eval $VERSION; our @BACKENDS = ( Clone => [0.10, "clone"], Storable => "dclone", "Clone::PP" => "clone", ); my $use_m; BEGIN { unless ($use_m) { eval "use Module::Runtime (); 1;" and $use_m = Module::Runtime->can("use_module") unless $ENV{CLONE_CHOOSE_NO_MODULE_RUNTIME}; $use_m ||= sub { my ($pkg, @imports) = @_; my $use_stmt = "use $pkg"; @imports and $use_stmt = join(" ", $use_stmt, @imports); eval $use_stmt; $@ and die $@; 1; }; } } sub backend { my $self = shift; my @backends = @BACKENDS; if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) { my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; my %b = @backends; Carp::croak "$favourite not found" unless $b{$favourite}; @backends = ($favourite => $b{$favourite}); } while (my ($pkg, $rout) = splice @backends, 0, 2) { eval { $use_m->($pkg, ref $rout ? ($rout->[0]) : ()); 1; } or next; my $fn = $pkg->can(ref $rout ? $rout->[1] : $rout); $fn or next; return $pkg; } } sub can { my $self = shift; my $name = shift; my @backends = @BACKENDS; return __PACKAGE__->SUPER::can($name) unless $name eq "clone"; if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) { my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; my %b = @backends; Carp::croak "$favourite not found" unless $b{$favourite}; @backends = ($favourite => $b{$favourite}); } my $fn; while (my ($pkg, $rout) = splice @backends, 0, 2) { eval { $use_m->($pkg, ref $rout ? ($rout->[0]) : ()); 1; } or next; $fn = $pkg->can(ref $rout ? $rout->[1] : $rout); $fn or next; last; } return $fn; } sub import { my ($me, @params) = @_; my $tgt = caller(0); my @B = @BACKENDS; local @BACKENDS = @B; push @params, "clone" unless grep { /^clone$/ } @params; while (my $param = shift @params) { if ($param =~ m/^:(.*)$/) { my $favourite = $1; $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} and $ENV{CLONE_CHOOSE_PREFERRED_BACKEND} ne $favourite and Carp::croak "Environment CLONE_CHOOSE_PREFERRED_BACKEND($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) not equal to imported ($favourite)"; my %b = @BACKENDS; Carp::croak "$favourite not found" unless $b{$favourite}; @BACKENDS = ($favourite => $b{$favourite}); } elsif ($param eq "clone") { my $fn = __PACKAGE__->can("clone"); $fn or Carp::croak "Cannot find an apropriate clone()."; no strict "refs"; *{"${tgt}::clone"} = $fn; @params and Carp::croak "Parameters left after clone. Please see description."; return; } else { Carp::croak "$param is not exportable by " . __PACKAGE__; } } } sub get_backends { my $self = shift; my %backends = @BACKENDS; if ($ENV{CLONE_CHOOSE_PREFERRED_BACKEND}) { my $favourite = $ENV{CLONE_CHOOSE_PREFERRED_BACKEND}; Carp::croak "$favourite not found" unless $backends{$favourite}; %backends = ($favourite => $backends{$favourite}); } return keys %backends; } 1; __END__ =head1 NAME Clone::Choose - Choose appropriate clone utility =begin html Travis CI Coverage Status =end html =head1 SYNOPSIS use Clone::Choose; my $data = { value => 42, href => { set => [ 'foo', 'bar' ], value => 'baz', }, }; my $cloned_data = clone $data; # it's also possible to use Clone::Choose and pass a clone preference use Clone::Choose qw(:Storable); =head1 DESCRIPTION C checks several different modules which provides a C function and selects an appropriate one. The default preference is Clone Storable Clone::PP This list might evolve in future. Please see L how to pick a particular one. =head1 EXPORTS C exports C by default. One can explicitly import C by using use Clone::Choose qw(clone); or pick a particular C implementation use Clone::Choose qw(:Storable clone); The exported implementation is resolved dynamically, which means that any using module can either rely on the default backend preference or choose a particular one. It is also possible to select a particular C backend by setting the environment variable CLONE_CHOOSE_PREFERRED_BACKEND to your preferred backend. This also means, an already chosen import can't be modified like use Clone::Choose qw(clone :Storable); When one seriously needs different clone implementations, our I way to use them would be: use Clone::Choose (); # do not import my ($xs_clone, $st_clone); { local @Clone::Choose::BACKENDS = (Clone => "clone"); $xs_clone = Clone::Choose->can("clone"); } { local @Clone::Choose::BACKENDS = (Storable => "dclone"); $st_clone = Clone::Choose->can("clone"); } Don't misinterpret I - modifying C<@Clone::Choose::BACKENDS> has a lot of pitfalls and is unreliable beside such small examples. Do not hesitate open a request with an appropriate proposal for choosing implementations dynamically. The use of C<@Clone::Choose::BACKENDS> is discouraged and will be deprecated as soon as anyone provides a better idea. =head1 PACKAGE METHODS =head2 backend C tells the caller about the dynamic chosen backend: use Clone::Choose; say Clone::Choose->backend; # Clone This method currently exists for debug purposes only. =head2 get_backends C returns a list of the currently supported backends. =head1 AUTHOR Jens Rehsack Stefan Hermes =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Clone::Choose You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 LICENSE AND COPYRIGHT Copyright 2017 Jens Rehsack Copyright 2017 Stefan Hermes This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =head1 SEE ALSO L, L, L =cut