X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=t%2Flei_external.t;fp=t%2Flei_external.t;h=0ef6633df0282e84c4cf91dff7c1e349c2b3244c;hb=dd80cd59cf0c90d61257fbfe8176e3312edbb841;hp=587990db53753adecc2461e061d5ce086fff28f2;hpb=04b73104416e4734b3a01e47525119cac867065a;p=public-inbox.git diff --git a/t/lei_external.t b/t/lei_external.t index 587990db..0ef6633d 100644 --- a/t/lei_external.t +++ b/t/lei_external.t @@ -1,7 +1,8 @@ #!perl -w -use strict; -use v5.10.1; -use Test::More; +# Copyright (C) 2020-2021 all contributors +# License: AGPL-3.0+ +# internal unit test, see t/lei-externals.t for functional tests +use strict; use v5.10.1; use Test::More; my $cls = 'PublicInbox::LeiExternal'; require_ok $cls; my $canon = $cls->can('ext_canonicalize'); @@ -15,4 +16,17 @@ is($canon->('/this/path/is/nonexistent/'), '/this/path/is/nonexistent', is($canon->('/this//path/'), '/this/path', 'extra slashes gone'); is($canon->('/ALL/CAPS'), '/ALL/CAPS', 'caps preserved'); +my $glob2re = $cls->can('glob2re'); +is($glob2re->('foo'), undef, 'plain string unchanged'); +is_deeply($glob2re->('[f-o]'), '[f-o]' , 'range accepted'); +is_deeply($glob2re->('*'), '[^/]*?' , 'wildcard accepted'); +is_deeply($glob2re->('{a,b,c}'), '(a|b|c)' , 'braces'); +is_deeply($glob2re->('{,b,c}'), '(|b|c)' , 'brace with empty @ start'); +is_deeply($glob2re->('{a,b,}'), '(a|b|)' , 'brace with empty @ end'); +is_deeply($glob2re->('{a}'), undef, 'ungrouped brace'); +is_deeply($glob2re->('{a'), undef, 'open left brace'); +is_deeply($glob2re->('a}'), undef, 'open right brace'); +is_deeply($glob2re->('*.[ch]'), '[^/]*?\\.[ch]', 'suffix glob'); +is_deeply($glob2re->('{[a-z],9,}'), '([a-z]|9|)' , 'brace with range'); + done_testing;