Skip to content

Commit ba42f1d

Browse files
committed
Fix signatures, skip some examples testing
1 parent 43cc319 commit ba42f1d

File tree

15 files changed

+85
-42
lines changed

15 files changed

+85
-42
lines changed

doc/Language/containers.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,6 @@ work with types in Perl 6.
323323
say $a = 12; # OUTPUT: «12␤»
324324
say $a = 'FOO'; # X::TypeCheck::Binding
325325
say $a = 13; # X::OutOfRange
326-
CATCH { default { say .^name, ': ', .Str; .resume } };
326+
CATCH { default { say .^name, ': ', .Str } };
327327
328328
=end pod

doc/Language/exceptions.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ then an L<X::IO::DoesNotExist> exception can be raised:
3232
3333
die X::IO::DoesNotExist.new(:path("foo/bar"), :trying("zombie copy"))
3434
35-
# RESULT: «!> Failed to find 'foo/bar' while trying to do '.zombie copy'
35+
# RESULT: «Failed to find 'foo/bar' while trying to do '.zombie copy'
3636
# in block <unit> at my-script.p6:1»
3737
3838
Note how the object has provided the backtrace with information about what

doc/Language/faq.pod6

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,12 @@ $x = Int
236236
If you want to exclude type objects, you can append the C<:D> type smiley,
237237
which stands for "definite":
238238
239+
=begin code :skip-test
239240
my Int:D $x = 42;
240241
$x = Int; # dies with:
241242
# Type check failed in assignment to $x;
242243
# expected Int:D but got Int
244+
=end code
243245
244246
Likewise, C<:U> constrains to undefined values, that is, type objects.
245247
@@ -252,12 +254,14 @@ a type or a definite value.
252254
253255
Example of a type constraint:
254256
257+
=begin code :skip-test
255258
sub divide-to-int( Int $a, Int $b --> Int ) {
256259
return ($a / $b).narrow;
257260
}
258261
259262
divide-to-int(3, 2)
260263
# Type check failed for return value; expected Int but got Rat
264+
=end code
261265
262266
Example of a definite return value:
263267
@@ -314,6 +318,7 @@ can also contain arrays directly:
314318
The big difference is that arrays inside a scalar act as one value in list
315319
context, whereas arrays will be happily iterated over.
316320
321+
=begin code :skip-test
317322
my @a = 1, 2, 3;
318323
my $s = @a;
319324
@@ -325,6 +330,7 @@ context, whereas arrays will be happily iterated over.
325330
326331
my @nested = flat $s, $s;
327332
say @nested.elems; # OUTPUT: «2␤»
333+
=end code
328334
329335
You can force flattening with C<@( ... )> or by calling the C<.list> method
330336
on an expression, and item context (not flattening) with C<$( ... )>
@@ -350,8 +356,10 @@ There are several reasons:
350356
351357
You likely tried to mix string interpolation and HTML.
352358
359+
=begin code :skip-test
353360
my $foo = "abc";
354361
say "$foo<html-tag>";
362+
=end code
355363
356364
Perl 6 thinks C<$foo> to be a Hash and C«<html-tag>» to be a string literal
357365
hash key. Use a closure to help it to understand you.

