Skip to content

Commit

Permalink
Give PL/Perl6 tests their own home
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Jun 25, 2010
1 parent 69c39b5 commit 3058930
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -3,7 +3,8 @@ MODULE_big = plparrot
OBJS= plparrot.o
DATA_built = plparrot.sql
REGRESS_OPTS = --dbname=$(PL_TESTDB) --load-language=plpgsql
TESTS = $(wildcard t/sql/*.sql)
TESTS = t/sql/test.sql
PLPERL6_TESTS = t/sql/plperl6.sql
REGRESS = $(patsubst t/sql/%.sql,%,$(TESTS))

EXTRA_CLEAN =
Expand Down Expand Up @@ -60,3 +61,6 @@ endif

test: all
psql -AX -f $(TESTS)

test_plperl6: all
psql -AX -f $(PLPERL6_TESTS)
6 changes: 6 additions & 0 deletions plparrot.c
Expand Up @@ -397,6 +397,9 @@ plperl6u_call_handler(PG_FUNCTION_ARGS)
{
Datum retval;
interp = p6_interp;
if(!interp) {
elog(ERROR,"Invalid Parrot interpreter!");
}
retval = plperl6_call_handler(fcinfo);
interp = trusted_interp;
return retval;
Expand All @@ -409,6 +412,9 @@ plperl6_call_handler(PG_FUNCTION_ARGS)
TriggerData *tdata;

interp = p6_interp;
if(!interp) {
elog(ERROR,"Invalid Parrot interpreter!");
}
PG_TRY();
{
if (CALLED_AS_TRIGGER(fcinfo)) {
Expand Down
34 changes: 34 additions & 0 deletions t/sql/plperl6.sql
@@ -0,0 +1,34 @@
\unset ECHO
\set QUIET 1
-- Turn off echo and keep things quiet.
-- Format the output for nice TAP.
\pset format unaligned
\pset tuples_only true
\pset pager
-- Revert all changes on failure.
\set ON_ERROR_ROLLBACK 1
\set ON_ERROR_STOP true

-- Load the TAP functions.
BEGIN;
\i pgtap.sql
\i plparrot.sql

-- Plan the tests.
SELECT plan(3);

CREATE FUNCTION test_void_plperl6(integer) RETURNS void AS $$ Nil $$ LANGUAGE plperl6;

CREATE FUNCTION test_int_plperl6(integer) RETURNS int AS $$ 42 $$ LANGUAGE plperl6;

CREATE FUNCTION test_float_plperl6(integer) RETURNS float AS $$ 5.0 $$ LANGUAGE plperl6;


select is(test_int_plperl6(89),42,'Return an integer from PL/Perl6');
select is(test_void_plperl6(42)::text,''::text,'Return nothing from PL/Perl6');
select is(test_float_plperl6(2),5.0::float,'Return a float from PL/Perl6');

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

rollback;
13 changes: 1 addition & 12 deletions t/sql/test.sql
Expand Up @@ -15,7 +15,7 @@ BEGIN;
\i plparrot.sql

-- Plan the tests.
SELECT plan(33);
SELECT plan(31);

CREATE OR REPLACE FUNCTION create_plparrot()
RETURNS BOOLEAN
Expand All @@ -25,12 +25,6 @@ CREATE LANGUAGE plparrot;
SELECT true;
$$;

CREATE FUNCTION test_void_plperl6(integer) RETURNS void AS $$ Nil $$ LANGUAGE plperl6;

CREATE FUNCTION test_int_plperl6(integer) RETURNS int AS $$ 42 $$ LANGUAGE plperl6;

CREATE FUNCTION test_float_plperl6(integer) RETURNS float AS $$ 5.0 $$ LANGUAGE plperl6;

CREATE FUNCTION test_void() RETURNS void AS $$
.return()
$$ LANGUAGE plparrot;
Expand Down Expand Up @@ -266,11 +260,6 @@ select is(test_timestamptz_out('1999-01-08 04:05:06+02'),'1999-01-08 04:05:06+02
select is(test_time_in('04:05:06'),1,'We can pass a time in');
select is(test_time_out('04:05:06'),'04:05:06','We can return a time');

select is(test_int_plperl6(89),42,'Return an integer from PL/Perl6');
select is(test_void_plperl6(42)::text,''::text,'Return nothing from PL/Perl6');
select is(test_float_plperl6(2),5.0::float,'Return a float from PL/Perl6');


-- not loading io opcodes, they are deprecated
--select isnt(test_open_plparrotu(), 42, 'open opcode is not mocked in plperlu');

Expand Down

0 comments on commit 3058930

Please sign in to comment.