This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Skip over state declarations at run time
[perl5.git] / t / op / flip.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     require "./test.pl";
6 }
7
8 plan(12);
9
10 @a = (1,2,3,4,5,6,7,8,9,10,11,12);
11 @b = ();
12 while ($_ = shift(@a)) {
13     if ($x = /4/../8/) { $z = $x; push @b, $x + 0; }
14     $y .= /1/../2/;
15 }
16 is(join("*", @b), "1*2*3*4*5");
17
18 is($z, '5E0');
19
20 is($y, '12E0123E0');
21
22 @a = ('a','b','c','d','e','f','g');
23
24 {
25 local $.;
26
27 open(of,'harness') or die "Can't open harness: $!";
28 while (<of>) {
29     (3 .. 5) && ($foo .= $_);
30 }
31 $x = ($foo =~ y/\n/\n/);
32
33 is($x, 3);
34
35 $x = 3.14;
36 ok(($x...$x) eq "1");
37
38 {
39     # coredump reported in bug 20001018.008
40     readline(UNKNOWN);
41     $. = 1;
42     $x = 1..10;
43     ok(1);
44 }
45
46 }
47
48 ok(!defined $.);
49
50 use warnings;
51 my $warn='';
52 $SIG{__WARN__} = sub { $warn .= join '', @_ };
53
54 ok(scalar(0..2));
55
56 like($warn, qr/uninitialized/);
57 $warn = '';
58
59 $x = "foo".."bar";
60
61 ok((() = ($warn =~ /isn't numeric/g)) == 2);
62 $warn = '';
63
64 $. = 15;
65 ok(scalar(15..0));
66
67 push @_, \scalar(0..0) for 1,2;
68 isnt $_[0], $_[1], '\scalar($a..$b) gives a different scalar each time';