3 # Uncomment this for testing, but don't leave it in for "production", as
4 # we've not yet verified that use works.
15 Even if you have a C<sub q{}>, calling C<q()> will be parsed as the
16 C<q()> operator. Calling C<&q()> or C<main::q()> gets you the function.
17 This test verifies this behavior for nine different operators.
21 sub m { return "m-".shift }
22 sub q { return "q-".shift }
23 sub qq { return "qq-".shift }
24 sub qr { return "qr-".shift }
25 sub qw { return "qw-".shift }
26 sub qx { return "qx-".shift }
27 sub s { return "s-".shift }
28 sub tr { return "tr-".shift }
29 sub y { return "y-".shift }
32 can_ok( 'main', "m" );
33 SILENCE_WARNING: { # Complains because $_ is undef
35 isnt( m('unqualified'), "m-unqualified", "m('unqualified') is oper" );
37 is( main::m('main'), "m-main", "main::m() is func" );
38 is( &m('amper'), "m-amper", "&m() is func" );
41 can_ok( 'main', "q" );
42 isnt( q('unqualified'), "q-unqualified", "q('unqualified') is oper" );
43 is( main::q('main'), "q-main", "main::q() is func" );
44 is( &q('amper'), "q-amper", "&q() is func" );
47 can_ok( 'main', "qq" );
48 isnt( qq('unqualified'), "qq-unqualified", "qq('unqualified') is oper" );
49 is( main::qq('main'), "qq-main", "main::qq() is func" );
50 is( &qq('amper'), "qq-amper", "&qq() is func" );
53 can_ok( 'main', "qr" );
54 isnt( qr('unqualified'), "qr-unqualified", "qr('unqualified') is oper" );
55 is( main::qr('main'), "qr-main", "main::qr() is func" );
56 is( &qr('amper'), "qr-amper", "&qr() is func" );
59 can_ok( 'main', "qw" );
60 isnt( qw('unqualified'), "qw-unqualified", "qw('unqualified') is oper" );
61 is( main::qw('main'), "qw-main", "main::qw() is func" );
62 is( &qw('amper'), "qw-amper", "&qw() is func" );
65 can_ok( 'main', "qx" );
66 eval "qx('unqualified'".
67 ($^O eq 'MSWin32' ? " 2>&1)" : ")");
69 skip("external command not portable on VMS", 1) if $^O eq 'VMS';
71 local $::TODO = $^O eq 'MSWin32' ? "Tainting of PATH not working of Windows" : $::TODO;
72 like( $@, qr/^Insecure/, "qx('unqualified') doesn't work" );
75 is( main::qx('main'), "qx-main", "main::qx() is func" );
76 is( &qx('amper'), "qx-amper", "&qx() is func" );
79 can_ok( 'main', "s" );
80 eval "s('unqualified')";
81 like( $@, qr/^Substitution replacement not terminated/, "s('unqualified') doesn't work" );
82 is( main::s('main'), "s-main", "main::s() is func" );
83 is( &s('amper'), "s-amper", "&s() is func" );
86 can_ok( 'main', "tr" );
87 eval "tr('unqualified')";
88 like( $@, qr/^Transliteration replacement not terminated/, "tr('unqualified') doesn't work" );
89 is( main::tr('main'), "tr-main", "main::tr() is func" );
90 is( &tr('amper'), "tr-amper", "&tr() is func" );
93 can_ok( 'main', "y" );
94 eval "y('unqualified')";
95 like( $@, qr/^Transliteration replacement not terminated/, "y('unqualified') doesn't work" );
96 is( main::y('main'), "y-main", "main::y() is func" );
97 is( &y('amper'), "y-amper", "&y() is func" );
101 from irc://irc.perl.org/p5p 2004/08/12
103 <kane-xs> bug or feature?
104 <purl> You decide!!!!
105 <kane-xs> [kane@coke ~]$ perlc -le'sub y{1};y(1)'
106 <kane-xs> Transliteration replacement not terminated at -e line 1.
107 <Nicholas> bug I think
108 <kane-xs> i'll perlbug
110 <kane-xs> smiles at rgs
112 <rgs> will be closed at not a bug,
113 <rgs> like the previous reports of this one
114 <Nicholas> feature being first class and second class keywords?
115 <rgs> you have similar ones with q, qq, qr, qx, tr, s and m
116 <rgs> one could say 1st class keywords, yes
117 <rgs> and I forgot qw
118 <kane-xs> hmm silly...
119 <Nicholas> it's acutally operators, isn't it?
120 <Nicholas> as in you can't call a subroutine with the same name as an
121 operator unless you have the & ?
122 <kane-xs> or fqpn (fully qualified package name)
123 <kane-xs> main::y() works just fine
124 <kane-xs> as does &y; but not y()
125 <Andy> If that's a feature, then let's write a test that it continues