Skip to content

Commit

Permalink
unfudge many unneeded :skip-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coke committed Jun 20, 2017
1 parent 3c7fe8a commit 0b5126a
Show file tree
Hide file tree
Showing 59 changed files with 211 additions and 213 deletions.
4 changes: 2 additions & 2 deletions doc/Language/classtut.pod6
Expand Up @@ -145,7 +145,7 @@ key principles of object oriented design.
The first declaration specifies instance storage for a callback – a bit of
code to invoke in order to perform the task that an object represents:
=for code :skip-test
=for code
has &!callback;
X<|sigils,&>
Expand All @@ -170,7 +170,7 @@ class (or some subclass of it).
The third attribute represents the state of completion of a task:
=for code :skip-test
=for code
has Bool $.done;
X<|twigils,.>
Expand Down
2 changes: 1 addition & 1 deletion doc/Language/concurrency.pod6
Expand Up @@ -515,7 +515,7 @@ more values need to be fetched and loaded into the channel:
Channels can be used in place of the L<Supply> in the C<whenever> of a
C<react> block described earlier:
=begin code :skip-test
=begin code
my $channel = Channel.new;
my $p = start {
react {
Expand Down
18 changes: 9 additions & 9 deletions doc/Language/control.pod6
Expand Up @@ -43,7 +43,7 @@ and how they are used is explained
L<elsewhere|/language/functions#Blocks_and_Lambdas>. For now it is just
important to understand when blocks run and when they do not:
=for code :skip-test
=for code
say "We get here"; { say "then here." }; { say "not here"; 0; } or die;
In the above example, after running the first statement, the first block stands
Expand Down Expand Up @@ -89,7 +89,7 @@ have unnecessary semicolons for clarity.
The simplest way to run a block where it cannot be a stand-alone statement
is by writing C<do> before it:
=for code :skip-test
=for code
# This dies half of the time
do { say "Heads I win, tails I die."; Bool.pick } or die; say "I win.";
Expand Down Expand Up @@ -178,7 +178,7 @@ A compound conditional may be produced by following an C<if> conditional
with C<else> to provide an alternative block to run when the conditional
expression is false:
=for code :skip-test
=for code
if 0 { say "no" } else { say "yes" } ; # says "yes"
if 0 { say "no" } else{ say "yes" } ; # says "yes", space is not required
Expand Down Expand Up @@ -316,7 +316,7 @@ The following examples should illustrate the C<if> or C<when> block's default be
assuming no special exit or other side effect statements are included
in the C<if> or C<when> blocks:
=begin code :skip-test
=begin code
{
if X {...} # if X is true in boolean context, block is executed
# following statements are executed regardless
Expand All @@ -336,7 +336,7 @@ context test defaults to C<$_ ~~> while the C<if>'s does not. That has an effec
how one uses the X in the C<when> block without a value for C<$_> (it's C<Any> in
that case and C<Any> smart matches on C<True>: C<Any ~~ True> yields C<True>). Consider the following:
=begin code :skip-test
=begin code
{
my $a = 1;
my $b = True;
Expand All @@ -350,7 +350,7 @@ that case and C<Any> smart matches on C<True>: C<Any ~~ True> yields C<True>).
Finally, C<when>'s statement modifier form does not effect execution
of following statements either inside or outside of another block:
=begin code :skip-test
=begin code
say "foo" when X; # if X is true statement is executed
# following statements are not affected
=end code
Expand Down Expand Up @@ -401,7 +401,7 @@ A C<for> may be used on lazy lists – it will only take elements from the
list when they are needed, so to read a file line by line, you could
use:
=for code :skip-test
=for code
for $*IN.lines -> $line { .say }
Iteration variables are always lexical, so you don't need to use C<my> to give
Expand Down Expand Up @@ -661,7 +661,7 @@ iteration.
The infinite loop does not require parentheses.
=for code :skip-test
=for code
loop { say 'forever' }
The C<loop> statement may be used to produce values from the result of each
Expand Down Expand Up @@ -894,7 +894,7 @@ prints "12".
The C<redo> command restarts the loop block without evaluating the
conditional again.
=for code :skip-test
=for code
loop {
my $x = prompt("Enter a number");
redo unless $x ~~ /\d+/;
Expand Down
8 changes: 4 additions & 4 deletions doc/Language/faq.pod6
Expand Up @@ -240,7 +240,7 @@ $x = Int
If you want to exclude type objects, you can append the C<:D> type smiley,
which stands for "definite":
=begin code :skip-test
=begin code
my Int:D $x = 42;
$x = Int; # dies with:
# Type check failed in assignment to $x;
Expand All @@ -258,7 +258,7 @@ a type or a definite value.
Example of a type constraint:
=begin code :skip-test
=begin code
sub divide-to-int( Int $a, Int $b --> Int ) {
return ($a / $b).narrow;
}
Expand Down Expand Up @@ -322,7 +322,7 @@ can also contain arrays directly:
The big difference is that arrays inside a scalar act as one value in list
context, whereas arrays will be happily iterated over.
=begin code :skip-test
=begin code
my @a = 1, 2, 3;
my $s = @a;
Expand Down Expand Up @@ -360,7 +360,7 @@ There are several reasons:
You likely tried to mix string interpolation and HTML.
=begin code :skip-test
=begin code
my $foo = "abc";
say "$foo<html-tag>";
=end code
Expand Down
4 changes: 2 additions & 2 deletions doc/Language/functions.pod6
Expand Up @@ -800,7 +800,7 @@ Coercion types can help you to have a specific type inside a routine, but
accept wider input. When the routine is called, the argument is automatically
converted to the narrower type.
=begin code :skip-test
=begin code
sub double(Int(Cool) $x) {
2 * $x
}
Expand All @@ -818,7 +818,7 @@ to C<Int()>.
The coercion works by looking for a method with the same name
as the target type. You can define coercions for your own types like so:
=begin code :skip-test
=begin code
class Bar {...}
class Foo {
Expand Down
6 changes: 3 additions & 3 deletions doc/Language/glossary.pod6
Expand Up @@ -829,7 +829,7 @@ For example, the L«C<IO::Handle.lines>|/type/IO::Handle#method_lines» returns
a L<Seq>. The following code contains a bug; keeping reification in mind, try to
spot it:
=for code :skip-test
=for code
my $fh = "/tmp/bar".IO.open;
my $lines = $fh.lines;
close $fh;
Expand All @@ -848,15 +848,15 @@ to read from a closed handle. So, to fix the bug we can either assign to
a C<@>-sigiled variable or call L«C<.elems>|/routine/elems» on C<$lines> before
closing the handle:
=for code :skip-test
=for code
my $fh = "/tmp/bar".IO.open;
my @lines = $fh.lines;
close $fh;
say @lines[0]; # no problem!
Also good:
=for code :skip-test
=for code
my $fh = "/tmp/bar".IO.open;
my $lines = $fh.lines;
say "Read $lines.elems() lines"; #reifying before closing handle
Expand Down
2 changes: 1 addition & 1 deletion doc/Language/haskell-to-p6.pod6
Expand Up @@ -205,7 +205,7 @@ The equivalent in Perl 6 is the following.
It should be noted that in Perl 6, one can also create a subset of an existing type.
=begin code :skip-test
=begin code
subset Name of Str where *.chars < 20;
sub full-name(Name $first, Name $last) {
Expand Down
20 changes: 10 additions & 10 deletions doc/Language/io-guide.pod6
Expand Up @@ -72,7 +72,7 @@ read the data in one chunk. Unless you're working with very large files that
are difficult to store entirely in memory all at the same time, these two
routines are for you.
=for code :skip-test
=for code
"my-file.txt".IO.spurt: "I ♥ Perl!";
The code above creates a file named C<my-file.txt> in the current directory
Expand All @@ -95,7 +95,7 @@ could note the L«C<spurt> documentation|/routine/spurt» mentions C<:append>
argument. However, for finer control, let's get ourselves an L<IO::Handle>
to work with:
=for code :skip-test
=for code
my $fh = 'my-file.txt'.IO.open: :a;
$fh.print: "I count: ";
$fh.print: "$_ " for ^10;
Expand Down Expand Up @@ -131,7 +131,7 @@ handles get a chance to get garbage collected.
We've seen in previous sections that writing stuff to files is a single-line
of code in Perl 6. Reading from them, is similarly easy:
=for code :skip-test
=for code
say 'my-file.txt'.IO.slurp; # OUTPUT: «I ♥ Perl!␤»
say 'my-file.txt'.IO.slurp: :bin; # OUTPUT: «Buf[uint8]:0x<49 20 e2 99 a5 20 50 65 72 6c 21>␤»
Expand All @@ -153,13 +153,13 @@ them out. Despite the file itself being too large to fit into available
L<RAM|https://en.wikipedia.org/wiki/Random-access_memory>, the program will
not have any issues running, as the contents are processed in small chunks:
=for code :skip-test
=for code
.say for '500-PetaByte-File.txt'.IO.lines.grep: *.contains: 'Perl';
Here's another example that prints the first 100 words from a file, without
loading it entirely:
=for code :skip-test
=for code
.say for '500-PetaByte-File.txt'.IO.words: 100
Note that we did this by passing a limit argument to
Expand All @@ -181,7 +181,7 @@ is there to help you with that.
Of course, you can read from files using the L<IO::Handle> type, which gives you
a lot finer control over what you're doing:
=begin code :skip-test
=begin code
given 'some-file.txt'.IO.open {
say .readchars: 8; # OUTPUT: «I ♥ Perl␤»
.seek: 1, SeekFromCurrent;
Expand Down Expand Up @@ -257,7 +257,7 @@ L«C<IO::Path>|/type/IO::Path» was instantiated with. It doesn't consider the
value of the L«C<$.CWD> attribute|/type/IO::Path#attribute_CWD». For example, this
code is broken:
=for code :skip-test
=for code
# WRONG!! .Str DOES NOT USE $.CWD!
my $path = 'foo'.IO;
chdir 'bar';
Expand All @@ -272,7 +272,7 @@ L«C<.relative>|/routine/relative» to stringify the object. Both routines retur
a L«C<Str>|/type/Str» object; they only differ in whether the result is an
absolute or relative path. So, we can fix our code like this:
=for code :skip-test
=for code
# RIGHT!! .absolute does consider the value of $.CWD!
my $path = 'foo'.IO;
chdir 'bar';
Expand All @@ -292,7 +292,7 @@ things to pay attention to.
This code is a mistake:
=for code :skip-test
=for code
# WRONG!!
my $*CWD = "foo".IO;
Expand All @@ -308,7 +308,7 @@ to L«C<$*CWD>|/language/variables#Dynamic_variables», just like C<my> would,
but it won't make it undefined, so the L«C<.IO>|/routine/IO» coercer will still
get the correct old value:
=for code :skip-test
=for code
temp $*CWD = "foo".IO;
Better yet, if you want to perform some code in a localized
Expand Down

0 comments on commit 0b5126a

Please sign in to comment.