File: 20dump.t

package info (click to toggle)
libxml-compile-dumper-perl 0.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 88 kB
  • sloc: perl: 164; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 829 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env perl

use warnings;
use strict;

use lib 'lib', 't';
#use TestTools;

use XML::Compile::Dumper;

use Test::More tests => 7;

my $testfile = 't/dump.pm';
my $package  = 't::dump';

unlink $testfile;

my $save = XML::Compile::Dumper->new
 ( filename => $testfile
 , package  => $package
 );

my $x = 'earth';
$save->freeze
 ( aap  => sub {42}    # simple
 , noot => sub {$x}    # closure
 );

$save->close;
ok(-f $testfile, 'dumpfile created');
cmp_ok(-s $testfile, '>', 290, 'some contents found');

eval "require $package";
is("$@", '', 'no parse errors');

$package->import;
{
   no strict 'refs';
   ok(defined *{"main::aap" }{CODE}, 'found aap');
   ok(defined *{"main::noot"}{CODE}, 'found noot');
}

cmp_ok(aap(),  "==",  42,      'call aap' );
cmp_ok(noot(), "cmp", 'world', 'call noot');

unlink $testfile;