2 # Copyright (C) 2001-2005, Parrot Foundation.
7 use lib qw( t . lib ../lib ../../lib );
9 use Parrot::Test tests => 28;
10 use Parrot::Test::PGE;
18 % prove -Ilib t/library/pge_globs.t
22 Parrot Grammar Engine tests of globs
27 pgeglob_is( '', '', 'literal: empty string, empty pattern' );
28 pgeglob_isnt( '0', '', 'literal: empty pattern' );
29 pgeglob_isnt( '', '0', 'literal: empty string' );
30 pgeglob_is( 'abc', 'abc', 'literal' );
31 pgeglob_isnt( 'abc', 'abd', 'literal' );
34 pgeglob_is( 'bznza', 'b?n*a', "glob wildcards" );
35 pgeglob_is( 'bana', 'b?n*a', "glob wildcards" );
36 pgeglob_isnt( 'bnana', 'b?n*a', "glob wildcards" );
37 pgeglob_is( 'bnan', '?n?*', "glob wildcards" );
38 pgeglob_is( 'ana', '?n?*', "glob wildcards" );
39 pgeglob_isnt( 'an', '?n?*', "glob wildcards" );
42 pgeglob_is( 'orange', '[go]range', 'glob enumerated characters' );
43 pgeglob_is( 'grange', '[go]range', 'glob enumerated characters' );
44 pgeglob_isnt( 'ggrange', '[go]range', 'glob enumerated characters' );
45 pgeglob_isnt( 'borange', '[go]range', 'glob enumerated characters' );
46 pgeglob_isnt( 'arange', '[go]range', 'glob enumerated characters' );
47 pgeglob_is( 'a', '[^0-9]', 'glob enumerated characters' );
48 pgeglob_isnt( '4', '[^0-9]', 'glob enumerated characters' );
49 pgeglob_isnt( '0', '[^0-9]', 'glob enumerated characters' );
50 pgeglob_isnt( '9', '[^0-9]', 'glob enumerated characters' );
51 pgeglob_isnt( '4a', '[^0-9]', 'glob enumerated characters' );
52 pgeglob_isnt( 'aa', '[^0-9]', 'glob enumerated characters' );
53 pgeglob_is( '_', '[A-z]', '_ is between A and z' );
56 pgeglob_is( '', '*', 'glob empty string' );
57 pgeglob_isnt( '', '?', 'glob empty string' );
58 pgeglob_isnt( '', '[0]', 'glob empty string' );
59 pgeglob_isnt( '', '[^0]', 'glob empty string' );
62 pir_output_is( <<'CODE', <<'OUT', "Glob, alternate" );
65 load_bytecode "PGE.pbc"
66 load_bytecode "PGE/Glob.pbc"
68 .local pmc rule, globc
69 globc = compreg "PGE::Glob"
70 rule = globc.'compile'("{app,bet,cod}a")
102 rule = globc.'compile'("*{1,two,three}")
157 # cperl-indent-level: 4
160 # vim: expandtab shiftwidth=4: