Skip to content

Commit a51de99

Browse files
committed
test the code in phasers doc.
Part of #1387
1 parent fdcab66 commit a51de99

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

doc/Language/phasers.pod6

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ them respond to various control exceptions and exit values.
1919
2020
Here is a summary:
2121
22+
=begin code :skip-test
2223
BEGIN {...} # * at compile time, ASAP, only ever runs once
2324
CHECK {...} # * at compile time, ALAP, only ever runs once
2425
INIT {...} # * at run time, ASAP, only ever runs once
@@ -44,19 +45,20 @@ Here is a summary:
4445
4546
COMPOSE {...} # when a role is composed into a class
4647
CLOSE {...} # appears in a supply block, called when the supply is closed
48+
=end code
4749
4850
Phasers marked with a C<*> have a run-time value, and if evaluated earlier than
4951
their surrounding expression, they simply save their result for use in the
5052
expression later when the rest of the expression is evaluated:
5153
5254
my $compiletime = BEGIN { now };
53-
our $temphandle = ENTER { maketemp() };
55+
our $random = ENTER { rand };
5456
5557
As with other statement prefixes, these value-producing constructs may be
5658
placed in front of either a block or a statement:
5759
5860
my $compiletime = BEGIN now;
59-
our $temphandle = ENTER maketemp();
61+
our $random = ENTER rand;
6062
6163
Most of these phasers will take either a block or a function reference. The
6264
statement form can be particularly useful to expose a lexically scoped
@@ -67,12 +69,11 @@ These declare the same variables with the same scope as the preceding example,
6769
but run the statements as a whole at the indicated time:
6870
6971
BEGIN my $compiletime = now;
70-
ENTER our $temphandle = maketemp();
72+
ENTER our $random = rand;
7173
7274
(Note, however, that the value of a variable calculated at compile time may not
7375
persist under run-time cloning of any surrounding closure.)
7476
75-
7677
Most of the non-value-producing phasers may also be so used:
7778
7879
END say my $accumulator;
@@ -117,55 +118,66 @@ teardown usually want to happen in the opposite order from each other.
117118
118119
=head2 Execution Order
119120
120-
Compilation Begins
121+
Compilation Begins
121122
123+
=for code :skip-test
122124
BEGIN {...} # at compile time, ASAP, only ever runs once
123125
CHECK {...} # at compile time, ALAP, only ever runs once
124126
COMPOSE {...} # when a role is composed into a class
125127
126-
Execution Begins
128+
Execution Begins
127129
130+
=for code :skip-test
128131
INIT {...} # at run time, ASAP, only ever runs once
129132
130-
Before block execution begins
133+
Before block execution begins
131134
135+
=for code :skip-test
132136
PRE {...} # assert precondition at every block entry, before ENTER
133137
134-
Loop execution begins
138+
Loop execution begins
135139
140+
=for code :skip-test
136141
FIRST {...} # at loop initialization time, before any ENTER
137142
138-
Block execution begins
143+
Block execution begins
139144
145+
=for code :skip-test
140146
ENTER {...} # at every block entry time, repeats on loop blocks.
141147
142-
Exception maybe happens
148+
Exception maybe happens
143149
150+
=for code :skip-test
144151
CATCH {...} # catch exceptions, before LEAVE
145152
CONTROL {...} # catch control exceptions, before LEAVE
146153
147-
End of loop, either continuing or finished
154+
End of loop, either continuing or finished
148155
156+
=for code :skip-test
149157
NEXT {...} # at loop continuation time, before any LEAVE
150158
LAST {...} # at loop termination time, after any LEAVE
151159
152-
End of block
160+
End of block
153161
162+
=for code :skip-test
154163
LEAVE {...} # at every block exit time (even stack unwinds from exceptions)
155164
KEEP {...} # at every successful block exit, part of LEAVE queue
156165
UNDO {...} # at every unsuccessful block exit, part of LEAVE queue
157166
158-
Postcondition for block
167+
Postcondition for block
159168
169+
=for code :skip-test
160170
POST {...} # assert postcondition at every block exit, after LEAVE
161171
162-
Async whenever-block is complete
172+
Async whenever-block is complete
163173
174+
=for code :skip-test
164175
LAST {...} # if ended normally with done, runs once after block
165176
QUIT {...} # catch async exceptions
166177
167-
Program terminating
178+
Program terminating
168179
180+
=for code :skip-test
169181
END {...} # at run time, ALAP, only ever runs once
170182
171183
=head1 Program Execution Phasers

xt/examples-compilation.t

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ if @*ARGS {
2929
doc/Language/5to6-perlfunc.pod6
3030
doc/Language/5to6-perlop.pod6
3131
doc/Language/modules.pod6
32-
doc/Language/phasers.pod6
3332
doc/Language/pod.pod6
3433
doc/Language/tables.pod6
3534
>);

0 commit comments

Comments
 (0)