Skip to content

Commit

Permalink
[t] Fix Parrot_PMC_modulus test and add Parrot_PMC_divide
Browse files Browse the repository at this point in the history
It seems that these functions take three arguments, but nothing
is done with the third argument. The function signatures of
Parrot_PMC_modulus, Parrot_PMC_divide and all similar functions
should probably be deprecated and either changed to:

1) take 2 arguments and return 1 value
2) return void and take 3 arguments

I think for unification with future design principles (such as
fixed width opcodes that return void), that option 2) should
be persued, but this issue needs to be brought up on parrot-dev.
  • Loading branch information
leto committed Jan 1, 2011
1 parent 6b2b50f commit d170bd5
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions t/src/embed.t
Expand Up @@ -10,7 +10,7 @@ use File::Spec::Functions;

plan skip_all => 'src/parrot_config.o does not exist' unless -e catfile(qw/src parrot_config.o/);

plan tests => 20;
plan tests => 21;

=head1 NAME
Expand Down Expand Up @@ -370,6 +370,49 @@ CODE
Done!
OUTPUT


c_output_is($common . linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Parrot_PMC_divide" );
int main(void)
{
Parrot_Interp interp;
Parrot_PMC pmc, pmc2, pmc3;
Parrot_Int type, value;
/* Create the interpreter */
interp = new_interp();
type = Parrot_PMC_typenum(interp, "Integer");
pmc = Parrot_PMC_new(interp, type);
pmc2 = Parrot_PMC_new(interp, type);
pmc3 = Parrot_PMC_new(interp, type);
Parrot_PMC_set_integer_native(interp, pmc, 42);
Parrot_PMC_set_integer_native(interp, pmc2, 21);
Parrot_PMC_set_integer_native(interp, pmc3, 0);
/*
We must pass in the destination, but the return
value of the function must be used. This is broken.
*/
pmc3 = Parrot_PMC_divide(interp, pmc, pmc2, pmc3);
value = Parrot_PMC_get_integer(interp, pmc);
printf("%d\n", (int) value);
value = Parrot_PMC_get_integer(interp, pmc2);
printf("%d\n", (int) value);
value = Parrot_PMC_get_integer(interp, pmc3);
printf("%d\n", (int) value);
Parrot_destroy(interp);
printf("Done!\n");
return 0;
}
CODE
42
21
2
Done!
OUTPUT

# Bug in modulus? Needs a TT
c_output_is($common . linedirective(__LINE__) . <<'CODE', <<'OUTPUT', "Parrot_PMC_modulus" );
Expand All @@ -391,7 +434,7 @@ int main(void)
Parrot_PMC_set_integer_native(interp, pmc2, 42);
Parrot_PMC_set_integer_native(interp, pmc3, 0);
Parrot_PMC_modulus(interp, pmc, pmc2, pmc3);
pmc3 = Parrot_PMC_modulus(interp, pmc, pmc2, pmc3);
value = Parrot_PMC_get_integer(interp, pmc);
printf("%d\n", (int) value);
value = Parrot_PMC_get_integer(interp, pmc2);
Expand Down

0 comments on commit d170bd5

Please sign in to comment.