Skip to content

Commit

Permalink
Add test for summing Fibonacci numbers in PL/Perl6
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Jun 29, 2010
1 parent 2d116c7 commit 6e63680
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion t/sql/plperl6.sql
Expand Up @@ -15,12 +15,16 @@ BEGIN;
\i plparrot.sql

-- Plan the tests.
SELECT plan(5);
SELECT plan(6);

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_fibonacci_plperl6(integer) RETURNS int AS $$
[+] (1, 1, *+* ... 100)
$$ LANGUAGE plperl6;

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

CREATE FUNCTION test_string_plperl6() RETURNS varchar AS $$ "rakudo" $$ LANGUAGE plperl6;
Expand All @@ -33,6 +37,8 @@ select is(test_float_plperl6(2), 5.0::float,'Return a float from PL/Perl6');
select is(test_string_plperl6(), 'rakudo','Return a varchar from PL/Perl6');
select is(test_singlequote_plperl6(), 'rakudo*','Use a single quote in a PL/Perl6 procedure');

select is(test_fibonacci_plperl6(1),232,'Calculate the sum of all Fibonacci numbers <= 100');

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

Expand Down

0 comments on commit 6e63680

Please sign in to comment.