Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Method on P6Invocation to check if we have more candidates, and tests…
… for it.
  • Loading branch information
jnthn committed May 5, 2009
1 parent 7609508 commit ee10f59
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/pmc/p6invocation.pmc
Expand Up @@ -117,4 +117,15 @@ pmclass P6Invocation need_ext dynpmc group perl6_group {
VTABLE_set_pmc_keyed_str(interp, lexpad, lexname, SELF);
return addr;
}

METHOD INTVAL have_more_candidates() {
PMC *candidates;
INTVAL position, result;

/* Get candidates and position, and check if we have more candidates. */
GETATTR_P6Invocation_candidate_list(interp, SELF, candidates);
GETATTR_P6Invocation_position(interp, SELF, position);
result = position < VTABLE_elements(interp, candidates);
RETURN(INTVAL result);
}
}
29 changes: 24 additions & 5 deletions t/pmc/p6invocation-1.t
Expand Up @@ -19,7 +19,7 @@ Test the P6Invocation PMC.
.loadlib 'perl6_group'

.sub 'main'
say "1..6"
say "1..9"

$P0 = new 'ResizablePMCArray'
$P1 = find_name 'first'
Expand All @@ -33,7 +33,7 @@ Test the P6Invocation PMC.

$P0()

say "ok 6"
say "ok 9"
.end

.sub 'first'
Expand All @@ -46,18 +46,37 @@ Test the P6Invocation PMC.
ok_3:
say "ok 3"

$P0()
$I0 = $P0.'have_more_candidates'()
if $I0 != 0 goto ok_4
print "not"
ok_4:
say "ok 4"

$P0()
.end

.sub 'second'
.lex '__CANDIATE_LIST__', $P0
say "ok 4"
say "ok 5"

$I0 = $P0.'have_more_candidates'()
if $I0 != 0 goto ok_6
print "not"
ok_6:
say "ok 6"

$P0()
.end

.sub 'third'
.lex '__CANDIATE_LIST__', $P0
say "ok 5"
say "ok 7"

$I0 = $P0.'have_more_candidates'()
if $I0 == 0 goto ok_8
print "not"
ok_8:
say "ok 8"
.end


Expand Down

0 comments on commit ee10f59

Please sign in to comment.