fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / compilers / pge / pge_util.t
blob502f8a75a1d0d37239ad4fed7ea63b671c1adc3d
1 #! perl
2 # Copyright (C) 2001-2007, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( t . lib ../lib ../../lib );
8 use Test::More;
9 use Parrot::Test tests => 8;
10 use Parrot::Test::PGE;
12 =head1 NAME
14 t/library/pge_util.t
16 =head1 SYNOPSIS
18         % prove -Ilib t/library/pge_util.t
20 =head1 DESCRIPTION
22 Parrot Grammar Engine tests of utility rules
24 =cut
26 my $str = "How will this\nstring choose\nto explode?\n\nTest";
27 p6rule_error_like(
28     $str,
29     "expl <PGE::Util::die: 'kaboom'>",
30     qr/^kaboom at line 3, near "ode\?\\n\\n/, "die"
33 pir_output_is( <<'CODE', <<'OUT', "split /\\:+/, 'Foo::Bar::baz'" );
35 .sub main :main
36   load_bytecode 'PGE.pbc'
37   load_bytecode 'PGE/Util.pbc'
39   .local pmc split, p6rule, regex
40   split  = get_global ['PGE';'Util'], 'split'
41   p6rule = compreg 'PGE::Perl6Regex'
42   regex  = p6rule('\:+')
44   $P0 = split(regex, "Foo::Bar::baz")
45   $S0 = join "\n", $P0
46   print $S0
47   print "\n"
48 .end
50 CODE
51 Foo
52 Bar
53 baz
54 OUT
56 pir_output_is( <<'CODE', <<'OUT', "split /\\:+/, 'Foo::'" );
58 .sub main :main
59   load_bytecode 'PGE.pbc'
60   load_bytecode 'PGE/Util.pbc'
62   .local pmc split, p6rule, regex
63   split  = get_global ['PGE';'Util'], 'split'
64   p6rule = compreg 'PGE::Perl6Regex'
65   regex  = p6rule('\:+')
67   $P0 = split(regex, "Foo::")
68   $S0 = join "\n", $P0
69   print $S0
70   print "\n"
71 .end
73 CODE
74 Foo
75 OUT
77 pir_output_is( <<'CODE', <<'OUT', "split /\\:+/, '::Foo'" );
79 .sub main :main
80   load_bytecode 'PGE.pbc'
81   load_bytecode 'PGE/Util.pbc'
83   .local pmc split, p6rule, regex
84   split  = get_global ['PGE';'Util'], 'split'
85   p6rule = compreg 'PGE::Perl6Regex'
86   regex  = p6rule('\:+')
88   $P0 = split(regex, "::Foo")
89   $S0 = join "\n", $P0
90   print $S0
91   print "\n"
92 .end
94 CODE
96 Foo
97 OUT
99 pir_output_is( <<'CODE', <<'OUT', "split /\\:+/, 'Foo'" );
101 .sub main :main
102   load_bytecode 'PGE.pbc'
103   load_bytecode 'PGE/Util.pbc'
105   .local pmc split, p6rule, regex
106   split  = get_global ['PGE';'Util'], 'split'
107   p6rule = compreg 'PGE::Perl6Regex'
108   regex  = p6rule('\:+')
110   $P0 = split(regex, "Foo")
111   $S0 = join "\n", $P0
112   print $S0
113   print "\n"
114 .end
116 CODE
120 pir_output_is( <<'CODE', <<'OUT', "split /\\:/, 'Foo::Bar'" );
122 .sub main :main
123   load_bytecode 'PGE.pbc'
124   load_bytecode 'PGE/Util.pbc'
126   .local pmc split, p6rule, regex
127   split  = get_global ['PGE';'Util'], 'split'
128   p6rule = compreg 'PGE::Perl6Regex'
129   regex  = p6rule('\:')
131   $P0 = split(regex, "Foo::Bar")
132   $S0 = join "\n", $P0
133   print $S0
134   print "\n"
135 .end
137 CODE
143 pir_output_is( <<'CODE', <<'OUT', "split /\\:/, 'Foo::Bar::Baz', 2" );
145 .sub main :main
146   load_bytecode 'PGE.pbc'
147   load_bytecode 'PGE/Util.pbc'
149   .local pmc split, p6rule, regex
150   split  = get_global ['PGE';'Util'], 'split'
151   p6rule = compreg 'PGE::Perl6Regex'
152   regex  = p6rule('\:+')
154   $P0 = split(regex, "Foo::Bar::Baz", 2)
155   $S0 = join "\n", $P0
156   print $S0
157   print "\n"
158 .end
160 CODE
162 Bar::Baz
165 pir_output_is( <<'CODE', <<'OUT', "split /(a)(b)/, 'abracadabra'" );
167 .sub main :main
168   load_bytecode 'PGE.pbc'
169   load_bytecode 'PGE/Util.pbc'
171   .local pmc split, p6rule, regex
172   split  = get_global ['PGE';'Util'], 'split'
173   p6rule = compreg 'PGE::Perl6Regex'
174   regex  = p6rule('(a)(b)')
176   $P0 = split(regex, "abracadabra")
177   $S0 = join "-", $P0
178   print $S0
179   print "\n"
180 .end
182 CODE
183 -a-b-racad-a-b-ra
186 # Local Variables:
187 #   mode: cperl
188 #   cperl-indent-level: 4
189 #   fill-column: 100
190 # End:
191 # vim: expandtab shiftwidth=4: