# LeadingDistinct.t test LeadingDistinct.pm 15jun15waw use warnings; use strict; use Test::More # tests => ?? + 1 # Test::NoWarnings adds 1 test 'no_plan' ; use Test::NoWarnings; # normal tokens (alpha and underscore). use constant TOKENS => qw/ab abcd abcdef ghi ghij ghijk lnm lnmopq lnmopqrst uvw xyz dcba edcba xyzzy xyzzz pqrst pqrtu report_time report_day reset read /; use constant TOKENS_AND_UNIQUE => ( ab => 'ab', abcd => 'abcd', abcdef => 'abcde', dcba => 'd', edcba => 'e', ghi => 'ghi', ghij => 'ghij', ghijk => 'ghijk', lnm => 'lnm', lnmopq => 'lnmopq', lnmopqrst => 'lnmopqr', pqrst => 'pqrs', pqrtu => 'pqrt', read => 'rea', report_day => 'report_d', report_time => 'report_t', reset => 'res', uvw => 'u', xyz => 'xyz', xyzzy => 'xyzzy', xyzzz => 'xyzzz', ); # some tokens to test handling of metacharacters. use constant WEIRD_TOKENS => qw(foo? foo?* foo+++ foo?*+ foo???); use constant WEIRD_TOKENS_AND_UNIQUE => ( 'foo+++' => 'foo+', 'foo?' => 'foo?', 'foo?*' => 'foo?*', 'foo?*+' => 'foo?*+', 'foo???' => 'foo??', ); BEGIN { use_ok 'LeadingDistinct'; } is_deeply { LeadingDistinct::extract(TOKENS) }, { TOKENS_AND_UNIQUE }, "normal chars: alphas & underscores"; is_deeply { LeadingDistinct::extract(TOKENS, WEIRD_TOKENS) }, { TOKENS_AND_UNIQUE, WEIRD_TOKENS_AND_UNIQUE }, "normal chars and some metacharacters";