doc/Language/list.pod6

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ One of the ways C<@>-sigiled variables act like lists is by always supporting
6060
L<positional subscripting|/language/subscripts>. Anything bound to a C<@>-sigiled
6161
value must support the L<Positional|/type/Positional> role which guarantees this:
6262
63+
=begin code :skip-test
6364
my @a := 1; # Type check failed in binding; expected Positional but got Int
64-
65+
=end code
6566
6667
=head1 Reset a List Container
6768
@@ -109,7 +110,9 @@ Although the C<Seq> class does provide some positional subscripting, it does
109110
not provide the full interface of C<Positional>, so an C<@>-sigiled variable
110111
may B<not> be bound to a C<Seq>.
111112
113+
=begin code :skip-test
112114
my @s := (loop { 42.say }); # Error expected Positional but got Seq
115+
=end code
113116
114117
This is because the C<Seq> does not keep values around after you have used them.
115118
This is useful behavior if you have a very long sequence, as you may want to
@@ -179,9 +182,11 @@ The lists we have talked about so far (C<List>, C<Seq> and C<Slip>)
179182
are all immutable. This means you cannot remove elements from them,
180183
or re-bind existing elements:
181184
185+
=begin code :skip-test
182186
(1, 2, 3)[0]:delete; # Error Can not remove elements from a List
183187
(1, 2, 3)[0] := 0; # Error Cannot use bind operator with this left-hand side
184188
(1, 2, 3)[0] = 0; # Error Cannot modify an immutable Int
189+
=end code
185190
186191
However, if any of the elements is wrapped in a L<C<Scalar>|/type/Scalar> you
187192
can still change the value which that C<Scalar> points to:
@@ -281,7 +286,9 @@ of pair forms happens.
281286
Most C<Positional> types will enforce an integer coercion on each element
282287
of a slice index, so pairs appearing there will generate an error, anyway:
283288
284-
(1, 2, 3)[1, 2, :c(3)] # Method 'Int' not found for invocant of class 'Pair'
289+
=begin code :skip-test
290+
(1, 2, 3)[1, 2, :c(3)] # OUTPUT: «Method 'Int' not found for invocant of class 'Pair'␤»
291+
=end code
285292
286293
...however this is entirely up to the type – if it defines an order
287294
for pairs, it could consider C<:c(3)> a valid index.
@@ -339,6 +346,7 @@ is of type C<Array[Int]> and one can create one with C<Array[Int].new>. If
339346
you intend to use an C<@>-sigiled variable only for this purpose, you may
340347
change its type by specifying the type of the elements when declaring it:
341348
349+
=begin code :skip-test
342350
my Int @a = 1, 2, 3; # An Array that contains only Ints
343351
my @b := Array[Int].new(1, 2, 3); # Same thing, but the variable is not typed
344352
say @b eqv @a; # says True.
@@ -350,15 +358,18 @@ change its type by specifying the type of the elements when declaring it:
350358
351359
@a[0] = 42; # fine
352360
@a[0] = "foo"; # error: Type check failed in assignment
361+
=end code
353362
354363
In the above example we bound a typed Array object to a C<@>-sigil variable for
355364
which no type had been specified. The other way around does not work – you may
356365
not bind an Array that has the wrong type to a typed C<@>-sigiled variable:
357366
367+
=begin code :skip-test
358368
my @a := Array[Int].new(1, 2, 3); # fine
359369
@a := Array[Str].new("a", "b"); # fine, can be re-bound
360370
my Int @b := Array[Int].new(1, 2, 3); # fine
361371
@b := Array.new(1, 2, 3); # error: Type check failed in binding
372+
=end code
362373
363374
When working with typed arrays, it is important to remember that they are
364375
nominally typed. This means the declared type of an array is what matters.

doc/Language/operators.pod6

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,11 +1209,13 @@ Instead of a role, you can provide an instantiated object. In this case,
12091209
the operator will create a role for you automatically. The role will contain
12101210
a single method named the same as C<$obj.^name> and that returns C<$obj>:
12111211
1212+
=begin code :skip-test
12121213
say 42 but 'forty two'; # OUTPUT: «forty two␤»
12131214
12141215
my $s = 12 but class Warbles { method hi { 'hello' } }.new;
12151216
say $s.Warbles.hi; # OUTPUT: «hello␤»
12161217
say $s + 42; # OUTPUT: «54␤»
1218+
=end code
12171219
12181220
If methods of the same name are present already, the last mixed in role takes
12191221
precedence. A list of methods can be provided in parentheses separated by

doc/Language/quoting.pod6

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,13 @@ Interpolation of undefined values will raise a control exception that can be
173173
caught in the current block with
174174
L<CONTROL|https://docs.perl6.org/syntax/CONTROL>.
175175
176+
=begin code :skip-test
176177
sub niler {Nil};
177178
my Str $a = niler;
178179
say("$a.html", "sometext");
179180
say "alive"; # this line is dead code
180181
CONTROL { .die };
182+
=end code
181183
182184
=head2 Word quoting: qw
183185
X<|qw word quote>

