root/lang/perl/DBIx-Class-FromValidators/trunk/inc/Test/Builder/Module.pm @ 1808

Revision 1808, 1.2 kB (checked in by woremacx, 6 years ago)

lang/perl/DBIx-Class-FromValidators?: fixes around packaging

Line 
1#line 1
2package Test::Builder::Module;
3
4use Test::Builder;
5
6require Exporter;
7@ISA = qw(Exporter);
8
9$VERSION = '0.02';
10
11use strict;
12
13# 5.004's Exporter doesn't have export_to_level.
14my $_export_to_level = sub {
15      my $pkg = shift;
16      my $level = shift;
17      (undef) = shift;                  # redundant arg
18      my $callpkg = caller($level);
19      $pkg->export($callpkg, @_);
20};
21
22
23#line 82
24
25sub import {
26    my($class) = shift;
27
28    my $test = $class->builder;
29
30    my $caller = caller;
31
32    $test->exported_to($caller);
33
34    $class->import_extra(\@_);
35    my(@imports) = $class->_strip_imports(\@_);
36
37    $test->plan(@_);
38
39    $class->$_export_to_level(1, $class, @imports);
40}
41
42
43sub _strip_imports {
44    my $class = shift;
45    my $list  = shift;
46
47    my @imports = ();
48    my @other   = ();
49    my $idx = 0;
50    while( $idx <= $#{$list} ) {
51        my $item = $list->[$idx];
52
53        if( defined $item and $item eq 'import' ) {
54            push @imports, @{$list->[$idx+1]};
55            $idx++;
56        }
57        else {
58            push @other, $item;
59        }
60
61        $idx++;
62    }
63
64    @$list = @other;
65
66    return @imports;
67}
68
69
70#line 144
71
72sub import_extra {}
73
74
75#line 175
76
77sub builder {
78    return Test::Builder->new;
79}
80
81
821;
Note: See TracBrowser for help on using the browser.