Skip to content

Commit 6fd1a1f

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

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

doc/Language/5to6-nutshell.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1526,7 +1526,7 @@ C<is export> role on the relevant subs and I<all> subs with this role are
15261526
then exported. Hence, the following module C<Bar> exports the subs C<foo>
15271527
and C<bar> but not C<baz>:
15281528
1529-
=begin code :skip-test
1529+
=begin code :skip-test<unit>
15301530
unit module Bar;
15311531
15321532
sub foo($a) is export { say "foo $a" }

doc/Language/classtut.pod6

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ possible to predict the moment when attribute initialization will be executed,
316316
because it can take place during compilation, runtime or both, especially when
317317
importing the class using the L<use|/syntax/use> keyword.
318318
319-
=begin code :skip-test
319+
=begin code :preamble<class Foo {}; sub some_complicated_subroutine {}>
320320
class HaveStaticAttr {
321321
my Foo $.foo = some_complicated_subroutine;
322322
}
@@ -493,7 +493,7 @@ After creating a class, you can create instances of the class. Declaring a
493493
custom constructor provides a simple way of declaring tasks along with their
494494
dependencies. To create a single task with no dependencies, write:
495495
496-
=for code :skip-test
496+
=for code :preamble<class Task {}>
497497
my $eat = Task.new({ say 'eating dinner. NOM!' });
498498
499499
An earlier section explained that declaring the class C<Task> installed a
@@ -505,7 +505,7 @@ modifying or accessing an existing object.
505505
506506
Unfortunately, dinner never magically happens. It has dependent tasks:
507507
508-
=begin code :skip-test
508+
=begin code :preamble<class Task {}>
509509
my $eat =
510510
Task.new({ say 'eating dinner. NOM!' },
511511
Task.new({ say 'making dinner' },
@@ -523,7 +523,7 @@ Notice how the custom constructor and sensible use of whitespace makes task depe
523523
Finally, the C<perform> method call recursively calls the C<perform> method
524524
on the various other dependencies in order, giving the output:
525525
526-
=begin code :skip-test
526+
=begin code :lang<output>
527527
making some money
528528
going to the store
529529
buying food
@@ -563,7 +563,7 @@ other means, such as attribute accessors.
563563
Now, any object of type Programmer can make use of the methods and accessors
564564
defined in the Employee class as though they were from the Programmer class.
565565
566-
=begin code :skip-test
566+
=begin code :preamble<class Programmer {}>
567567
my $programmer = Programmer.new(
568568
salary => 100_000,
569569
known_languages => <Perl5 Perl6 Erlang C++>,
@@ -580,7 +580,7 @@ Of course, classes can override methods and attributes defined by parent
580580
classes by defining their own. The example below demonstrates the C<Baker>
581581
class overriding the C<Cook>'s C<cook> method.
582582
583-
=begin code :skip-test
583+
=begin code :preamble<class Employee {}>
584584
class Cook is Employee {
585585
has @.utensils is rw;
586586
has @.cookbooks is rw;
@@ -636,7 +636,7 @@ classes when looking up a method to search for. Perl 6 uses the L<C3 algorithm
636636
multiple inheritance hierarchies, which is better than depth-first search
637637
for handling multiple inheritance.
638638
639-
=begin code :skip-test
639+
=begin code :preamble<class Programmer {}; class Cook {}>
640640
class GeekCook is Programmer is Cook {
641641
method new( *%params ) {
642642
push( %params<cookbooks>, "Cooking for Geeks" );
@@ -671,7 +671,7 @@ Classes to be inherited from can be listed in the class declaration body by
671671
prefixing the C<is> trait with C<also>. This also works for the role
672672
composition trait C<does>.
673673
674-
=begin code :skip-test
674+
=begin code :preamble<class Programmer {}; class Cook {}>
675675
class GeekCook {
676676
also is Programmer;
677677
also is Cook;
@@ -692,7 +692,7 @@ a controlling object) for some properties, such as its type.
692692
Given an object C<$o> and the class definitions from the previous sections,
693693
we can ask it a few questions:
694694
695-
=begin code :skip-test
695+
=begin code :preamble<my $o; class Employee {}; class GeekCook {}>
696696
if $o ~~ Employee { say "It's an employee" };
697697
if $o ~~ GeekCook { say "It's a geeky cook" };
698698
say $o.perl;
@@ -702,7 +702,7 @@ we can ask it a few questions:
702702
703703
The output can look like this:
704704
705-
=begin code :skip-test
705+
=begin code :lang<output>
706706
It's an employee
707707
(Programmer)
708708
Programmer.new(known_languages => ["Perl", "Python", "Pascal"],
@@ -736,7 +736,7 @@ it is actually a method call on its I<meta class>, which is a class managing
736736
the properties of the C<Programmer> class – or any other class you are
737737
interested in. This meta class enables other ways of introspection too:
738738
739-
=for code :skip-test
739+
=for code :preamble<my $o>
740740
say $o.^attributes.join(', ');
741741
say $o.^parents.map({ $_.^name }).join(', ');
742742

doc/Language/control.pod6

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ you would normally put semicolon, then you do not need the semicolon:
6969
7070
...but:
7171
72-
=begin code :skip-test
72+
=begin code :skip-test<syntax error>
7373
{ 42.say } { 43.say } # Syntax error
7474
{ 42.say; } { 43.say } # Also a syntax error, of course
7575
=end code
7676
7777
So, be careful when you backspace in a line-wrapping editor:
7878
79-
=begin code :skip-test
79+
=begin code :skip-test<syntax error>
8080
{ "Without semicolons line-wrapping can be a bit treacherous.".say } \
8181
{ 43.say } # Syntax error
8282
=end code
@@ -119,7 +119,7 @@ parenthesize a statement if it is the last thing in an expression:
119119
=for code
120120
3, do if 1 { 2 } ; # OUTPUT: «(3, 2)␤»
121121
3, (if 1 { 2 }) ; # OUTPUT: «(3, 2)␤»
122-
=for code :skip-test
122+
=for code :skip-test<syntax error>
123123
3, if 1 { 2 } ; # Syntax error
124124
125125
...which brings us to C<if>.
@@ -135,7 +135,7 @@ instead the C<{> and C<}> around the block are mandatory:
135135
136136
=for code
137137
if 1 { "1 is true".say } ; # says "1 is true"
138-
=for code :skip-test
138+
=for code :skip-test<syntax error>
139139
if 1 "1 is true".say ; # syntax error, missing block
140140
=for code
141141
if 0 { "0 is true".say } ; # does not say anything, because 0 is false
@@ -190,7 +190,7 @@ if 0 { say "no" } else{ say "yes" } ; # says "yes", space is not required
190190
The C<else> cannot be separated from the conditional statement by a
191191
semicolon, but as a special case, it is OK to have a newline.
192192
193-
=for code :skip-test
193+
=for code :skip-test<syntax error>
194194
if 0 { say "no" }; else { say "yes" } ; # syntax error
195195
=for code
196196
if 0 { say "no" }
@@ -213,14 +213,16 @@ be run. You can end with an C<elsif> instead of an C<else> if you want.
213213
214214
You cannot use the statement modifier form with C<else> or C<elsif>:
215215
216-
=for code :skip-test
216+
=for code :skip-test<syntax error>
217217
42.say if 0 else { 43.say } # syntax error
218218
219219
All the same rules for semicolons and newlines apply, consistently
220220
221-
=for code :skip-test
221+
=for code :skip-test<syntax error>
222222
if 0 { say 0 }; elsif 1 { say 1 } else { say "how?" } ; # syntax error
223223
if 0 { say 0 } elsif 1 { say 1 }; else { say "how?" } ; # syntax error
224+
225+
=for code
224226
if 0 { say 0 } elsif 1 { say 1 } else { say "how?" } ; # says "1"
225227
226228
if 0 { say 0 } elsif 1 { say 1 }
@@ -261,7 +263,7 @@ two differences C<unless> works the same as L<#if>:
261263
262264
=for code
263265
unless 1 { "1 is false".say } ; # does not say anything, since 1 is true
264-
=for code :skip-test
266+
=for code :skip-test<syntax error>
265267
unless 1 "1 is false".say ; # syntax error, missing block
266268
=for code
267269
unless 0 { "0 is false".say } ; # says "0 is false"

doc/Language/functions.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ an un-named C<Capture> parameter, and allows a C<multi> to take additional
370370
arguments. The first two calls succeed, but the third fails (at compile time)
371371
because C<42> doesn't match C<Str>.
372372
373-
=for code :skip-test
373+
=for code :preamble<sub congratulate {}>
374374
say &congratulate.signature # OUTPUT: «(Str $reason, Str $name, | is raw)␤»
375375
376376
You can give the C<proto> a function body, and place the C<{*}> where
@@ -394,7 +394,7 @@ with. Parameter defaults and type coercions will work but are not passed on.
394394
proto mistake-proto(Str() $str, Int $number = 42) {*}
395395
multi mistake-proto($str, $number) { say $str.^name }
396396
mistake-proto(7, 42); # OUTPUT: «Int␤» -- not passed on
397-
=for code :skip-test
397+
=for code :skip-test<compilation error>
398398
mistake-proto('test'); # fails -- not passed on
399399
400400
=head2 X<only|declarator>

0 commit comments

Comments
 (0)