doc/Language/regexes.pod6

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Alphanumeric characters and the underscore C<_> are matched literally. All
4444
other characters must either be escaped with a backslash (for example, C<\:>
4545
to match a colon), or be within quotes:
4646
47-
/ 'two words' / # matches 'two words' including the blank
48-
/ "a:b" / # matches 'a:b' including the colon
49-
/ '#' / # matches a hash character
47+
/ 'two words' /; # matches 'two words' including the blank
48+
/ "a:b" /; # matches 'a:b' including the colon
49+
/ '#' /; # matches a hash character
5050
5151
Strings are searched left to right, so it's enough if only
5252
part of the string matches the regex:

doc/Language/subscripts.pod6

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ invocant as a list of one element. (But there's no such fallback for
115115
associative subscripts, so they throw a run-time error when applied to an
116116
object that does not implement support for them.)
117117
118+
=begin code :skip-test
118119
say 42[0]; # OUTPUT: «42␤»
119120
say 42<foo>; # ERROR: postcircumfix { } not defined for type Int
121+
=end code
120122
121123
=head1 Nonexistent elements
122124
@@ -588,6 +590,7 @@ See also the L<keys> routine.
588590
Return the bare value of the element (rather than potentially returning a
589591
mutable value container), and silently skip nonexistent elements:
590592
593+
=begin code :skip-test
591594
my @tens = 0, 10, 20, 30;
592595
dd @tens[1]:v; # OUTPUT: «10␤»
593596
dd @tens[0, 4, 2]:v; # OUTPUT: «(0, 20)␤»
@@ -597,6 +600,7 @@ mutable value container), and silently skip nonexistent elements:
597600
my %month = Jan => 1, Feb => 2, Mar => 3;
598601
dd %month<Feb>:v; # OUTPUT: «2␤»
599602
dd %month<Jan Foo Mar>:v; # OUTPUT: «(1, 3)␤»
603+
=end code
600604
601605
If you I<don't> want to skip nonexistent elements, use the negated form:
602606
@@ -645,6 +649,7 @@ subscripting interface.
645649
Imagine a HTTP::Header type which, despite being a custom class with special
646650
behavior, can be indexed like a hash:
647651
652+
=begin code :skip-test
648653
my $request = HTTP::Request.new(GET => "perl6.org");
649654
say $request.header.WHAT; # OUTPUT: «(HTTP::Header)␤»
650655
@@ -655,6 +660,7 @@ behavior, can be indexed like a hash:
655660
say $request.header<Accept-Language>.perl; # OUTPUT: «["en", "fr"]␤»
656661
657662
my $rawheader = $request.header.Str; # stringify according to HTTP spec
663+
=end code
658664
659665
The simplest way to implement this class, would be to give it an attribute of
660666
type L<Hash>, and delegate all subscripting and iterating related functionality

doc/Type/Callable.pod6

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,13 @@ value of the right function will be L<slipped|/type/Slip> into the left function
7777
# or to:
7878
say f g 2;
7979
80+
=begin code
8081
sub f($a, $b, $c) { [~] $c, $b, $a }
8182
sub g($str){ $str.comb }
8283
my &composed = &f ∘ &g;
8384
say composed 'abc'; # OUTPUT: «cba␤»
8485
# equivalent to:
8586
say f |g 'abc';
87+
=end code
8688
8789
=end pod

doc/Type/IO/Socket/Async.pod6

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,23 @@ listener should be C<close>d.
9696
9797
For example, when using C<tap>:
9898
99+
=begin code :skip-test
99100
my $listener = IO::Socket::Async.listen('127.0.0.1', 8080);
100101
my $tap = $listener.tap({ ... });
101102
102103
# When you want to close the listener
103104
$tap.close;
105+
=end code
104106
105107
Or when using C<whenever>:
106108
109+
=begin code :skip-test
107110
my $listener = IO::Socket::Async.listen('127.0.0.1', 5000);
108111
my $big-finish = Promise.new;
109112
my $tap = do whenever $listener -> $conn { ... }
110113
await $big-finish;
111114
$tap.close;
115+
=end code
112116
113117
=head2 method udp
114118

0 commit comments

Comments
 (0)