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