Move Test::Simple from lib to ext.
[p5sagit/p5-mst-13.2.git] / ext / 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
82d700dc 20use Test::More tests => 5;
7483b81c 21
22
23package Overloaded;
24
25use overload
26 q{""} => sub { $_[0]->{string} };
27
28sub new {
29 my $class = shift;
30 bless { string => shift }, $class;
31}
32
33
34package main;
35
36my $warnings = '';
37local $SIG{__WARN__} = sub { $warnings = join '', @_ };
38
39# overloaded object as name
40my $obj = Overloaded->new('foo');
41ok( 1, $obj );
42
43# overloaded object which returns undef as name
44my $undef = Overloaded->new(undef);
45pass( $undef );
46
47is( $warnings, '' );
48
49
50TODO: {
51 my $obj = Overloaded->new('not really todo, testing overloaded reason');
52 local $TODO = $obj;
53 fail("Just checking todo as an overloaded value");
54}
55
56
57SKIP: {
58 my $obj = Overloaded->new('not really skipped, testing overloaded reason');
59 skip $obj, 1;
60}