Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test type checking of default values, RT #74758
  • Loading branch information
moritz committed Oct 1, 2011
1 parent 584c1a8 commit 9e7fb12
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion S06-signature/optional.t
Expand Up @@ -3,7 +3,7 @@ use Test;

# L<S06/Optional parameters/>

plan 21;
plan 23;

sub opt1($p?) { defined($p) ?? $p !! 'undef'; }

Expand Down Expand Up @@ -84,4 +84,13 @@ is opt_hash2(), 0, "optional hash not passed is empty (copy)";
eval_dies_ok 'sub opt($a = 1, $b) { }',
'Cannot put required parameter after optional parameters';

# RT #74758
{
sub opt-type1(Int $x?) { $x };
ok opt-type1() === Int,
'optional param with type constraints gets the right value';
sub opt-type2(Int $x = 'str') { };
nok eval('opt-type2()'), 'default values are type-checked';
}

# vim: ft=perl6
8 changes: 8 additions & 0 deletions S12-subset/subtypes.t
Expand Up @@ -214,6 +214,14 @@ ok "x" !~~ NW1, 'subset declaration without where clause rejects wrong value';
is $*call2, 1, 'level two subset checked (should succeed)';
}

# RT #75718
{
roles R { };
subset S of R;
nok 1 ~~ S, 'subsets of roles (1)';
ok R ~~ S, 'subsets of roles (2)';
}

done;

# vim: ft=perl6
1 change: 1 addition & 0 deletions S14-roles/composition.t
Expand Up @@ -72,6 +72,7 @@ ok rB !~~ RT64002, 'role not matched by second role it does';
}

# diamond composition
#?rakudo skip 'diamond composition'
{
role DA {
method foo { "OH HAI" };
Expand Down

0 comments on commit 9e7fb12

Please sign in to comment.