xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/op/flip.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gate# $RCSfile: flip.t,v $$Revision: 4.1 $$Date: 92/08/07 18:27:52 $
4*0Sstevel@tonic-gate
5*0Sstevel@tonic-gatechdir 't' if -d 't';
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gateprint "1..15\n";
8*0Sstevel@tonic-gate
9*0Sstevel@tonic-gate@a = (1,2,3,4,5,6,7,8,9,10,11,12);
10*0Sstevel@tonic-gate
11*0Sstevel@tonic-gatewhile ($_ = shift(@a)) {
12*0Sstevel@tonic-gate    if ($x = /4/../8/) { $z = $x; print "ok ", $x + 0, "\n"; }
13*0Sstevel@tonic-gate    $y .= /1/../2/;
14*0Sstevel@tonic-gate}
15*0Sstevel@tonic-gate
16*0Sstevel@tonic-gateif ($z eq '5E0') {print "ok 6\n";} else {print "not ok 6\n";}
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gateif ($y eq '12E0123E0') {print "ok 7\n";} else {print "not ok 7\n";}
19*0Sstevel@tonic-gate
20*0Sstevel@tonic-gate@a = ('a','b','c','d','e','f','g');
21*0Sstevel@tonic-gate
22*0Sstevel@tonic-gate{
23*0Sstevel@tonic-gatelocal $.;
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gateopen(of,'harness') or die "Can't open harness: $!";
26*0Sstevel@tonic-gatewhile (<of>) {
27*0Sstevel@tonic-gate    (3 .. 5) && ($foo .= $_);
28*0Sstevel@tonic-gate}
29*0Sstevel@tonic-gate$x = ($foo =~ y/\n/\n/);
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gateif ($x eq 3) {print "ok 8\n";} else {print "not ok 8 $x:$foo:\n";}
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate$x = 3.14;
34*0Sstevel@tonic-gateif (($x...$x) eq "1") {print "ok 9\n";} else {print "not ok 9\n";}
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gate{
37*0Sstevel@tonic-gate    # coredump reported in bug 20001018.008
38*0Sstevel@tonic-gate    readline(UNKNOWN);
39*0Sstevel@tonic-gate    $. = 1;
40*0Sstevel@tonic-gate    $x = 1..10;
41*0Sstevel@tonic-gate    print "ok 10\n";
42*0Sstevel@tonic-gate}
43*0Sstevel@tonic-gate
44*0Sstevel@tonic-gate}
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gateif (!defined $.) { print "ok 11\n" } else { print "not ok 11 # $.\n" }
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gateuse warnings;
49*0Sstevel@tonic-gatemy $warn='';
50*0Sstevel@tonic-gate$SIG{__WARN__} = sub { $warn .= join '', @_ };
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gateif (0..2) { print "ok 12\n" } else { print "not ok 12\n" }
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gateif ($warn =~ /uninitialized/) { print "ok 13\n" } else { print "not ok 13\n" }
55*0Sstevel@tonic-gate$warn = '';
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate$x = "foo".."bar";
58*0Sstevel@tonic-gate
59*0Sstevel@tonic-gateif ((() = ($warn =~ /isn't numeric/g)) == 2) {
60*0Sstevel@tonic-gate    print "ok 14\n"
61*0Sstevel@tonic-gate}
62*0Sstevel@tonic-gateelse {
63*0Sstevel@tonic-gate    print "not ok 14\n"
64*0Sstevel@tonic-gate}
65*0Sstevel@tonic-gate$warn = '';
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate$. = 15;
68*0Sstevel@tonic-gateif (15..0) { print "ok 15\n" } else { print "not ok 15\n" }
69