root/trunk/db-tests/plperl/0001-basics.sql

Revision 71, 2.1 kB (checked in by depesz, 4 years ago)

db-tests framework. Currently tests plperl if it works sanely

Line 
1 \set ECHO
2 \set QUIET 1
3
4 \pset format unaligned
5 \pset tuples_only true
6 \pset pager
7
8 \set ON_ERROR_ROLLBACK 1
9 \set ON_ERROR_STOP true
10 \set QUIET 1
11
12 BEGIN;
13     SELECT plan(18);
14
15     SELECT lives_ok( 'CREATE LANGUAGE plperl', 'Language creation should work fine?!' );
16
17     SELECT throws_ok( 'CREATE function x() RETURNS TEXT as $$xx++$$ language plperl');
18
19     SELECT throws_ok( 'CREATE function x() RETURNS TEXT as $$use Data::Dumper;$$ language plperl');
20
21     SELECT lives_ok( 'CREATE function x_text() RETURNS TEXT as $$return "Test String"$$ language plperl', 'Returning TEXT');
22     SELECT ok( x_text() = 'Test String'::TEXT, 'Simple call to function returning TEXT');
23
24     SELECT lives_ok( 'CREATE function x_int4() RETURNS INT4 as $$return 567123$$ language plperl', 'Returning INT4');
25     SELECT ok( x_int4() = 567123::INT4, 'Simple call to function returning INT4');
26
27     SELECT lives_ok( 'CREATE function x_numeric() RETURNS NUMERIC as $$return 123.456$$ language plperl', 'Returning NUMERIC');
28     SELECT ok( x_numeric() = 123.456::NUMERIC, 'Simple call to function returning NUMERIC');
29
30     SELECT lives_ok( 'CREATE function x_timestamptz() RETURNS TIMESTAMPTZ as $$return q{2008-02-28 17:56:23 EDT}$$ language plperl', 'Returning TIMESTAMPTZ');
31     SELECT ok( x_timestamptz() = '2008-02-29 07:56:23 AEST'::TIMESTAMPTZ, 'Simple call to function returning TIMESTAMPTZ');
32
33     SELECT lives_ok( 'CREATE function y_text(TEXT) RETURNS TEXT as $$return scalar reverse shift$$ language plperl', 'Taking and returning TEXT');
34     SELECT ok( y_text('OmniTI') = 'ITinmO', 'Simple call to function processing TEXT');
35
36     SELECT lives_ok( 'CREATE function y_int4(INT4) RETURNS INT4 as $$return $_[0] / 2$$ language plperl', 'Taking and returning INT4');
37     SELECT throws_ok( 'SELECT y_int4(3) = 1' );
38     SELECT ok( y_int4(4) = 2, 'Simple call to function processing INT4');
39
40     SELECT lives_ok( 'CREATE function y_numeric(NUMERIC) RETURNS NUMERIC as $$return $_[0] / 2$$ language plperl', 'Taking and returning NUMERIC');
41     SELECT ok( y_numeric(5) = 2.5, 'Simple call to function processing NUMERIC');
42
43     SELECT * FROM finish();
44 ROLLBACK;
Note: See TracBrowser for help on using the browser.