Permalink
Browse files

test type checking of default values, RT #74758

  • Loading branch information...
1 parent 584c1a8 commit 9e7fb12f462a5e7e7217cd64a2c1beb1b0196e17 @moritz moritz committed Oct 1, 2011
Showing with 19 additions and 1 deletion.
  1. +10 −1 S06-signature/optional.t
  2. +8 −0 S12-subset/subtypes.t
  3. +1 −0 S14-roles/composition.t
@@ -3,7 +3,7 @@ use Test;
# L<S06/Optional parameters/>
-plan 21;
+plan 23;
sub opt1($p?) { defined($p) ?? $p !! 'undef'; }
@@ -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
@@ -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
@@ -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" };

0 comments on commit 9e7fb12

Please sign in to comment.