xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/op/reverse.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gateprint "1..4\n";
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gateprint "not " unless reverse("abc")    eq "cba";
11*0Sstevel@tonic-gateprint "ok 1\n";
12*0Sstevel@tonic-gate
13*0Sstevel@tonic-gate$_ = "foobar";
14*0Sstevel@tonic-gateprint "not " unless reverse()         eq "raboof";
15*0Sstevel@tonic-gateprint "ok 2\n";
16*0Sstevel@tonic-gate
17*0Sstevel@tonic-gate{
18*0Sstevel@tonic-gate    my @a = ("foo", "bar");
19*0Sstevel@tonic-gate    my @b = reverse @a;
20*0Sstevel@tonic-gate
21*0Sstevel@tonic-gate    print "not " unless $b[0] eq $a[1] && $b[1] eq $a[0];
22*0Sstevel@tonic-gate    print "ok 3\n";
23*0Sstevel@tonic-gate}
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate{
26*0Sstevel@tonic-gate    # Unicode.
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gate    my $a = "\x{263A}\x{263A}x\x{263A}y\x{263A}";
29*0Sstevel@tonic-gate    my $b = scalar reverse($a);
30*0Sstevel@tonic-gate    my $c = scalar reverse($b);
31*0Sstevel@tonic-gate    print "not " unless $a eq $c;
32*0Sstevel@tonic-gate    print "ok 4\n";
33*0Sstevel@tonic-gate}
34