5 if ($ENV{'PERL_CORE'}){
7 unshift @INC, '../lib';
10 if (! $Config{'useithreads'}) {
11 print("1..0 # Skip: Perl not compiled with 'useithreads'\n");
16 use ExtUtils::testlib;
19 my ($id, $ok, $name) = @_;
21 # You have to do it this way or VMS will get confused.
23 print("ok $id - $name\n");
25 print("not ok $id - $name\n");
26 printf("# Failed test at line %d\n", (caller)[2]);
34 print("1..37\n"); ### Number of tests that will be run ###
41 ### Start of Testing ###
43 my ($hobj, $aobj, $sobj) : shared;
47 my $sref = \do{ my $x };
58 $$aobj[0] = bless(&share({}), 'yin');
59 $$aobj[1] = bless(&share([]), 'yang');
62 $$hobj{'hash'} = bless(&share({}), 'yin');
63 $$hobj{'array'} = bless(&share([]), 'yang');
64 $$hobj{'scalar'} = $sobj;
68 # Test objects in child thread
69 ok(2, ref($hobj) eq 'foo', "hash blessing does work");
70 ok(3, ref($aobj) eq 'bar', "array blessing does work");
71 ok(4, ref($sobj) eq 'baz', "scalar blessing does work");
72 ok(5, $$sobj eq '3', "scalar contents okay");
74 ok(6, ref($$aobj[0]) eq 'yin', "blessed hash in array");
75 ok(7, ref($$aobj[1]) eq 'yang', "blessed array in array");
76 ok(8, ref($$aobj[2]) eq 'baz', "blessed scalar in array");
77 ok(9, ${$$aobj[2]} eq '3', "blessed scalar in array contents");
79 ok(10, ref($$hobj{'hash'}) eq 'yin', "blessed hash in hash");
80 ok(11, ref($$hobj{'array'}) eq 'yang', "blessed array in hash");
81 ok(12, ref($$hobj{'scalar'}) eq 'baz', "blessed scalar in hash");
82 ok(13, ${$$hobj{'scalar'}} eq '3', "blessed scalar in hash contents");
86 # Test objects in parent thread
87 ok(14, ref($hobj) eq 'foo', "hash blessing does work");
88 ok(15, ref($aobj) eq 'bar', "array blessing does work");
89 ok(16, ref($sobj) eq 'baz', "scalar blessing does work");
90 ok(17, $$sobj eq '3', "scalar contents okay");
92 ok(18, ref($$aobj[0]) eq 'yin', "blessed hash in array");
93 ok(19, ref($$aobj[1]) eq 'yang', "blessed array in array");
94 ok(20, ref($$aobj[2]) eq 'baz', "blessed scalar in array");
95 ok(21, ${$$aobj[2]} eq '3', "blessed scalar in array contents");
97 ok(22, ref($$hobj{'hash'}) eq 'yin', "blessed hash in hash");
98 ok(23, ref($$hobj{'array'}) eq 'yang', "blessed array in hash");
99 ok(24, ref($$hobj{'scalar'}) eq 'baz', "blessed scalar in hash");
100 ok(25, ${$$hobj{'scalar'}} eq '3', "blessed scalar in hash contents");
108 my $data = $$aobj[0];
115 $data = $$hobj{'hash'};
117 $$hobj{'hash'} = $data;
118 $data = $$hobj{'array'};
120 $$hobj{'array'} = $data;
126 ok(26, ref($hobj) eq 'oof', "hash reblessing does work");
127 ok(27, ref($aobj) eq 'rab', "array reblessing does work");
128 ok(28, ref($sobj) eq 'zab', "scalar reblessing does work");
129 ok(29, $$sobj eq 'test', "scalar contents okay");
131 ok(30, ref($$aobj[0]) eq 'niy', "reblessed hash in array");
132 ok(31, ref($$aobj[1]) eq 'gnay', "reblessed array in array");
133 ok(32, ref($$aobj[2]) eq 'zab', "reblessed scalar in array");
134 ok(33, ${$$aobj[2]} eq 'test', "reblessed scalar in array contents");
136 ok(34, ref($$hobj{'hash'}) eq 'niy', "reblessed hash in hash");
137 ok(35, ref($$hobj{'array'}) eq 'gnay', "reblessed array in hash");
138 ok(36, ref($$hobj{'scalar'}) eq 'zab', "reblessed scalar in hash");
139 ok(37, ${$$hobj{'scalar'}} eq 'test', "reblessed scalar in hash contents");