1#!./perl 2 3BEGIN { 4 chdir 't' if -d 't'; 5 require './test.pl'; 6 set_up_inc('../lib'); 7 require Config; 8 9 skip_all_without_config('useithreads'); 10 skip_all_if_miniperl("no dynamic loading on miniperl, no threads"); 11} 12 13use v5.36; 14use feature 'class'; 15no warnings 'experimental::class'; 16 17use threads; 18 19class Testcase1 { 20 field $x :param; 21 method x { return $x } 22} 23 24{ 25 my $ret = threads->create(sub { 26 pass("Created dummy thread"); 27 return 1; 28 })->join; 29 next_test(); # account for pass() inside thread 30 is($ret, 1, "Returned from dummy thread"); 31} 32 33{ 34 my $obj = Testcase1->new(x => 10); 35 threads->create(sub { 36 is($obj->x, 10, '$obj->x inside thread created before'); 37 })->join; 38 next_test(); # account for is() inside thread 39} 40 41threads->create(sub { 42 my $obj = Testcase1->new(x => 20); 43 is($obj->x, 20, '$obj->x created inside thread'); 44})->join; 45next_test(); # account for is() inside thread 46 47done_testing; 48