1#!./perl
2
3#
4# Ensure that syntax using colons (:) is parsed correctly.
5# The tests are done on the following tokens (by default):
6# ABC LABEL XYZZY m q qq qw qx s tr y AUTOLOAD and alarm 
7#	-- Robin Barker <rmb@cise.npl.co.uk>
8#
9
10BEGIN {
11    chdir 't' if -d 't';
12    @INC = '../lib';
13}
14
15use strict;
16
17$_ = '';	# to avoid undef warning on m// etc.
18
19sub ok {
20    my($test,$ok) = @_;
21    print "not " unless $ok;
22    print "ok $test\n";
23}
24
25$SIG{__WARN__} = sub { 1; }; # avoid some spurious warnings
26
27print "1..25\n";
28
29ok 1, (eval "package ABC; sub zyx {1}; 1;" and
30	eval "ABC::zyx" and
31	not eval "ABC:: eq ABC||" and
32	not eval "ABC::: >= 0");
33
34ok 2, (eval "package LABEL; sub zyx {1}; 1;" and
35	eval "LABEL::zyx" and
36	not eval "LABEL:: eq LABEL||" and
37	not eval "LABEL::: >= 0");
38
39ok 3, (eval "package XYZZY; sub zyx {1}; 1;" and
40	eval "XYZZY::zyx" and
41	not eval "XYZZY:: eq XYZZY||" and
42	not eval "XYZZY::: >= 0");
43
44ok 4, (eval "package m; sub zyx {1}; 1;" and
45	not eval "m::zyx" and
46	eval "m:: eq m||" and
47	not eval "m::: >= 0");
48
49ok 5, (eval "package q; sub zyx {1}; 1;" and
50	not eval "q::zyx" and
51	eval "q:: eq q||" and
52	not eval "q::: >= 0");
53
54ok 6, (eval "package qq; sub zyx {1}; 1;" and
55	not eval "qq::zyx" and
56	eval "qq:: eq qq||" and
57	not eval "qq::: >= 0");
58
59ok 7, (eval "package qw; sub zyx {1}; 1;" and
60	not eval "qw::zyx" and
61	eval "qw:: eq qw||" and
62	not eval "qw::: >= 0");
63
64ok 8, (eval "package qx; sub zyx {1}; 1;" and
65	not eval "qx::zyx" and
66	eval "qx:: eq qx||" and
67	not eval "qx::: >= 0");
68
69ok 9, (eval "package s; sub zyx {1}; 1;" and
70	not eval "s::zyx" and
71	not eval "s:: eq s||" and
72	eval "s::: >= 0");
73
74ok 10, (eval "package tr; sub zyx {1}; 1;" and
75	not eval "tr::zyx" and
76	not eval "tr:: eq tr||" and
77	eval "tr::: >= 0");
78
79ok 11, (eval "package y; sub zyx {1}; 1;" and
80	not eval "y::zyx" and
81	not eval "y:: eq y||" and
82	eval "y::: >= 0");
83
84ok 12, (eval "ABC:1" and
85	not eval "ABC:echo: eq ABC|echo|" and
86	not eval "ABC:echo:ohce: >= 0");
87
88ok 13, (eval "LABEL:1" and
89	not eval "LABEL:echo: eq LABEL|echo|" and
90	not eval "LABEL:echo:ohce: >= 0");
91
92ok 14, (eval "XYZZY:1" and
93	not eval "XYZZY:echo: eq XYZZY|echo|" and
94	not eval "XYZZY:echo:ohce: >= 0");
95
96ok 15, (not eval "m:1" and
97	eval "m:echo: eq m|echo|" and
98	not eval "m:echo:ohce: >= 0");
99
100ok 16, (not eval "q:1" and
101	eval "q:echo: eq q|echo|" and
102	not eval "q:echo:ohce: >= 0");
103
104ok 17, (not eval "qq:1" and
105	eval "qq:echo: eq qq|echo|" and
106	not eval "qq:echo:ohce: >= 0");
107
108ok 18, (not eval "qw:1" and
109	eval "qw:echo: eq qw|echo|" and
110	not eval "qw:echo:ohce: >= 0");
111
112ok 19, (not eval "qx:1" and
113	eval "qx:echo 1: eq qx|echo 1|" and	# echo without args may warn
114	not eval "qx:echo:ohce: >= 0");
115
116ok 20, (not eval "s:1" and
117	not eval "s:echo: eq s|echo|" and
118	eval "s:echo:ohce: >= 0");
119
120ok 21, (not eval "tr:1" and
121	not eval "tr:echo: eq tr|echo|" and
122	eval "tr:echo:ohce: >= 0");
123
124ok 22, (not eval "y:1" and
125	not eval "y:echo: eq y|echo|" and
126	eval "y:echo:ohce: >= 0");
127
128ok 23, (eval "AUTOLOAD:1" and
129	not eval "AUTOLOAD:echo: eq AUTOLOAD|echo|" and
130	not eval "AUTOLOAD:echo:ohce: >= 0");
131
132ok 24, (eval "and:1" and
133	not eval "and:echo: eq and|echo|" and
134	not eval "and:echo:ohce: >= 0");
135
136ok 25, (eval "alarm:1" and
137	not eval "alarm:echo: eq alarm|echo|" and
138	not eval "alarm:echo:ohce: >= 0");
139