source: trunk/essentials/dev-lang/perl/ext/Storable/t/code.t

Last change on this file was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 7.0 KB
Line 
1#!./perl
2#
3# Copyright (c) 2002 Slaven Rezic
4#
5# You may redistribute only under the same terms as Perl 5, as specified
6# in the README file that comes with the distribution.
7#
8
9sub BEGIN {
10 if ($ENV{PERL_CORE}){
11 chdir('t') if -d 't';
12 @INC = ('.', '../lib');
13 } else {
14 unshift @INC, 't';
15 }
16 require Config; import Config;
17 if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bStorable\b/) {
18 print "1..0 # Skip: Storable was not built\n";
19 exit 0;
20 }
21}
22
23use strict;
24BEGIN {
25 if (!eval q{
26 use Test;
27 use B::Deparse 0.61;
28 use 5.006;
29 1;
30 }) {
31 print "1..0 # skip: tests only work with B::Deparse 0.61 and at least perl 5.6.0\n";
32 exit;
33 }
34 require File::Spec;
35 if ($File::Spec::VERSION < 0.8) {
36 print "1..0 # Skip: newer File::Spec needed\n";
37 exit 0;
38 }
39}
40
41BEGIN { plan tests => 59 }
42
43use Storable qw(retrieve store nstore freeze nfreeze thaw dclone);
44use Safe;
45
46#$Storable::DEBUGME = 1;
47
48use vars qw($freezed $thawed @obj @res $blessed_code);
49
50$blessed_code = bless sub { "blessed" }, "Some::Package";
51{ package Another::Package; sub foo { __PACKAGE__ } }
52
53{
54 no strict; # to make the life for Safe->reval easier
55 sub code { "JAPH" }
56}
57
58local *FOO;
59
60@obj =
61 ([\&code, # code reference
62 sub { 6*7 },
63 $blessed_code, # blessed code reference
64 \&Another::Package::foo, # code in another package
65 sub ($$;$) { 0 }, # prototypes
66 sub { print "test\n" },
67 \&Test::ok, # large scalar
68 ],
69
70 {"a" => sub { "srt" }, "b" => \&code},
71