This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RT #75468: readline ignores <> overloading when arg is tied
[perl5.git] / t / comp / colon.t
CommitLineData
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
abb363a1 7# -- Robin Barker
8ebc5c01 8#
9
e07a7c00
NC
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
16sub 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
24print "1..25\n";
25
26ok 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
31ok 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
36ok 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
41ok 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
46ok 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
51ok 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
56ok 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
61ok 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
66ok 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
71ok 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
76ok 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
81ok 12, (eval "ABC:1" and
82 not eval "ABC:echo: eq ABC|echo|" and
83 not eval "ABC:echo:ohce: >= 0");
84
85ok 13, (eval "LABEL:1" and
86 not eval "LABEL:echo: eq LABEL|echo|" and
87 not eval "LABEL:echo:ohce: >= 0");
88
89ok 14, (eval "XYZZY:1" and
90 not eval "XYZZY:echo: eq XYZZY|echo|" and
91 not eval "XYZZY:echo:ohce: >= 0");
92
93ok 15, (not eval "m:1" and
94 eval "m:echo: eq m|echo|" and
95 not eval "m:echo:ohce: >= 0");
96
97ok 16, (not eval "q:1" and
98 eval "q:echo: eq q|echo|" and
99 not eval "q:echo:ohce: >= 0");
100
101ok 17, (not eval "qq:1" and
102 eval "qq:echo: eq qq|echo|" and
103 not eval "qq:echo:ohce: >= 0");
104
105ok 18, (not eval "qw:1" and
106 eval "qw:echo: eq qw|echo|" and
107 not eval "qw:echo:ohce: >= 0");
108
109ok 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
113ok 20, (not eval "s:1" and
114 not eval "s:echo: eq s|echo|" and
115 eval "s:echo:ohce: >= 0");
116
117ok 21, (not eval "tr:1" and
118 not eval "tr:echo: eq tr|echo|" and
119 eval "tr:echo:ohce: >= 0");
120
121ok 22, (not eval "y:1" and
122 not eval "y:echo: eq y|echo|" and
123 eval "y:echo:ohce: >= 0");
124
10517af5 125ok 23, (eval "AUTOLOAD:1" and
8ebc5c01 126 not eval "AUTOLOAD:echo: eq AUTOLOAD|echo|" and
127 not eval "AUTOLOAD:echo:ohce: >= 0");
128
10517af5 129ok 24, (eval "and:1" and
8ebc5c01 130 not eval "and:echo: eq and|echo|" and
131 not eval "and:echo:ohce: >= 0");
132
10517af5 133ok 25, (eval "alarm:1" and
8ebc5c01 134 not eval "alarm:echo: eq alarm|echo|" and
135 not eval "alarm:echo:ohce: >= 0");