3 # Copyright (C) 2006-2009, Parrot Foundation.
10 use Parrot::Test tests => 15;
13 ## test description key
14 # A args/params R results/returns
16 # I IREG S SREG P PREG N NREG
18 # u unnamed n named r required o optional
19 # m normal s slurpy E end
21 ## the section titles below refer to the row/column designation in the state table
24 pcc_ok( { args => "'abc'", params => ".param pmc abc" }, 'A C:Sum D:Pur' );
27 pcc_ok( { args => "'abc'", params => ".param pmc abc :slurpy" }, 'A C:Pum D:Purs' );
28 pcc_ok( { args => "'abc', 'def'", params => ".param pmc abc :slurpy" }, 'A C:Pum D:Purs' );
29 pcc_ok( { args => "'123'", params => ".param pmc abc" }, 'A C:Pum D:Pur' );
32 pcc_ok( { args => "", params => "" } );
36 { args => "123", params => ".param pmc x :named('x')" },
37 '/positional arg found, named arg expected/',
38 'positional found, named expected',
39 todo => 'cc processor state missing',
42 ## E -- not yet working
43 #pcc_like({args=>"x=>['123';'456'] :flat", params=>".param pmc x"},
44 # '/named arg found, positional param expected/',
45 # 'E1: named found, required param expected',
48 #pcc_like({args=>"x=>['123';'456'] :flat", params=>".param pmc x"},
49 # '/named arg found, required param expected/',
50 # 'E2: named found, required slurpy param expected',
55 { params => ".param pmc abc" },
56 '/too few positional arguments: 0 passed, 1 \(or more\) expected/',
57 'G1: argument underflow: required param',
61 { params => ".param pmc abc :slurpy" },
62 '/argument underflow: required slurpy param expected/',
63 'G2: argument underflow: required slurpy param',
67 pcc_ok( { params => ".param pmc abc :optional" }, 'G3: optional param may be empty', );
69 pcc_ok( { params => ".param pmc abc :optional :slurpy" },
70 'G4: optional slurpy param may be empty' );
73 { params => ".param pmc abc :named('x')" },
74 '/too few named arguments: no argument for required parameter \'x\'/',
75 'G5: argument underflow: named required param',
79 { params => ".param pmc abc :named('x') :slurpy" },
80 '/too few named arguments: no argument for required parameter \'x\'/',
81 'G6: argument underflow: named required slurpy param',
85 { params => ".param pmc abc :named('x') :optional" },
86 'G7: named optional param may be empty',
90 { params => ".param pmc abc :named('x') :optional :slurpy" },
91 'G8: named optional slurpy param may be empty',
94 pcc_ok( {}, 'G9: no args, no params' );
99 my ( $o, $desc, %todo ) = @_;
100 my $test = create(%$o);
101 pir_output_is( $test, "ok\n", $desc, %todo )
102 or !exists $todo{todo} && diag $test;
106 my ( $o, $exp, $desc, %todo ) = @_;
107 my $test = create(%$o);
108 pir_output_like( $test, $exp, $desc, %todo )
109 or !exists $todo{todo} && diag $test;
113 my ( $o, $exp, $desc, %todo ) = @_;
114 my $test = create(%$o);
115 pir_error_output_like( $test, $exp, $desc, %todo )
116 or !exists $todo{todo} && diag $test;
121 $o{$_} ||= '' for qw/args params returns results/;
130 $o{returns} 'foo'($o{args})
146 # cperl-indent-level: 4
149 # vim: expandtab shiftwidth=4: