Skip to content

Commit 7cc795c

Browse files
committed
Better tag some skip-tests, and allow some to run
1 parent 6fd1a1f commit 7cc795c

File tree

9 files changed

+59
-53
lines changed

9 files changed

+59
-53
lines changed

doc/Language/5to6-perlfunc.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ much as possible.
13371337
13381338
These survive the transition to Perl 6. Some notes:
13391339
1340-
=for code :skip-test
1340+
=for code :lang<perl5>
13411341
q/.../; # is still equivalent to using single quotes.
13421342
qq/.../; # is still equivalent to using double quotes.
13431343
qw/.../; # is more commonly rendered as C<< <...> >> in Perl 6.

doc/Language/glossary.pod6

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ normally need to use some operator (e.g. C</> for L<Rat> or C<+> for
9494
L<Complex>). This allows you to use such literals in places where
9595
expressions are not allowed, for example, as literals in signatures:
9696
97-
=for code :skip-test
97+
=for code :skip-test<syntax error>
9898
# Wrong, can't use an operator there:
9999
multi foo (1/3) { say "It's one third!" }
100100
=for code
@@ -131,7 +131,7 @@ that name:
131131
# anonymous, but knows its own name
132132
my $s = anon sub triple($x) { 3 * $x }
133133
say $s.name; # OUTPUT: «triple␤»
134-
=for code :skip-test
134+
=for code :skip-test<error>
135135
say triple(42); # OUTPUT: «Undeclared routine: triple␤»
136136
137137
X<|API>
@@ -157,11 +157,11 @@ X<|Arity>
157157
The number of L<positional|/type/Positional> operands expected by an
158158
L<operator|#Operator>, subroutine, method or callable block.
159159
160-
=begin code :preamble<class Foo {};>
160+
=begin code :preamble<class Foo {}>
161161
sub infix:<+>(Foo $a, Foo $b) { $a.Int + $b.Int } # arity of "+" is 2
162162
sub frobnicate($x) { ... } # arity of 1
163163
sub the-answer() { 42 } # arity of 0
164-
-> $key, $value { ... } # arity of 2
164+
-> $key, $value { ... } # arity of 2
165165
=end code
166166
167167
The arity of a C<Callable> is one of the main selectors in
@@ -279,12 +279,14 @@ Finally, if there is a variable with the same name as an intended adverbial
279279
pair, you don't have to specify the name twice, but just specify the adverb
280280
with the appropriate sigil:
281281
282-
=begin code :skip-test
283-
:$foo # same as foo => $foo
284-
:@bar # same as bar => @bar
285-
:%mapper # same as mapper => %mapper
286-
:&test # same as test => &test
287-
=end code
282+
=begin table
283+
variable only | same as
284+
================|==============
285+
:$foo | foo => $foo
286+
:@bar | bar => @bar
287+
:%mapper | mapper => %mapper
288+
:&test | test => &test
289+
=end table
288290
289291
See also L<#Adverb>.
290292

doc/Language/haskell-to-p6.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ and Undefined objects. Plain type objects are undefined while instantiated objec
8080
8181
So in Perl 6 we have type constraints that indicate the definedness of a type. These are
8282
83-
=begin code :skip-test
83+
=begin code
8484
Int:D; # This is a defined Int.
8585
Int:U; # This is an undefined Int, AKA a type object
8686
Int:_; # This is either defined or undefined.

doc/Language/ipc.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ you will want to make use of L<Proc::Async|/type/Proc::Async>. This class
7070
provides support for asynchronous communication with a program, as well as the
7171
ability to send signals to that program.
7272
73-
=begin code :skip-test
73+
=begin code
7474
# Get ready to run the program
7575
my $log = Proc::Async.new('tail', '-f', '/var/log/system.log');
7676
$log.stdout.tap(-> $buf { print $buf });

doc/Language/list.pod6

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ with parentheses, so:
2323
2424
There is one exception, empty lists are created with just parenthesis:
2525
26-
=for code :skip-test
26+
=for code
2727
(); # This is an empty List
28+
=for code :skip-test<syntax error>
2829
(,); # This is a syntax error
2930
3031
Note that hanging commas are just fine as long as the beginning and
@@ -69,13 +70,14 @@ use a sigil before the parenthesis:
6970
Individual elements can be pulled out of a list using a subscript. The
7071
first element of a list is at index number zero:
7172
72-
=begin code :skip-test
73+
=for code
7374
say (1, 2)[0]; # says 1
7475
say (1, 2)[1]; # says 2
7576
say (1, 2)[2]; # says Nil
77+
=for code :skip-test<syntax error>
7678
say (1, 2)[-1]; # Error
79+
=for code
7780
say ((<a b>,<c d>),(<e f>,<g h>))[1;0;1]; # says "f"
78-
=end code
7981
8082
=head1 The @ sigil
8183
@@ -544,7 +546,7 @@ Given the following sub declaration:
544546
545547
Calls that pass an Array[Int] will be successful:
546548
547-
=begin code :skip-test
549+
=begin code :preamble<sub mean(Int @a) {}>
548550
my Int @b = 1, 3, 5;
549551
say mean(@b); # @b is Array[Int]
550552
say mean(Array[Int].new(1, 3, 5)); # Anonymous Array[Int]
@@ -555,7 +557,7 @@ However, the following calls will all fail, due to passing an untyped array,
555557
even if the array just happens to contain Int values at the point it is
556558
passed:
557559
558-
=begin code :skip-test
560+
=begin code :skip-test<compilation errors>
559561
my @c = 1, 3, 5;
560562
say mean(@c); # Fails, passing untyped Array
561563
say mean([1, 3, 5]); # Same
@@ -566,7 +568,7 @@ Note that in any given compiler, there may be fancy, under-the-hood, ways to
566568
bypass the type check on arrays, so when handling untrusted input, it can be
567569
good practice to perform additional type checks, where it matters:
568570
569-
=begin code :skip-test
571+
=begin code :preamble<my @a;my $i>
570572
for @a -> Int $i { $_++.say };
571573
=end code
572574

