File: 50_context.t

package info (click to toggle)
libstring-copyright-perl 0.003014-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 284 kB
  • sloc: perl: 177; makefile: 2; sh: 1
file content (91 lines) | stat: -rw-r--r-- 2,729 bytes parent folder | download
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
use Test2::V0;

plan 23;

use String::Copyright {
	format => sub { join ':', $_->[0] || '', $_->[1] || '' }
};

is copyright('This software is copyright (c) 2016 by Foo'), '2016:Foo',
	'sign pseudosign intro';
is copyright('This software is (c) copyright 2016 by Foo'), '2016:Foo',
	'pseudosign sign intro';

is copyright("Copyright:\n2000 Foo"), '2000:Foo', 'sign then newline';
is copyright("Copyright:\n!not Foo"), '', 'sign then newline then non-owner';

is copyright("#define foo(c) 1999 Foo"), '', 'bogus sign';

is copyright("(c) 1999 Foo\n#define foo(c) 1999 Bar"),
	'1999:Foo',
	'sign, then bogus sign';

is copyright("#define foo(c) 1999 Foo\n(c) 1999 Bar"),
	'1999:Bar',
	'bogus sign, then sign';

is copyright("(c) 1999 Foo #define foo(c) 1999 Bar"),
	'1999:Foo #define foo(c) 1999 Bar',
	'sign, then bogus sign on same line';

is copyright("#define foo(c) 1997 Foo (c) 1999 Bar"),
	'1999:Bar',
	'bogus sign, then sign on same line';

is copyright("(c) 1999 Foo (c) 2000 Foo (c) 2002 Foo"),
	'1999:Foo (c) 2000 Foo (c) 2002 Foo',
	'sign x 3 on same line';

my $todo = todo 'not yet handled';
is copyright("(c) 2000 Foo\n    2005 Bar\n2008 Baz"),
	":2000:Foo\n2005:Bar\n2008:Baz",
	'multi-line multi-statement';

is copyright("Copyright:\n2000 Foo\n2000 Bar"),
	"2000:Foo\n2000:Bar",
	'multi-line multi-statement after single sign';

is copyright("Copyright:\nFoo\nBar\n\nBaz"),
	":Foo\n:Bar",
	'multi-line owner-only multi-statement after single sign';

is copyright("Copyright:\n2000\n2001\nFoo\n\n2002"),
	"2000-2000:\n:Foo",
	'multi-line year-only multi-statement after single sign';
$todo = undef;

is copyright(
	"Copyright (C) 2004 - 2005\n\nSee http://foo.bar for more information"),
	'2004-2005:',
	'years-only, with unrelated text after double-newline';

is copyright("* Note, the copyright information is at end of file."), '',
	'non-sign and space';

is copyright("* For copyright information, see copyright.h."), '',
	'non-sign and punctuation';

is copyright('covered under the following copyright and permission notice:'),
	'',
	'chatter involving "and"';

is copyright(" if (ref \$copyright eq 'ARRAY') {"), '',
	'chatter involving "eq"';

is copyright('the above copyright  notice, this list'), '',
	'chatter with double whitespace';
is copyright(
	"=head1 COPYRIGHT AND LICENSE\n\nThis software is (c) copyright 2016 by Foo"
	), '2016:Foo',
	'chatter then copyright';

is copyright("Copyright ?1991-2012 Unicode, Inc."),
	'1991-2012:Unicode, Inc.',
	'broken copyright sign';

is copyright(
	"Copyright 1991-2012 Unicode, Inc. All rights reserved. Distributed under the Terms of Use in http://www.unicode.org/copyright.html."
	), '1991-2012:Unicode, Inc.',
	'boilerplate then chatter';

done_testing;