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