2 # Copyright (C) 2001-2005, Parrot Foundation.
7 use lib qw( t . lib ../lib ../../lib );
9 use Parrot::Test qw/ no_plan /;
10 use Parrot::Test::PGE;
18 % prove -Ilib t/library/pge.t
22 Parrot Grammar Engine basic tests
26 ## definition of PGE public api
27 ## data format like: filename => { 'namespace' => [list of subs], ... },
29 'PGE.pir' => { 'PGE' => [qw/ /], },
30 'PGE/Exp.pir' => { 'PGE::Exp' => [qw/ root_pir /], },
34 next from to __get_bool __get_integer __get_number
35 __get_string __get_pmc_keyed_int __set_pmc_keyed_int
36 __delete_keyed_int __defined_keyed_int list hash
40 'PGE/OPTable.pir' => { 'PGE::OPTable' => [qw/ newtok parse /], },
41 'PGE/Perl6Regex.pir' => {
43 'PGE::Exp' => [qw/ /],
44 'PGE::Perl6Regex' => [qw/ /],
49 ident null fail upper lower alpha digit xdigit space
50 print graph blank cntrl punct alnum sp lt gt dot ws before
54 'PGE/TokenHash.pir' => { 'PGE::TokenHash' => [qw/ /], },
57 ## populate_namespaces -- populate many namespaces with a subname
58 ## data format like: subname => [qw/ list of namespaces /],
59 ## my $p6r_subs = { p6analyze => [qw/ Literal /], };
60 ## populate_namespaces( $ns_subs, $p6r_subs, 'PGE/Perl6Regex.pir', 'PGE::Exp' );
61 sub populate_namespaces {
62 my ( $outdata_ref, $indata_ref, $filekey, $nsprefix ) = @_;
63 for my $key ( sort keys %$indata_ref ) {
64 push @{ $outdata_ref->{$filekey}{ $nsprefix . '::' . $_ } } => $key
65 for @{ $indata_ref->{$key} };
71 load_bytecode 'PGE.pbc'
82 pir_output_is( <<'CODE'. $POST, <<OUT, 'load_bytecode PGE.pbc' );
84 load_bytecode 'PGE.pbc'
90 pir_output_is( <<'CODE'. $POST, <<OUT, 'load_bytecode PGE.pbc 2x' );
92 load_bytecode 'PGE.pbc'
93 load_bytecode 'PGE.pbc'
98 ## compiler registration
99 for my $compiler (qw/ PGE::Perl6Regex PGE::Perl6Regex PGE::P5Regex PGE::Glob /) {
100 pir_output_is( <<"CODE". $POST, <<OUT, 'compreg "$compiler"' );
102 load_bytecode 'PGE.pbc'
103 \$P0 = compreg '$compiler'
110 for my $file ( sort keys %$ns_subs ) {
111 for my $ns ( sort keys %{ $ns_subs->{$file} } ) {
112 for my $sub ( sort @{ $ns_subs->{$file}{$ns} } ) {
114 pir_output_is( <<CODE. $POST, <<OUT, 'get_global $file: ($ns:: $sub)' );
116 load_bytecode 'PGE.pbc'
118 sub = get_global ['$ns'], '$sub'
128 # cperl-indent-level: 4
131 # vim: expandtab shiftwidth=4: