1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
use Test2::V0;
plan 29;
use String::Copyright {
format => sub { join ':', $_->[0] || '', $_->[1] || '' }
};
is copyright("© 1999,2000 \n , 2001 ,2002, 2003 Foo"),
'1999-2003:Foo',
'comma list';
is copyright("© 1999,2000 \n 2001 ,2002, 2003 Foo"),
'1999-2003:Foo',
'non-comma list';
is copyright("© 1999-2000 , 2001 - 2002\n, 2003 Foo"),
'1999-2003:Foo',
'single-year ranges';
is copyright("© 1999-2000 , 2001\n - 2002\n, 2003 Foo"),
'1999-2001:2002',
'range w/ newline before hyphen and before comma';
is copyright("© 1999,2000,2003,2005,2006 Foo"),
'1999-2000, 2003, 2005-2006:Foo',
'range non-range range';
is copyright("© 1999-2000 , 2001 -\n 2002\n, 2003 Foo"),
'1999-2003:Foo',
'range w/ newline after hyphen';
is copyright("© 1999-2002, 2003 Foo"), '1999-2003:Foo', 'multi-year ranges';
is copyright("© 1999\n, 2003 Foo"),
'1999, 2003:Foo',
'newline before year-delimiting comma';
is copyright("© 1999-2000 -2004-2005 Foo"),
'1999-2000:-2004-2005 Foo',
'broken range - bogus multi-range';
is copyright("(c) <year> Foo"),
'', 'bogus dummy year "<year>"';
is copyright("Copyright (C) 19xx name of author"),
'', 'bogus dummy year "19xx"';
is copyright("(c) 19yy Foo"),
'', 'bogus dummy year "19yy"';
is copyright("(c) yyyy Foo"),
'', 'bogus dummy year "yyyy"';
my $todo = todo 'not yet handled';
is copyright("© 1999-2000-2004-2005 Foo"),
':1999-2000-2004-2005 Foo',
'broken range - bogus multi-nonspace-range';
is copyright("© 1999-2000-2005-2004 Foo"),
'1999-2000-2005-2004:Foo',
'broken range - bogus multi-range wrong order';
is copyright("© 1999,2000 \n - 2000 ,2002, 2003 \nFoo"),
'1999-2000, 2002-2003:Foo',
'broken range - same year';
is copyright("© 1999,2000 \n - 1999 ,2002, 2003 \nFoo"),
'1999, 2000:- 1999, 2002-2003 Foo',
'broken range - earlier year';
$todo = undef;
is copyright("© 1999,2000 , 2001 ,200\n2, 2003 Foo"),
'1999-2001:200',
'broken range - newline in year';
is copyright("© 1999"), '1999:', 'owner-less year';
is copyright("© . 1999"), '', 'bogus owner-less year starting with dot';
is copyright("© , 1999, 2000"), '1999-2000:', 'initial comma';
is copyright("© -1999, 2000"),
':-1999, 2000',
'not-treated-as-year starting with dash';
is copyright("© 2001, 2001"), '2001:', 'duplicate year';
is copyright("© 2001-2001"), '2001:', 'single-year range';
is copyright("© 2002-2000"), '2000-2002:', 'backwards range';
$todo = todo 'not yet handled';
is copyright("© 2000-03"), '2000-2003:', 'sloppy range-end, 2 digits';
is copyright("© 2005-7"), '2005-2007:', 'sloppy range-end, 1 digit';
is copyright("Copyright (c) Foo, 2000"), '2000:Foo', 'year at end';
is copyright("Copyright (c) Foo, 2000,\n 2001"),
'2000-2001:Foo',
'year at end and next line';
done_testing;
|