1use strict; 2 3use Test::More tests => 21; 4 5use lib 't'; 6use Run; 7 8require_ok('Exporter::Easiest'); 9 10{ 11 no strict 'refs'; 12 13 *{suck_list} = \&Exporter::Easiest::suck_list; 14 *{parse_spec} = \&Exporter::Easiest::parse_spec; 15} 16 17is_deeply(suck_list([qw(a b c d e)]), [qw( a b c d e )], "suck all"); 18is_deeply(suck_list([qw(a b c => e)]), [qw( a b )], "suck some"); 19 20is_deeply( 21 { 22 parse_spec(q( 23 a => a b c 24 )) 25 }, 26 { 27 a => [qw( a b c )], 28 }, 29 "parse 1" 30); 31 32is_deeply( 33 { 34 parse_spec(q( 35 a => a b c 36 b => g h i 37 )) 38 }, 39 { 40 a => [qw( a b c )], 41 b => [qw( g h i )], 42 }, 43 "parse 2" 44); 45 46is_deeply( 47 { 48 parse_spec(q( 49 a => 50 b => g h i 51 )) 52 }, 53 { 54 a => [], 55 b => [qw( g h i )], 56 }, 57 "parse with empty" 58); 59 60is_deeply( 61 { 62 parse_spec(q( 63 a => 64 :b => a b :c 65 :e => e f g 66 )) 67 }, 68 { 69 a => [], 70 TAGS => 71 [ 72 'b', [qw( a b :c )], 73 'e', [qw( e f g )], 74 ] 75 }, 76 "simple with :s" 77); 78 79is_deeply( 80 { 81 parse_spec(q( 82 b => a b 83 a => 84 :b => 85 :e => e f :g 86 :d => a 87 c => a :c 88 )) 89 }, 90 { 91 a => [], 92 TAGS => 93 [ 94 'b', [], 95 'e', [qw( e f :g )], 96 'd' => ['a'], 97 ], 98 b => [qw( a b )], 99 c => [qw( a :c)], 100 }, 101 "everything" 102); 103 104is_deeply( 105 { parse_spec(q(VARS => a b)) }, 106 { VARS => [qw( a b )] }, 107 "VARS list" 108); 109 110is_deeply( 111 { parse_spec(q(VARS => a)) }, 112 { VARS => [qw( a )] }, 113 "VARS list of 1" 114); 115is_deeply( 116 { parse_spec(q(VARS => 1)) }, 117 { VARS => 1 }, 118 "VARS 1" 119); 120 121is_deeply( 122 { parse_spec(q(VARS => 0)) }, 123 { VARS => 0 }, 124 "VARS 0" 125); 126 127is_deeply( 128 { parse_spec(q(ALL => all)) }, 129 { ALL => 'all' }, 130 "good ALL works" 131); 132 133eval {parse_spec(q(ALL => all other))}; 134ok($@, "bad all dies"); 135 136package Test::The::Use; 137 138use Exporter::Easiest q( 139 EXPORT => e_1 e_2 140 TAGS => 141 :tag1 => a b c d e f 142 :tag2 => b d f 143 :tag3 => :tag1 !:tag2 144 OK => o_1 o_2 145); 146 147use vars qw( @EXPORT @EXPORT_OK %EXPORT_TAGS ); 148 149::ok(::eq_set( \@EXPORT, [ qw( e_1 e_2)] ), "use EXPORT and TAGS"); 150::ok(::eq_set( \@EXPORT_OK ,[qw( a b c d e f o_1 o_2 )] ), "use OK with EXPORT and TAGS" 151); 152 153my %e = %EXPORT_TAGS; 154 155::ok(::eq_set( $e{tag1}, [qw( a b c d e f )] ), "use TAGS tag1"); 156::ok(::eq_set( $e{tag2}, [qw( b d f )] ), "use TAGS tag2"); 157::ok(::eq_set( $e{tag3}, [qw( a c e )] ), "use TAGS tag3"); 158::ok(keys(%e) == 3, "use TAGS count"); 159 160package Test::Vars; 161 162use Exporter::Easiest qw( OK => $Var ); 163 164::runs_ok('$Var', 'tag vars can use var $Var'); 165