diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-02-28 21:47:18 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-02-28 21:47:18 +0000 |
commit | 2b92dfceaa9d709661beb0761c3c790732df0cbc (patch) | |
tree | 209c29455bbe5f778f77447c6260b44a61f08855 /t/base | |
parent | 056534bf6b6b1b89850de37d21bf18c33cca9bd7 (diff) | |
download | perl-2b92dfceaa9d709661beb0761c3c790732df0cbc.tar.gz |
todo item: permit extended control variables a la ${^Foo} (patch
courtesy Mark-Jason Dominus <mjd@plover.com>)
p4raw-id: //depot/perl@3039
Diffstat (limited to 't/base')
-rwxr-xr-x | t/base/lex.t | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/t/base/lex.t b/t/base/lex.t index 045cb22eb0..325fd42992 100755 --- a/t/base/lex.t +++ b/t/base/lex.t @@ -2,7 +2,7 @@ # $RCSfile: lex.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:04 $ -print "1..30\n"; +print "1..41\n"; $x = 'x'; @@ -117,3 +117,68 @@ $foo =~ s/^not /substr(<<EOF, 0, 0)/e; Ignored EOF print $foo; + +# Tests for new extended control-character variables +# MJD 19990227 + +{ my $CX = "\cX"; + my $CXY ="\cXY"; + $ {$CX} = 17; + $ {$CXY} = 23; + if ($ {^XY} != 23) { print "not " } + print "ok 31\n"; + +# Does the syntax where we use the literal control character still work? + if ($ {} != 17) { print "not " } + print "ok 32\n"; + + $ = 24; # Literal control character + if ($ != 24) { print "not " } # Literal control character + print "ok 33\n"; + if ($^N != 24) { print "not " } # Control character escape sequence + print "ok 34\n"; + +# Does the old UNBRACED syntax still do what it used to? + if ("$^XY" ne "17Y") { print "not " } + print "ok 35\n"; + + sub XX () { 6 } + $ {"\cN\cXX"} = 119; + $^N = 5; # This should be an unused ^Var. + $N = 5; + # The second caret here should be interpreted as an xor + if (($^N^XX) != 3) { print "not " } + print "ok 36\n"; +# if (($N ^ XX()) != 3) { print "not " } +# print "ok 32\n"; + + # These next two tests are trying to make sure that + # $^FOO is always global; it doesn't make sense to `my' it. + # + eval 'my $^X;'; + print "not " unless index ($@, 'Can\'t use global $^X in "my"') > -1; + print "ok 37\n"; +# print "($@)\n" if $@; + + eval 'my $ {^XYZ};'; + print "not " unless index ($@, 'Can\'t use global $^XYZ in "my"') > -1; + print "ok 38\n"; +# print "($@)\n" if $@; + +# Now let's make sure that caret variables are all forced into the main package. + package Someother; + $^N = 'Someother'; + $ {^Nostril} = 'Someother 2'; + $ {^M} = 'Someother 3'; + package main; + print "not " unless $^N eq 'Someother'; + print "ok 39\n"; + print "not " unless $ {^Nostril} eq 'Someother 2'; + print "ok 40\n"; + print "not " unless $ {^M} eq 'Someother 3'; + print "ok 41\n"; + + +} + + |