From 2368e7a7477d88e5e00b35bf1b475f84abebddac Mon Sep 17 00:00:00 2001 From: rgrjr Date: Sun, 14 Jan 2007 01:15:14 +0000 Subject: [PATCH] * src/mmd.c: + (Parrot_mmd_sort_candidate_list): Don't return the singleton without first checking parameter type compatibility. This could be optimized to do explicit type checking, but I suspect that's not worth it (or at least not yet). * t/pmc/mmd.t: + Add two cases, the second for regression, the first for comparison. git-svn-id: https://svn.perl.org/parrot/trunk@16606 d31e2699-5ff4-0310-a27c-f18f2fbe73fe --- src/mmd.c | 2 -- t/pmc/mmd.t | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/mmd.c b/src/mmd.c index 7b611f5fb6..5986bc5afe 100644 --- a/src/mmd.c +++ b/src/mmd.c @@ -896,8 +896,6 @@ PMC *Parrot_mmd_sort_candidate_list(Interp *interp, PMC *candidates) n = VTABLE_elements(interp, candidates); if (!n) return PMCNULL; - if (n == 1) - return candidates; arg_tuple = mmd_arg_tuple_func(interp); candidates = VTABLE_clone(interp, candidates); diff --git a/t/pmc/mmd.t b/t/pmc/mmd.t index 6bd0ab90e4..b77d01c36a 100644 --- a/t/pmc/mmd.t +++ b/t/pmc/mmd.t @@ -7,7 +7,7 @@ use warnings; use lib qw( . lib ../lib ../../lib ); use Test::More; -use Parrot::Test tests => 42; +use Parrot::Test tests => 44; =head1 NAME @@ -404,6 +404,62 @@ calling foo(b, f) Bar::foo OUT +pir_output_is( <<'CODE', <<'OUT', "MMD second arg int/float dispatch"); +.sub foo :multi(_, Integer) + .param pmc first + .param pmc second + print "(_, Int) method: " + print first + print ', ' + print second + print "\n" +.end +.sub foo :multi(_, Float) + .param pmc first + .param pmc second + print "(_, Float) method: " + print first + print ', ' + print second + print "\n" +.end +.sub main :main + $P0 = new .Float + $P0 = 9.5 + foo(1, $P0) + $P1 = new .Integer + $P1 = 3 + foo(1, $P1) +.end +CODE +(_, Float) method: 1, 9.5 +(_, Int) method: 1, 3 +OUT + +pir_output_like( <<'CODE', <<'OUT', "MMD single method, dispatch failure"); +## Compare this to the previous example. +.sub foo :multi(_, Float) + .param pmc first + .param pmc second + print "(_, Float) method: " + print first + print ', ' + print second + print "\n" +.end +.sub main :main + $P0 = new .Float + $P0 = 9.5 + foo(1, $P0) + $P1 = new .Integer + $P1 = 3 + foo(1, $P1) +.end +CODE +/\A\(_, Float\) method: 1, 9\.5 +Null PMC access/ +OUT + pir_output_is( <<'CODE', <<'OUT', "MMD on argument count" ); .sub main :main p("ok 1\n") -- 2.11.4.GIT