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>
17 $_ = ''; # to avoid undef warning on m// etc.
21 print "not " unless $ok;
25 $SIG{__WARN__} = sub { 1; }; # avoid some spurious warnings
29 ok 1, (eval "package ABC; sub zyx {1}; 1;" and
31 not eval "ABC:: eq ABC||" and
32 not eval "ABC::: >= 0");
34 ok 2, (eval "package LABEL; sub zyx {1}; 1;" and
36 not eval "LABEL:: eq LABEL||" and
37 not eval "LABEL::: >= 0");
39 ok 3, (eval "package XYZZY; sub zyx {1}; 1;" and
41 not eval "XYZZY:: eq XYZZY||" and
42 not eval "XYZZY::: >= 0");
44 ok 4, (eval "package m; sub zyx {1}; 1;" and
47 not eval "m::: >= 0");
49 ok 5, (eval "package q; sub zyx {1}; 1;" and
52 not eval "q::: >= 0");
54 ok 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");
59 ok 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");
64 ok 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");
69 ok 9, (eval "package s; sub zyx {1}; 1;" and
71 not eval "s:: eq s||" and
74 ok 10, (eval "package tr; sub zyx {1}; 1;" and
75 not eval "tr::zyx" and
76 not eval "tr:: eq tr||" and
79 ok 11, (eval "package y; sub zyx {1}; 1;" and
81 not eval "y:: eq y||" and
84 ok 12, (eval "ABC:1" and
85 not eval "ABC:echo: eq ABC|echo|" and
86 not eval "ABC:echo:ohce: >= 0");
88 ok 13, (eval "LABEL:1" and
89 not eval "LABEL:echo: eq LABEL|echo|" and
90 not eval "LABEL:echo:ohce: >= 0");
92 ok 14, (eval "XYZZY:1" and
93 not eval "XYZZY:echo: eq XYZZY|echo|" and
94 not eval "XYZZY:echo:ohce: >= 0");
96 ok 15, (not eval "m:1" and
97 eval "m:echo: eq m|echo|" and
98 not eval "m:echo:ohce: >= 0");
100 ok 16, (not eval "q:1" and
101 eval "q:echo: eq q|echo|" and
102 not eval "q:echo:ohce: >= 0");
104 ok 17, (not eval "qq:1" and
105 eval "qq:echo: eq qq|echo|" and
106 not eval "qq:echo:ohce: >= 0");
108 ok 18, (not eval "qw:1" and
109 eval "qw:echo: eq qw|echo|" and
110 not eval "qw:echo:ohce: >= 0");
112 ok 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");
116 ok 20, (not eval "s:1" and
117 not eval "s:echo: eq s|echo|" and
118 eval "s:echo:ohce: >= 0");
120 ok 21, (not eval "tr:1" and
121 not eval "tr:echo: eq tr|echo|" and
122 eval "tr:echo:ohce: >= 0");
124 ok 22, (not eval "y:1" and
125 not eval "y:echo: eq y|echo|" and
126 eval "y:echo:ohce: >= 0");
128 ok 23, (eval "AUTOLOAD:1" and
129 not eval "AUTOLOAD:echo: eq AUTOLOAD|echo|" and
130 not eval "AUTOLOAD:echo:ohce: >= 0");
132 ok 24, (eval "and:1" and
133 not eval "and:echo: eq and|echo|" and
134 not eval "and:echo:ohce: >= 0");
136 ok 25, (eval "alarm:1" and
137 not eval "alarm:echo: eq alarm|echo|" and
138 not eval "alarm:echo:ohce: >= 0");