11-opts.t 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!perl -T
  2. use strict;
  3. use warnings;
  4. use Test::More tests => 10;
  5. use Regexp::Wildcards;
  6. my $rw = Regexp::Wildcards->new();
  7. my $wc = 'a,b{c,d}e*f?(g)';
  8. my $none = quotemeta $wc;
  9. my $unix = 'a\\,b(?:c|d)e.*f.\\(g\\)';
  10. my $win32 = '(?:a|b\{c|d\}e.*f.\\(g\\))';
  11. my $jokers = 'a\\,b\\{c\\,d\\}e.*f.\\(g\\)';
  12. my $groups = 'a\\,b\\{c\\,d\\}e\\*f\\?(g)';
  13. my $jok_gr = 'a\\,b\\{c\\,d\\}e.*f.(g)';
  14. is($rw->convert($wc), $unix, 'nothing defaults to unix');
  15. $rw->type('win32');
  16. is($rw->convert($wc), $win32, 'set to win32');
  17. $rw->type('darwin');
  18. is($rw->convert($wc), $unix, 'set to darwin');
  19. $rw->type('MSWin32');
  20. is($rw->convert($wc), $win32, 'reset to win32');
  21. $rw->type();
  22. is($rw->convert($wc), $unix, 'reset to unix');
  23. $rw = Regexp::Wildcards->new(do => [ qw<jokers> ], type => 'win32');
  24. is($rw->convert($wc), $jokers, 'do overrides type in new');
  25. $rw->do(add => 'groups');
  26. is($rw->convert($wc), $jok_gr, 'added groups to jokers');
  27. $rw->do(add => 'jokers');
  28. is($rw->convert($wc), $jok_gr, 'added jokers but it already exists');
  29. $rw->do(rem => 'jokers');
  30. is($rw->convert($wc), $groups, 'removed jokers, only groups remains');
  31. $rw->do();
  32. is($rw->convert($wc), $none, 'reset do');