doc/Language/operators.pod6

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ L<common mistake|/language/traps#Using_»_and_map_interchangeably> of expecting
724724
side-effects to occur in order. The following C<say> is B<not>
725725
guaranteed to produce the output in order:
726726
727-
=begin code :skip-test
727+
=begin code :preamble<my @a>
728728
@a».say; # WRONG! Could produce a␤b␤c␤ or c␤b␤a␤ or any other order
729729
=end code
730730
@@ -1016,11 +1016,12 @@ replacing the resulting value in the left-side container.
10161016
In most cases, this behaves identically to the postfix mutator, but the
10171017
precedence is lower:
10181018
1019-
=for code :skip-test
1020-
my $a = -5
1021-
say ++$a.=abs
1019+
=for code
1020+
my $a = -5;
1021+
say ++$a.=abs;
10221022
# OUTPUT: «6␤»
1023-
say ++$a .= abs
1023+
=for code :skip-test<error>
1024+
say ++$a .= abs;
10241025
# OUTPUT: «Cannot modify an immutable Int␤
10251026
# in block <unit> at <tmp> line 1␤␤»
10261027
@@ -1360,7 +1361,7 @@ restored to its original value.
13601361
13611362
You can also assign immediately as part of the call to temp:
13621363
1363-
=begin code :skip-test
1364+
=begin code :preamble<my $a>
13641365
temp $a = "five";
13651366
=end code
13661367
@@ -1887,8 +1888,7 @@ this operator is not arithmetically symmetrical (doesn't do ± Δ):
18871888
18881889
The tolerance is supposed to be modifiable via an adverb:
18891890
1890-
=comment RT #128210
1891-
=begin code :skip-test
1891+
=begin code :skip-test<RT #128210>
18921892
my ($x, $y) = 42, 42.1;
18931893
say $x =~= $y :tolerance(.1);
18941894
=end code

doc/Language/rb-nutshell.pod6

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ coding styles:
7171
=begin item
7272
I<No space allowed before the opening parenthesis of an argument list.>
7373
74-
=begin code :skip-test
74+
=begin code :skip-test<error>
7575
foo (3, 4, 1); # Not right in Ruby or Perl 6 (in Perl 6 this would
7676
# try to pass a single argument of type List to foo)
7777
=end code
@@ -362,17 +362,19 @@ L<Captures|/type/Capture>.
362362
Perl 6 additionally uses "twigils", which are further indicators about the
363363
variable and go between the sigil and the rest of the variable name. Examples:
364364
365-
=begin code :skip-test
366-
$foo # Scalar with no twigil
367-
$!foo # Private instance variable
368-
$.foo # Instance variable accessor
369-
$*foo # Dynamically scoped variable
370-
$^foo # A positional (placeholder) parameter to a block
371-
$:foo # A named (placeholder) parameter to a block
372-
$=foo # POD (documentation) variables
373-
$?FILE # Current source filename. The ? twigil indicates a compile-time value
374-
$~foo # Sublanguage seen by parser, uncommon
375-
=end code
365+
=begin table
366+
Variable | Description
367+
=========|============
368+
$foo | Scalar with no twigil
369+
$!foo | Private instance variable
370+
$.foo | Instance variable accessor
371+
$*foo | Dynamically scoped variable
372+
$^foo | A positional (placeholder) parameter to a block
373+
$:foo | A named (placeholder) parameter to a block
374+
$=foo | POD (documentation) variables
375+
$?FILE | Current source filename. The ? twigil indicates a compile-time value
376+
$~foo | Sublanguage seen by parser, uncommon
377+
=end table
376378
377379
Though each of these examples use the C<$> sigil, most could use C<@>
378380
(Positional) or C<%> (Associative).
@@ -393,7 +395,7 @@ Perl 6 has I<colon-pair> syntax, which can sometimes look like Ruby symbols.
393395
=for code :lang<ruby>
394396
:age # Ruby symbol
395397
396-
=begin code :skip-test
398+
=begin code
397399
# All of these are equivalent for Perl 6
398400
:age ;# Perl 6 pair with implicit True value
399401
:age(True) ;# Perl 6 pair with explicit True value
@@ -480,7 +482,7 @@ See L<S03/Smartmatching|https://design.perl6.org/S03.html#Smart_matching> for mo
480482
In Perl 6, these single-character ops have been removed, and replaced by
481483
two-character ops which coerce their arguments to the needed context.
482484
483-
=begin code :skip-test
485+
=begin code :lang<text>
484486
# Infix ops (two arguments; one on each side of the op)
485487
+& +| +^ And Or Xor: Numeric
486488
~& ~| ~^ And Or Xor: String
@@ -1046,7 +1048,7 @@ $ PERL6LIB="/some/module/lib" perl6 program.p6
10461048
As with Ruby, if you don't specify C<PERL6LIB>, you need to specify the
10471049
library path within the program via the C<use lib> pragma:
10481050
1049-
=for code :skip-test
1051+
=for code :skip-test<can't use lib here>
10501052
# Ruby and Perl 6
10511053
use lib '/some/module/lib';
10521054
@@ -1062,18 +1064,18 @@ C<is export> role on the relevant subs and I<all> subs with this role are
10621064
then exported. Hence, the following module C<Bar> exports the subs C<foo>
10631065
and C<bar> but not C<baz>:
10641066
1065-
=for code :skip-test
1067+
=for code :skip-test<can't unit here>
10661068
unit module Bar; # remainder of the file is in module Bar { ... }
10671069
1068-
=for code :skip-test
1070+
=for code
10691071
sub foo($a) is export { say "foo $a" }
10701072
sub bar($b) is export { say "bar $b" }
10711073
sub baz($z) { say "baz $z" }
10721074
10731075
To use this module, simply C<use Bar> and the functions C<foo> and C<bar>
10741076
will be available:
10751077
1076-
=for code :skip-test
1078+
=for code :skip-test<can't use>
10771079
use Bar;
10781080
foo(1); #=> "foo 1"
10791081
bar(2); #=> "bar 2"
@@ -1082,7 +1084,7 @@ If you try to use C<baz> an "Undeclared routine" error is raised at compile time
10821084
10831085
Some modules allow for selectively importing functions, which would look like:
10841086
1085-
=begin code :skip-test
1087+
=begin code :skip-test<can't use>
10861088
use Bar <foo>; # Import only foo
10871089
foo(1); #=> "foo 1"
10881090
bar(2); # Error!

doc/Programs/02-reading-docs.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ p6doc [switches] [arguments]
2626
2727
With no switches or arguments, C<p6doc> lists its help to C<$*OUT> (C<stdout>):
2828
29-
=begin code :skip-test
29+
=begin code :lang<output>
3030
You want to maintain the index?
3131
To build an index for 'p6doc -f'
3232
p6doc build

doc/Type/Buf.pod6

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Adds elements at the end of the buffer
118118
119119
Extracts the last element of the buffer
120120
121-
=for code :skip-test
121+
=for code :preamble<my $bú>
122122
say $bú.pop(); # OUTPUT: «8»
123123
say $bú.perl; # OUTPUT: «Buf.new(1,1,2,3,5)»
124124
@@ -128,7 +128,7 @@ Extracts the last element of the buffer
128128
129129
Appends at the end of the buffer
130130
131-
=for code :skip-test
131+
=for code :preamble<my $bú; my @φ>
132132
$bú.append( @φ[5..10] );
133133
say $bú.perl; # OUTPUT: «Buf.new(1,1,2,3,5,8,13,21,34,55,89)»
134134
@@ -138,7 +138,7 @@ Appends at the end of the buffer
138138
139139
Adds elements at the beginning of the buffer
140140
141-
=for code :skip-test
141+
=for code :preamble<my $bú>
142142
$bú.prepend( 0 );
143143
say $bú.perl; # OUTPUT: «Buf.new(0,1,1,2,3,5,8,13,21,34,55,89)»
144144
@@ -148,7 +148,7 @@ Adds elements at the beginning of the buffer
148148
149149
Takes out the first element of the buffer
150150
151-
=for code :skip-test
151+
=for code :preamble<my $bú>
152152
$bú.shift();
153153
say $bú.perl; # OUTPUT: «Buf.new(1,1,2,3,5,8,13,21,34,55,89)»
154154
@@ -158,7 +158,7 @@ Takes out the first element of the buffer
158158
159159
Adds elements at the beginning of the buffer
160160
161-
=for code :skip-test
161+
=for code :preamble<my $bú>
162162
$bú.unshift( 0 );
163163
say $bú.perl; # OUTPUT: «Buf.new(0,1,1,2,3,5,8,13,21,34,55,89)»
164164
@@ -168,7 +168,7 @@ Adds elements at the beginning of the buffer
168168
169169
Substitutes elements of the buffer by other elements
170170
171-
=for code :skip-test
171+
=for code :preamble<my $bú>
172172
$bú.splice: 0, 3, <3 2 1>;
173173
say $bú.perl; # OUTPUT: «Buf.new(3,2,1,2,3,5,8,13,21,34,55,89)»
174174

0 commit comments

Comments
 (0)