Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update thread.t for API change.
  • Loading branch information
jnthn committed Oct 31, 2013
1 parent 1f4fd4a commit 6f65a8b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions S17-concurrency/thread.t
Expand Up @@ -4,13 +4,13 @@ use Test;
plan 19;

{
my $t = Thread.start({ 1 });
my $t = Thread.run({ 1 });
isa_ok $t, Thread;
$t.join();
}

{
my $t = Thread.start({
my $t = Thread.run({
pass "Code in thread ran";
});
$t.join();
Expand All @@ -19,7 +19,7 @@ plan 19;

{
my $tracker;
my $t = Thread.start({
my $t = Thread.run({
$tracker = "in thread,";
});
$t.join();
Expand All @@ -32,14 +32,14 @@ plan 19;
# at the exact wrong time. Also, if this test file hangs for ages at exit,
# something is probably wrong with regard to this test.
my $start = now;
my $alt = Thread.start({ sleep 10000 }, :app_lifetime);
my $alt = Thread.run({ sleep 10000 }, :app_lifetime);
ok now - $start < 10, "Starting app_lifetime thread that sleeps won't block main thread";
}

{
my ($a, $b);
my $t1 = Thread.start({ $a = 21 });
my $t2 = Thread.start({ $b = 42 });
my $t1 = Thread.run({ $a = 21 });
my $t2 = Thread.run({ $b = 42 });
isnt $t1.id, 0, "Thread 1 got non-zero ID";
isnt $t2.id, 0, "Thread 2 got non-zero ID";
isnt $t1.id, $t2.id, "Threads got different IDs";
Expand All @@ -50,33 +50,33 @@ plan 19;
}

{
my $t = Thread.start(:name("My little thready"), { 1 });
my $t = Thread.run(:name("My little thready"), { 1 });
is $t.name, "My little thready", "Has correct name";
$t.join();
is $t.name, "My little thready", "Name doesn't vanish after joining";
}

{
my $t = Thread.start({ 1 });
my $t = Thread.run({ 1 });
is $t.name, "<anon>", "Default thread name is <anon>";
$t.join();
}

{
my $t1 = Thread.start({ 1 });
my $t1 = Thread.run({ 1 });
ok $t1.Str ~~ /^ Thread '<' \d+ '>' '(<anon>)' $/,
"Correct Thread stringification (anon case)";
$t1.join();
my $t2 = Thread.start(:name('Magical threader'), { 1 });
my $t2 = Thread.run(:name('Magical threader'), { 1 });
ok $t2.Str ~~ /^ Thread '<' \d+ '>' '(Magical threader)' $/,
"Correct Thread stringification (name case)";
$t2.join();
}

{
my ($t1id, $t2id);
my $t1 = Thread.start({ $t1id = $*THREAD.id; });
my $t2 = Thread.start({ $t2id = $*THREAD.id; });
my $t1 = Thread.run({ $t1id = $*THREAD.id; });
my $t2 = Thread.run({ $t2id = $*THREAD.id; });
$t1.join();
$t2.join();
is $t1id, $t1.id, 'Correct $*THREAD instance in thread 1';
Expand Down

0 comments on commit 6f65a8b

Please sign in to comment.