Skip to content

Commit

Permalink
Add a Fibonacci test using placeholder variables in PL/Perl6
Browse files Browse the repository at this point in the history
  • Loading branch information
leto committed Aug 17, 2010
1 parent 7532acb commit ba187db
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion t/sql/plperl6.sql
Expand Up @@ -15,7 +15,7 @@ BEGIN;
\i plparrot.sql

-- Plan the tests.
SELECT plan(14);
SELECT plan(15);

CREATE OR REPLACE FUNCTION test_void_plperl6() RETURNS void LANGUAGE plperl6 AS $$
{ Nil }
Expand Down Expand Up @@ -54,6 +54,12 @@ CREATE OR REPLACE FUNCTION test_named_fibonacci_plperl6(integer) RETURNS int LAN
}
$$;

CREATE OR REPLACE FUNCTION test_placeholder_fibonacci_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$
{
[+] (1, 1, *+* ... $^limit)
}
$$;

CREATE OR REPLACE FUNCTION test_input_2_placeholders(integer, integer) RETURNS int LANGUAGE plperl6 AS $$
{
return $^a * $^b - $^b;
Expand Down Expand Up @@ -94,6 +100,7 @@ select is(test_named_pointy(10,20,30), 6000, 'Pointy blocks with named parameter

select is(test_named_fibonacci_plperl6(100),232,'Calculate the sum of all Fibonacci numbers <= 100 (named variable in signature)');
select is(test_fibonacci_plperl6(100),232,'Calculate the sum of all Fibonacci numbers <= 100');
select is(test_placeholder_fibonacci_plperl6(100),232,'Calculate the sum of all Fibonacci numbers <= 100 (placeholder variable)');

SELECT language_is_trusted( 'plperl6', 'PL/Perl6 should be trusted' );

Expand Down

0 comments on commit ba187db

Please sign in to comment.