<commit_before>use v6;

use Test;

plan 3;

# L<S12/"Calling sets of methods"/"It is also possible to trim the candidate list so that the current call is considered the final candidate.">

class Foo {
    # $.tracker is used to determine the order of calls.
    has $.tracker;
    method doit()  {$.tracker ~= 'foo,'}
    method doit(Int $num) {$.tracker ~= 'fooint,'}
    method show  {$.tracker}
    method clear {$.tracker = ''}
}

class BarLastCallSame is Foo {
    method doit() {$.tracker ~= 'bar,'; lastcall; $.tracker ~= 'ret1,'}
    method doit(Int $num) {$.tracker ~= 'barint,'; callsame; $.tracker ~= 'ret2,'}
}

{
    my $o = BarLastCallSame.new;
    $o.clear;
    $o.doit;
    is($o.show, 'bar,ret1,', 'lastcall inheritance test');
    $o.clear;
    is($o.show, '', 'sanity test for clearing');
    $o.doit(5);
    is($o.show, 'barint,bar,ret1,ret2,', 'lastcall multimethod/inheritance test');
}

# vim: ft=perl6<commit_msg>[t/spec] Some corrections to lastcall.t (currently NYI in Rakudo).<commit_after>use v6;

use Test;

plan 3;

# L<S12/"Calling sets of methods"/"It is also possible to trim the candidate list so that the current call is considered the final candidate.">

class Foo {
    # $.tracker is used to determine the order of calls.
    has $.tracker is rw;
    method doit()  {$.tracker ~= 'foo,'}
    method doit(Int $num) {$.tracker ~= 'fooint,'}
    method show  {$.tracker}
    method clear {$.tracker = ''}
}

class BarLastCallSame is Foo {
    multi method doit($foo) {$.tracker ~= 'bar,'; lastcall; $.tracker ~= 'ret1,'}
    multi method doit(Int $num) {$.tracker ~= 'barint,'; callsame; $.tracker ~= 'ret2,'}
}

{
    my $o = BarLastCallSame.new;
    $o.clear;
    $o.doit("");
    is($o.show, 'bar,ret1,', 'lastcall inheritance test');
    $o.clear;
    is($o.show, '', 'sanity test for clearing');
    $o.doit(5);
    is($o.show, 'barint,bar,ret1,ret2,', 'lastcall multimethod/inheritance test');
}

# vim: ft=perl6
{'fraction_non_alphanumeric': 0.17511520737327188, 'fraction_numerical': 0.011264720942140297, 'mean_word_length': 3.420814479638009, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6399795', 'n_tokens_mistral': 721, 'n_tokens_neox': 717, 'n_words': 209}