Skip to content

Commit

Permalink
Comment out some stuff that is not quite right and refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Mar 17, 2010
1 parent 88fbe6e commit 1923558
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
9 changes: 8 additions & 1 deletion plparrot.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,21 @@ plparrot_call_handler(PG_FUNCTION_ARGS)
/* procstruct probably isn't valid after this ReleaseSysCache call, so don't use it anymore */
ReleaseSysCache(proctup);

// This makes the test_void test pass, but it is cheating, since it never compiles/runs the PIR
/*
if (returntype == VOIDOID)
PG_RETURN_VOID();

*/
// Why is this ever the right thing to do?
/*
if (fcinfo->nargs == 0)
PG_RETURN_NULL();
*/

/* Assume from here on out that the first argument type is the same as the return type */
retval = PG_GETARG_DATUM(0);

elog(NOTICE,"entering PG_TRY");
PG_TRY();
{
if (CALLED_AS_TRIGGER(fcinfo)) {
Expand All @@ -202,6 +208,7 @@ plparrot_call_handler(PG_FUNCTION_ARGS)
elog(ERROR, "Error compiling PIR function");
}
/* See Parrot's src/extend.c for interpretations of the third argument */
elog(NOTICE,"about to call compiled PIR string with Parrot_ext_call");
Parrot_ext_call(interp, func_pmc, "->");
}
}
Expand Down
21 changes: 12 additions & 9 deletions t/sql/test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,43 @@ CREATE LANGUAGE plparrot;
SELECT true;
$$;

CREATE FUNCTION test_void() RETURNS void AS $$ FAIL $$ LANGUAGE plparrot;
CREATE FUNCTION test_void() RETURNS void AS $$
.sub foo_void
.return()
.end
$$ LANGUAGE plparrot;

CREATE FUNCTION test_int() RETURNS int AS $$
.sub foo
.sub foo_int
.return(1)
.end
$$ LANGUAGE plparrot;

CREATE FUNCTION test_int_int(int) RETURNS int AS $$
.sub foo
.sub foo_int_int
.param int x
.return(x)
.end
$$ LANGUAGE plparrot;

CREATE FUNCTION test_float() RETURNS float AS $$
.sub foo
.param num x
.return(x)
.sub foo_float
.return(1.0)
.end
$$ LANGUAGE plparrot;

CREATE FUNCTION test_varchar() RETURNS varchar(5) AS $$
.sub foo
.sub foo_varchar
$S0 = 'cheese'
.return($S0)
.end
$$ LANGUAGE plparrot;

select is(test_void()::text,''::text,'We can return void');
select is(test_int(),1,'We can return an int');
select is(test_int_int(42),42,'We can return an int that was passed as an arg');
select is(test_void()::text,''::text,'We can return void');
select is(test_float(), 1.0::float ,'We can return a float');
select is(test_varchar(), 'cheese', 'We can return a varchar');
select is(test_int_int(42),42,'We can return an int that was passed as an arg');

-- Finish the tests and clean up.
SELECT * FROM finish();
Expand Down

0 comments on commit 1923558

Please sign in to comment.