Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 52 lines (43 sloc) 2.011 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>
f1d90ff @moritz avoid using typed slurpy for unrelated things
moritz authored
8 #
2e6f3e1 @usev6 Use .perl to compare signatures; tests are passing now
usev6 authored
9 # TODO: if there is a better way to compare signatures: don't rely on .perl
e27dccc [t/spec] smartlinks and a simplification
moritz authored
10
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
11 sub simple { 'simple' }
2e6f3e1 @usev6 Use .perl to compare signatures; tests are passing now
usev6 authored
12 is &simple.signature.perl, ':()', 'signature is :() when none is specified';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
13 is simple(), 'simple', 'can call sub with no signature specified';
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
14 dies-ok { EVAL('simple( :golf<hotel> )') },
ea5588e [t/spec] improved readability/clarity after comments from TimToady++
kyle authored
15 'sub with no signature dies when given a named argument';
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
16 dies-ok { EVAL("simple( 'india' )") },
ea5588e [t/spec] improved readability/clarity after comments from TimToady++
kyle authored
17 'sub with no signature dies when given positional argument';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
18
19 sub positional { @_[0] }
2e6f3e1 @usev6 Use .perl to compare signatures; tests are passing now
usev6 authored
20 is &positional.signature.perl, ':(*@_)',
d07b99e @lizmat Unfudge now passing tests again
lizmat authored
21 'signature is :(Mu *@_) when none is specified and @_ is used, RT #125486';
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';
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat 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> }
2e6f3e1 @usev6 Use .perl to compare signatures; tests are passing now
usev6 authored
28 is &named.signature.perl, ':(*%_)',
d07b99e @lizmat Unfudge now passing tests again
lizmat authored
29 'signature is :(Mu *%_) when none is specified and %_ is used, RT #125486';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
30 is named( :bravo<charlie> ), 'charlie', 'can call sub with named param used';
2544bcf @jdhore Remove most remaining .notdef's.
jdhore authored
31 nok named().defined, 'named param sub is callable with no params';
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
32 dies-ok { named( 'zulu' ) }, 'named param sub dies with positional param';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
33
34 sub both { @_[1] ~ %_<delta> }
2e6f3e1 @usev6 Use .perl to compare signatures; tests are passing now
usev6 authored
35 is &both.signature.perl, ':(*@_, *%_)',
d07b99e @lizmat Unfudge now passing tests again
lizmat authored
36 'signature is :(Mu *@_, Mu *%_) when none is specified and @_ and %_ are used, RT #125486';
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
37 is both( 'x', :delta<echo>, 'foxtrot' ), 'foxtrotecho',
38 'can call sub with both named and positional params used';
8f9a119 [t/] unify compartmentalized undef and Object concepts into Mu
lwall authored
39 is both(), '',
8c7f047 [t/spec] Tests for P5 style subs without signatures
kyle authored
40 'sub using both named and position params works with no params';
8549842 [t/spec] avoid warnings in unspecified.t
moritz authored
41
25668e6 @coke Prefer RT #XXXXXX
coke authored
42 # RT #71112
2ce2e07 [t/spec] Test for RT 71112: Cannot assign to readonly variable.
kyle authored
43 {
44 sub rt71112 { @_[0] = 'bug' }
45 my $tender = 'sanity';
25668e6 @coke Prefer RT #XXXXXX
coke authored
46 #?rakudo todo 'RT #71112: Cannot assign to readonly variable.'
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
47 dies-ok { rt71112( $tender ) }, 'Sub that tries to modify @_ dies';
2ce2e07 [t/spec] Test for RT 71112: Cannot assign to readonly variable.
kyle authored
48 is $tender, 'sanity', 'The variable passed is unchanged.';
49 }
50
8549842 [t/spec] avoid warnings in unspecified.t
moritz authored
51 # vim: ft=perl6
Something went wrong with that request. Please try again.