Commit | Line | Data |
8ebc5c01 |
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 | |
e07a7c00 |
10 | # Uncomment this for testing, but don't leave it in for "production", as |
11 | # we've not yet verified that use works. |
12 | # use strict; |
8ebc5c01 |
13 | |
14 | $_ = ''; # to avoid undef warning on m// etc. |
15 | |
16 | sub ok { |
17 | my($test,$ok) = @_; |
18 | print "not " unless $ok; |
19 | print "ok $test\n"; |
20 | } |
21 | |
22 | $SIG{__WARN__} = sub { 1; }; # avoid some spurious warnings |
23 | |
24 | print "1..25\n"; |
25 | |
26 | ok 1, (eval "package ABC; sub zyx {1}; 1;" and |
27 | eval "ABC::zyx" and |
28 | not eval "ABC:: eq ABC||" and |
29 | not eval "ABC::: >= 0"); |
30 | |
31 | ok 2, (eval "package LABEL; sub zyx {1}; 1;" and |
32 | eval "LABEL::zyx" and |
33 | not eval "LABEL:: eq LABEL||" and |
34 | not eval "LABEL::: >= 0"); |
35 | |
36 | ok 3, (eval "package XYZZY; sub zyx {1}; 1;" and |
37 | eval "XYZZY::zyx" and |
38 | not eval "XYZZY:: eq XYZZY||" and |
39 | not eval "XYZZY::: >= 0"); |
40 | |
41 | ok 4, (eval "package m; sub zyx {1}; 1;" and |
42 | not eval "m::zyx" and |
43 | eval "m:: eq m||" and |
44 | not eval "m::: >= 0"); |
45 | |
46 | ok 5, (eval "package q; sub zyx {1}; 1;" and |
47 | not eval "q::zyx" and |
48 | eval "q:: eq q||" and |
49 | not eval "q::: >= 0"); |
50 | |
51 | ok 6, (eval "package qq; sub zyx {1}; 1;" and |
52 | not eval "qq::zyx" and |
53 | eval "qq:: eq qq||" and |
54 | not eval "qq::: >= 0"); |
55 | |
56 | ok 7, (eval "package qw; sub zyx {1}; 1;" and |
57 | not eval "qw::zyx" and |
58 | eval "qw:: eq qw||" and |
59 | not eval "qw::: >= 0"); |
60 | |
61 | ok 8, (eval "package qx; sub zyx {1}; 1;" and |
62 | not eval "qx::zyx" and |
63 | eval "qx:: eq qx||" and |
64 | not eval "qx::: >= 0"); |
65 | |
66 | ok 9, (eval "package s; sub zyx {1}; 1;" and |
67 | not eval "s::zyx" and |
68 | not eval "s:: eq s||" and |
69 | eval "s::: >= 0"); |
70 | |
71 | ok 10, (eval "package tr; sub zyx {1}; 1;" and |
72 | not eval "tr::zyx" and |
73 | not eval "tr:: eq tr||" and |
74 | eval "tr::: >= 0"); |
75 | |
76 | ok 11, (eval "package y; sub zyx {1}; 1;" and |
77 | not eval "y::zyx" and |
78 | not eval "y:: eq y||" and |
79 | eval "y::: >= 0"); |
80 | |
81 | ok 12, (eval "ABC:1" and |
82 | not eval "ABC:echo: eq ABC|echo|" and |
83 | not eval "ABC:echo:ohce: >= 0"); |
84 | |
85 | ok 13, (eval "LABEL:1" and |
86 | not eval "LABEL:echo: eq LABEL|echo|" and |
87 | not eval "LABEL:echo:ohce: >= 0"); |
88 | |
89 | ok 14, (eval "XYZZY:1" and |
90 | not eval "XYZZY:echo: eq XYZZY|echo|" and |
91 | not eval "XYZZY:echo:ohce: >= 0"); |
92 | |
93 | ok 15, (not eval "m:1" and |
94 | eval "m:echo: eq m|echo|" and |
95 | not eval "m:echo:ohce: >= 0"); |
96 | |
97 | ok 16, (not eval "q:1" and |
98 | eval "q:echo: eq q|echo|" and |
99 | not eval "q:echo:ohce: >= 0"); |
100 | |
101 | ok 17, (not eval "qq:1" and |
102 | eval "qq:echo: eq qq|echo|" and |
103 | not eval "qq:echo:ohce: >= 0"); |
104 | |
105 | ok 18, (not eval "qw:1" and |
106 | eval "qw:echo: eq qw|echo|" and |
107 | not eval "qw:echo:ohce: >= 0"); |
108 | |
109 | ok 19, (not eval "qx:1" and |
bbad3607 |
110 | eval "qx:echo 1: eq qx|echo 1|" and # echo without args may warn |
8ebc5c01 |
111 | not eval "qx:echo:ohce: >= 0"); |
112 | |
113 | ok 20, (not eval "s:1" and |
114 | not eval "s:echo: eq s|echo|" and |
115 | eval "s:echo:ohce: >= 0"); |
116 | |
117 | ok 21, (not eval "tr:1" and |
118 | not eval "tr:echo: eq tr|echo|" and |
119 | eval "tr:echo:ohce: >= 0"); |
120 | |
121 | ok 22, (not eval "y:1" and |
122 | not eval "y:echo: eq y|echo|" and |
123 | eval "y:echo:ohce: >= 0"); |
124 | |
f71d6157 |
125 | ok 23, (not eval "AUTOLOAD:1" and |
8ebc5c01 |
126 | not eval "AUTOLOAD:echo: eq AUTOLOAD|echo|" and |
127 | not eval "AUTOLOAD:echo:ohce: >= 0"); |
128 | |
f71d6157 |
129 | ok 24, (not eval "and:1" and |
8ebc5c01 |
130 | not eval "and:echo: eq and|echo|" and |
131 | not eval "and:echo:ohce: >= 0"); |
132 | |
f71d6157 |
133 | ok 25, (not eval "alarm:1" and |
8ebc5c01 |
134 | not eval "alarm:echo: eq alarm|echo|" and |
135 | not eval "alarm:echo:ohce: >= 0"); |