summaryrefslogtreecommitdiff
path: root/t/pragma/constant.t
diff options
context:
space:
mode:
authorCasey R. Tweten <crt@kiski.net>2000-12-29 07:03:00 -0500
committerJarkko Hietaniemi <jhi@iki.fi>2000-12-29 17:45:12 +0000
commitc7206c54089b550f8b7c01366011a58bd74a9703 (patch)
tree2fafb0f1bfbfca12c2095bf8390d8b411810c635 /t/pragma/constant.t
parent26191e783d73bf5f223253769d4bfbf74617dc91 (diff)
downloadperl-c7206c54089b550f8b7c01366011a58bd74a9703.tar.gz
Idea: Declare multiple constants at once (fwd)
Message-ID: <Pine.OSF.4.21.0012291201150.17186-100000@home.kiski.net> Tests for for #8240. p4raw-id: //depot/perl@8256
Diffstat (limited to 't/pragma/constant.t')
-rwxr-xr-xt/pragma/constant.t22
1 files changed, 21 insertions, 1 deletions
diff --git a/t/pragma/constant.t b/t/pragma/constant.t
index 450b4d02cf..f932976f60 100755
--- a/t/pragma/constant.t
+++ b/t/pragma/constant.t
@@ -14,7 +14,7 @@ END { print @warnings }
######################### We start with some black magic to print on failure.
-BEGIN { $| = 1; print "1..73\n"; }
+BEGIN { $| = 1; print "1..82\n"; }
END {print "not ok 1\n" unless $loaded;}
use constant 1.01;
$loaded = 1;
@@ -229,3 +229,23 @@ test 71, (shift @warnings) =~ /^Constant name 'ENV' is forced into package main:
test 72, (shift @warnings) =~ /^Constant name 'INC' is forced into package main:: at/;
test 73, (shift @warnings) =~ /^Constant name 'SIG' is forced into package main:: at/;
@warnings = ();
+
+
+use constant {
+ THREE => 3,
+ FAMILY => [ qw( John Jane Sally ) ],
+ AGES => { John => 33, Jane => 28, Sally => 3 },
+ RFAM => [ [ qw( John Jane Sally ) ] ],
+ SPIT => sub { shift },
+ PHFAM => [ { John => 1, Jane => 2, Sally => 3 }, 33, 28, 3 ],
+};
+
+test 74, @{+FAMILY} == THREE;
+test 75, @{+FAMILY} == @{RFAM->[0]};
+test 76, FAMILY->[2] eq RFAM->[0]->[2];
+test 77, AGES->{FAMILY->[1]} == 28;
+test 78, PHFAM->{John} == AGES->{John};
+test 79, PHFAM->[3] == AGES->{FAMILY->[2]};
+test 80, @{+PHFAM} == SPIT->(THREE+1);
+test 81, THREE**3 eq SPIT->(@{+FAMILY}**3);
+test 82, AGES->{FAMILY->[THREE-1]} == PHFAM->[THREE];