Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 57 lines (47 sloc) 1.996 kB
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
1 use v6;
2 use Test;
3
d2482f4 replace plan *; with number of tests S03-S06
mberends authored
4 plan 17;
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
5
e27dccc [t/spec] smartlinks and a simplification
moritz authored
6 # L<S06/Perl5ish subroutine declarations/You can declare a sub without
7 # parameter list>
8
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
9 sub simple { 'simple' }
10 #?rakudo skip 'siglist'
11 is &simple.signature, :(), 'signature is :() when none is specified';
12 is simple(), 'simple', 'can call sub with no signature specified';
ea5588e [t/spec] improved readability/clarity after comments from TimToady++
kyle authored
13 dies_ok { simple( :golf<hotel> ) },
14 'sub with no signature dies when given a named argument';
15 dies_ok { simple( 'india' ) },
16 'sub with no signature dies when given positional argument';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
17
18 sub positional { @_[0] }
19 #?rakudo skip 'siglist'
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
20 is &positional.signature, :(Mu *@_),
21 'signature is :(Mu *@_) when none is specified and @_ is used';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
22 is positional( 'alpha' ), 'alpha', 'can call sub with positional param used';
2544bcf @jdhore Remove most remaining .notdef's.
jdhore authored
23 nok positional().defined, 'sub using positional param called with no params';
d4509d1 [t/spec] bring unspecified.t closer to my understanding of the spec
moritz authored
24 dies_ok { positional( :victor<whiskey> ) },
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
25 'sub using positional param called with named param';
26
27 sub named { %_<bravo> }
28 #?rakudo skip 'siglist'
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
29 is &named.signature, :(Mu *%_),
30 'signature is :(Mu *%_) when none is specified and %_ is used';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
31 is named( :bravo<charlie> ), 'charlie', 'can call sub with named param used';
2544bcf @jdhore Remove most remaining .notdef's.
jdhore authored
32 nok named().defined, 'named param sub is callable with no params';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
33 dies_ok { named( 'zulu' ) }, 'named param sub dies with positional param';
34
35 sub both { @_[1] ~ %_<delta> }
36 #?rakudo skip 'siglist'
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
37 is &both.signature, :(Mu *@_, Mu *%_),
38 'signature is :(Mu *@_, Mu *%_) when none is specified and @_ and %_ are used';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
39 is both( 'x', :delta<echo>, 'foxtrot' ), 'foxtrotecho',
40 'can call sub with both named and positional params used';
d5fdcaf [t/spec]: Fudge and fix some tests after autoviv changes.
pmichaud authored
41 #?rakudo todo 'undef Stringy'
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
42 is both(), '',
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
43 'sub using both named and position params works with no params';
8549842 [t/spec] avoid warnings in unspecified.t
moritz authored
44
2ce2e07 [t/spec] Test for RT 71112: Cannot assign to readonly variable.
kyle authored
45 # RT 71112
46 {
47 sub rt71112 { @_[0] = 'bug' }
48 my $tender = 'sanity';
49 #?rakudo todo 'RT 71112: Cannot assign to readonly variable.'
50 dies_ok { rt71112( $tender ) }, 'Sub that tries to modify @_ dies';
51 is $tender, 'sanity', 'The variable passed is unchanged.';
52 }
53
e76dd4c @moritz s/done_testing/done/ as per recent S24 changes
moritz authored
54 done;
2ce2e07 [t/spec] Test for RT 71112: Cannot assign to readonly variable.
kyle authored
55
8549842 [t/spec] avoid warnings in unspecified.t
moritz authored
56 # vim: ft=perl6
Something went wrong with that request. Please try again.