Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Basic test for new multi/coercion semantics.
  • Loading branch information
jnthn committed Apr 4, 2015
1 parent 7bb87ca commit 0f4a710
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion S06-multi/type-based.t
@@ -1,6 +1,6 @@
use v6;
use Test;
plan 53;
plan 56;

# type based dispatching
#
Expand Down Expand Up @@ -210,6 +210,19 @@ is(mmd(1..3), 2, 'Slurpy MMD to listop via list');
ok rt107638(1), 'native types and where clauses do not cause spurious circularities';
}

# Coercion types introduce two candidates
{
proto foo($) {*}
multi foo(Int() $) { 1 }
multi foo(Cool $) { 2 }

my class NotCool { method Int() { 42 } }

is foo(42), 1, 'Int hits Int() candidate as if it were an Int candidate';
is foo("omg"), 2, 'Str hits Cool candidate';
is foo(NotCool), 1, 'Set hits Int() candidate due to it accepting Any and coercing';
}

done;

# vim: ft=perl6

0 comments on commit 0f4a710

Please sign in to comment.