Skip to content

Commit

Permalink
Add a two tests, one for a fibonacci using a pointy block, and for th…
Browse files Browse the repository at this point in the history
…e definedness of @_[0]
  • Loading branch information
leto committed Aug 3, 2010
1 parent 6a74227 commit c199d95
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion t/sql/plperl6.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN;
\i plparrot.sql

-- Plan the tests.
SELECT plan(10);
SELECT plan(12);

CREATE OR REPLACE FUNCTION test_void_plperl6(integer) RETURNS void LANGUAGE plperl6 AS $$
Nil
Expand All @@ -33,6 +33,10 @@ CREATE OR REPLACE FUNCTION test_defined_plperl6(integer) RETURNS int LANGUAGE pl
@_[0].defined
$$;

CREATE OR REPLACE FUNCTION test_defined_plperl6() RETURNS int LANGUAGE plperl6 AS $$
@_[0].defined
$$;

CREATE OR REPLACE FUNCTION test_2arguments_plperl6(integer,integer) RETURNS int LANGUAGE plperl6 AS $$
@_.elems
$$;
Expand All @@ -42,6 +46,12 @@ my $limit = @_[0];
[+] (1, 1, *+* ... $limit)
$$;

CREATE OR REPLACE FUNCTION test_pointy_fibonacci_plperl6(integer) RETURNS int LANGUAGE plperl6 AS $$
-> $limit {
[+] (1, 1, *+* ... $limit)
}(|@_);
$$;

CREATE OR REPLACE FUNCTION test_named_pointy(integer, integer, integer) RETURNS int LANGUAGE plperl6 AS $$
-> $a, $b, $c {
return $a * $b * $c;
Expand All @@ -61,8 +71,10 @@ 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(100),232,'Calculate the sum of all Fibonacci numbers <= 100');
select is(test_pointy_fibonacci_plperl6(100),232,'Calculate the sum of all Fibonacci numbers <= 100 (pointy block)');
select is(test_arguments_plperl6(5),5,'We can return an argument unchanged');
select is(test_defined_plperl6(100),1,'@_[0] is defined when an argument is passed in');
select is(test_defined_plperl6(),0,'@_[0] is not defined when an argument is not passed in');
select is(test_2arguments_plperl6(4,9),2,'PL/Perl sees multiple arguments');

select is(test_named_pointy(10,20,30), 6000, 'Pointy blocks with named parameters work');
Expand Down

0 comments on commit c199d95

Please sign in to comment.