Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test
hyper for
, race for
, and for
semantics
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use v6; | ||
use Test; | ||
|
||
plan 6; | ||
|
||
{ | ||
my \rs = (^10000).race.map(* + 1); | ||
my $main-thread = $*THREAD.id; | ||
my $saw-another-thread = False; | ||
for rs { | ||
$saw-another-thread = True if $*THREAD.id != $main-thread; | ||
} | ||
nok $saw-another-thread, 'Plain for loop sequentially iterates a RaceSeq'; | ||
} | ||
|
||
{ | ||
my \hs = (^10000).hyper.map(* + 1); | ||
my $main-thread = $*THREAD.id; | ||
my $saw-another-thread = False; | ||
for hs { | ||
$saw-another-thread = True if $*THREAD.id != $main-thread; | ||
} | ||
nok $saw-another-thread, 'Plain for loop sequentially iterates a HyperSeq'; | ||
} | ||
|
||
{ | ||
my \rs = (^10000).race.map(* + 1); | ||
my $main-thread = $*THREAD.id; | ||
my $saw-another-thread = False; | ||
$saw-another-thread = True if $*THREAD.id != $main-thread for rs; | ||
nok $saw-another-thread, 'Plain postfix for loop sequentially iterates a RaceSeq'; | ||
} | ||
|
||
{ | ||
my \hs = (^10000).hyper.map(* + 1); | ||
my $main-thread = $*THREAD.id; | ||
my $saw-another-thread = False; | ||
$saw-another-thread = True if $*THREAD.id != $main-thread for hs; | ||
nok $saw-another-thread, 'Plain postfix for loop sequentially iterates a HyperSeq'; | ||
} | ||
|
||
{ | ||
my $main-thread = $*THREAD.id; | ||
my $saw-another-thread = False; | ||
race for ^10000 { | ||
$saw-another-thread = True if $*THREAD.id != $main-thread; | ||
} | ||
ok $saw-another-thread, 'A race for loop runs the body over threads'; | ||
} | ||
|
||
{ | ||
my $main-thread = $*THREAD.id; | ||
my $saw-another-thread = False; | ||
hyper for ^10000 { | ||
$saw-another-thread = True if $*THREAD.id != $main-thread; | ||
} | ||
ok $saw-another-thread, 'A hyper for loop runs the body over threads'; | ||
} |