Skip to content

Commit

Permalink
Better tag some skip-tests, and allow some to run
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Oct 3, 2018
1 parent 4e6f32c commit 6fd1a1f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion doc/Language/5to6-nutshell.pod6
Expand Up @@ -1526,7 +1526,7 @@ C<is export> role on the relevant subs and I<all> subs with this role are
then exported. Hence, the following module C<Bar> exports the subs C<foo>
and C<bar> but not C<baz>:
=begin code :skip-test
=begin code :skip-test<unit>
unit module Bar;
sub foo($a) is export { say "foo $a" }
Expand Down
22 changes: 11 additions & 11 deletions doc/Language/classtut.pod6
Expand Up @@ -316,7 +316,7 @@ possible to predict the moment when attribute initialization will be executed,
because it can take place during compilation, runtime or both, especially when
importing the class using the L<use|/syntax/use> keyword.
=begin code :skip-test
=begin code :preamble<class Foo {}; sub some_complicated_subroutine {}>
class HaveStaticAttr {
my Foo $.foo = some_complicated_subroutine;
}
Expand Down Expand Up @@ -493,7 +493,7 @@ After creating a class, you can create instances of the class. Declaring a
custom constructor provides a simple way of declaring tasks along with their
dependencies. To create a single task with no dependencies, write:
=for code :skip-test
=for code :preamble<class Task {}>
my $eat = Task.new({ say 'eating dinner. NOM!' });
An earlier section explained that declaring the class C<Task> installed a
Expand All @@ -505,7 +505,7 @@ modifying or accessing an existing object.
Unfortunately, dinner never magically happens. It has dependent tasks:
=begin code :skip-test
=begin code :preamble<class Task {}>
my $eat =
Task.new({ say 'eating dinner. NOM!' },
Task.new({ say 'making dinner' },
Expand All @@ -523,7 +523,7 @@ Notice how the custom constructor and sensible use of whitespace makes task depe
Finally, the C<perform> method call recursively calls the C<perform> method
on the various other dependencies in order, giving the output:
=begin code :skip-test
=begin code :lang<output>
making some money
going to the store
buying food
Expand Down Expand Up @@ -563,7 +563,7 @@ other means, such as attribute accessors.
Now, any object of type Programmer can make use of the methods and accessors
defined in the Employee class as though they were from the Programmer class.
=begin code :skip-test
=begin code :preamble<class Programmer {}>
my $programmer = Programmer.new(
salary => 100_000,
known_languages => <Perl5 Perl6 Erlang C++>,
Expand All @@ -580,7 +580,7 @@ Of course, classes can override methods and attributes defined by parent
classes by defining their own. The example below demonstrates the C<Baker>
class overriding the C<Cook>'s C<cook> method.
=begin code :skip-test
=begin code :preamble<class Employee {}>
class Cook is Employee {
has @.utensils is rw;
has @.cookbooks is rw;
Expand Down Expand Up @@ -636,7 +636,7 @@ classes when looking up a method to search for. Perl 6 uses the L<C3 algorithm
multiple inheritance hierarchies, which is better than depth-first search
for handling multiple inheritance.
=begin code :skip-test
=begin code :preamble<class Programmer {}; class Cook {}>
class GeekCook is Programmer is Cook {
method new( *%params ) {
push( %params<cookbooks>, "Cooking for Geeks" );
Expand Down Expand Up @@ -671,7 +671,7 @@ Classes to be inherited from can be listed in the class declaration body by
prefixing the C<is> trait with C<also>. This also works for the role
composition trait C<does>.
=begin code :skip-test
=begin code :preamble<class Programmer {}; class Cook {}>
class GeekCook {
also is Programmer;
also is Cook;
Expand All @@ -692,7 +692,7 @@ a controlling object) for some properties, such as its type.
Given an object C<$o> and the class definitions from the previous sections,
we can ask it a few questions:
=begin code :skip-test
=begin code :preamble<my $o; class Employee {}; class GeekCook {}>
if $o ~~ Employee { say "It's an employee" };
if $o ~~ GeekCook { say "It's a geeky cook" };
say $o.perl;
Expand All @@ -702,7 +702,7 @@ we can ask it a few questions:
The output can look like this:
=begin code :skip-test
=begin code :lang<output>
It's an employee
(Programmer)
Programmer.new(known_languages => ["Perl", "Python", "Pascal"],
Expand Down Expand Up @@ -736,7 +736,7 @@ it is actually a method call on its I<meta class>, which is a class managing
the properties of the C<Programmer> class – or any other class you are
interested in. This meta class enables other ways of introspection too:
=for code :skip-test
=for code :preamble<my $o>
say $o.^attributes.join(', ');
say $o.^parents.map({ $_.^name }).join(', ');
Expand Down
18 changes: 10 additions & 8 deletions doc/Language/control.pod6
Expand Up @@ -69,14 +69,14 @@ you would normally put semicolon, then you do not need the semicolon:
...but:
=begin code :skip-test
=begin code :skip-test<syntax error>
{ 42.say } { 43.say } # Syntax error
{ 42.say; } { 43.say } # Also a syntax error, of course
=end code
So, be careful when you backspace in a line-wrapping editor:
=begin code :skip-test
=begin code :skip-test<syntax error>
{ "Without semicolons line-wrapping can be a bit treacherous.".say } \
{ 43.say } # Syntax error
=end code
Expand Down Expand Up @@ -119,7 +119,7 @@ parenthesize a statement if it is the last thing in an expression:
=for code
3, do if 1 { 2 } ; # OUTPUT: «(3, 2)␤»
3, (if 1 { 2 }) ; # OUTPUT: «(3, 2)␤»
=for code :skip-test
=for code :skip-test<syntax error>
3, if 1 { 2 } ; # Syntax error
...which brings us to C<if>.
Expand All @@ -135,7 +135,7 @@ instead the C<{> and C<}> around the block are mandatory:
=for code
if 1 { "1 is true".say } ; # says "1 is true"
=for code :skip-test
=for code :skip-test<syntax error>
if 1 "1 is true".say ; # syntax error, missing block
=for code
if 0 { "0 is true".say } ; # does not say anything, because 0 is false
Expand Down Expand Up @@ -190,7 +190,7 @@ if 0 { say "no" } else{ say "yes" } ; # says "yes", space is not required
The C<else> cannot be separated from the conditional statement by a
semicolon, but as a special case, it is OK to have a newline.
=for code :skip-test
=for code :skip-test<syntax error>
if 0 { say "no" }; else { say "yes" } ; # syntax error
=for code
if 0 { say "no" }
Expand All @@ -213,14 +213,16 @@ be run. You can end with an C<elsif> instead of an C<else> if you want.
You cannot use the statement modifier form with C<else> or C<elsif>:
=for code :skip-test
=for code :skip-test<syntax error>
42.say if 0 else { 43.say } # syntax error
All the same rules for semicolons and newlines apply, consistently
=for code :skip-test
=for code :skip-test<syntax error>
if 0 { say 0 }; elsif 1 { say 1 } else { say "how?" } ; # syntax error
if 0 { say 0 } elsif 1 { say 1 }; else { say "how?" } ; # syntax error
=for code
if 0 { say 0 } elsif 1 { say 1 } else { say "how?" } ; # says "1"
if 0 { say 0 } elsif 1 { say 1 }
Expand Down Expand Up @@ -261,7 +263,7 @@ two differences C<unless> works the same as L<#if>:
=for code
unless 1 { "1 is false".say } ; # does not say anything, since 1 is true
=for code :skip-test
=for code :skip-test<syntax error>
unless 1 "1 is false".say ; # syntax error, missing block
=for code
unless 0 { "0 is false".say } ; # says "0 is false"
Expand Down
4 changes: 2 additions & 2 deletions doc/Language/functions.pod6
Expand Up @@ -370,7 +370,7 @@ an un-named C<Capture> parameter, and allows a C<multi> to take additional
arguments. The first two calls succeed, but the third fails (at compile time)
because C<42> doesn't match C<Str>.
=for code :skip-test
=for code :preamble<sub congratulate {}>
say &congratulate.signature # OUTPUT: «(Str $reason, Str $name, | is raw)␤»
You can give the C<proto> a function body, and place the C<{*}> where
Expand All @@ -394,7 +394,7 @@ with. Parameter defaults and type coercions will work but are not passed on.
proto mistake-proto(Str() $str, Int $number = 42) {*}
multi mistake-proto($str, $number) { say $str.^name }
mistake-proto(7, 42); # OUTPUT: «Int␤» -- not passed on
=for code :skip-test
=for code :skip-test<compilation error>
mistake-proto('test'); # fails -- not passed on
=head2 X<only|declarator>
Expand Down

0 comments on commit 6fd1a1f

Please sign in to comment.