Clear up test based on line number differences between the core and the
[p5sagit/p5-mst-13.2.git] / lib / Test / Simple / t / overload_threads.t
CommitLineData
7483b81c 1#!perl -w
2
3BEGIN {
4 if( $ENV{PERL_CORE} ) {
5 chdir 't';
6 @INC = ('../lib', 'lib');
7 }
8 else {
9 unshift @INC, 't/lib';
10 }
11}
12chdir 't';
13
14BEGIN {
15 # There was a bug with overloaded objects and threads.
16 # See rt.cpan.org 4218
17 eval { require threads; 'threads'->import; 1; };
18}
19
20use Test::More;
21
22BEGIN {
23 if( !eval "require overload" ) {
24 plan skip_all => "needs overload.pm";
25 }
26 else {
27 plan tests => 5;
28 }
29}
30
31
32package Overloaded;
33
34use overload
35 q{""} => sub { $_[0]->{string} };
36
37sub new {
38 my $class = shift;
39 bless { string => shift }, $class;
40}
41
42
43package main;
44
45my $warnings = '';
46local $SIG{__WARN__} = sub { $warnings = join '', @_ };
47
48# overloaded object as name
49my $obj = Overloaded->new('foo');
50ok( 1, $obj );
51
52# overloaded object which returns undef as name
53my $undef = Overloaded->new(undef);
54pass( $undef );
55
56is( $warnings, '' );
57
58
59TODO: {
60 my $obj = Overloaded->new('not really todo, testing overloaded reason');
61 local $TODO = $obj;
62 fail("Just checking todo as an overloaded value");
63}
64
65
66SKIP: {
67 my $obj = Overloaded->new('not really skipped, testing overloaded reason');
68 skip $obj, 1;
69}