This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Test-Simple to CPAN version 0.96
[perl5.git] / cpan / Test-Simple / t / use_ok.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = qw(../lib ../lib/Test/Simple/t/lib);
7     }
8     else {
9         unshift @INC, 't/lib';
10     }
11 }
12
13 use Test::More tests => 15;
14
15 # Using Symbol because it's core and exports lots of stuff.
16 {
17     package Foo::one;
18     ::use_ok("Symbol");
19     ::ok( defined &gensym,        'use_ok() no args exports defaults' );
20 }
21
22 {
23     package Foo::two;
24     ::use_ok("Symbol", qw(qualify));
25     ::ok( !defined &gensym,       '  one arg, defaults overridden' );
26     ::ok( defined &qualify,       '  right function exported' );
27 }
28
29 {
30     package Foo::three;
31     ::use_ok("Symbol", qw(gensym ungensym));
32     ::ok( defined &gensym && defined &ungensym,   '  multiple args' );
33 }
34
35 {
36     package Foo::four;
37     my $warn; local $SIG{__WARN__} = sub { $warn .= shift; };
38     ::use_ok("constant", qw(foo bar));
39     ::ok( defined &foo, 'constant' );
40     ::is( $warn, undef, 'no warning');
41 }
42
43 {
44     package Foo::five;
45     ::use_ok("Symbol", 1.02);
46 }
47
48 {
49     package Foo::six;
50     ::use_ok("NoExporter", 1.02);
51 }
52
53 {
54     package Foo::seven;
55     local $SIG{__WARN__} = sub {
56         # Old perls will warn on X.YY_ZZ style versions.  Not our problem
57         warn @_ unless $_[0] =~ /^Argument "\d+\.\d+_\d+" isn't numeric/;
58     };
59     ::use_ok("Test::More", 0.47);
60 }
61
62 {
63     package Foo::eight;
64     local $SIG{__DIE__};
65     ::use_ok("SigDie");
66     ::ok(defined $SIG{__DIE__}, '  SIG{__DIE__} preserved');
67 }