This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove the Rhapsody port.
[perl5.git] / t / op / filetest_stack_ok.t
CommitLineData
c410dd6a
AA
1#!./perl
2
3# On platforms that don't support all of the filetest operators the code
4# that faked the results of missing tests used to leave the test's
5# argument on the stack.
6
7BEGIN {
8 chdir 't' if -d 't';
9 @INC = '../lib';
10 require './test.pl';
11}
12
13my @ops = split //, 'rwxoRWXOezsfdlpSbctugkTMBAC';
14
d6642e43
FC
15plan( tests => @ops * 5 );
16
17package o { use overload '-X' => sub { 1 } }
18my $o = bless [], 'o';
c410dd6a
AA
19
20for my $op (@ops) {
21 ok( 1 == @{ [ eval "-$op 'TEST'" ] }, "-$op returns single value" );
e5e154d2 22 ok( 1 == @{ [ eval "-$op *TEST" ] }, "-$op *gv returns single value" );
73ceeaa7
B
23
24 my $count = 0;
25 my $t;
26 for my $m ("a", "b") {
27 if ($count == 0) {
28 $t = eval "-$op _" ? 0 : "foo";
29 }
30 elsif ($count == 1) {
31 is($m, "b", "-$op did not remove too many values from the stack");
32 }
33 $count++;
34 }
35
36 $count = 0;
37 for my $m ("c", "d") {
38 if ($count == 0) {
39 $t = eval "-$op -e \$^X" ? 0 : "bar";
40 }
41 elsif ($count == 1) {
73ceeaa7
B
42 is($m, "d", "-$op -e \$^X did not remove too many values from the stack");
43 }
44 $count++;
45 }
d6642e43
FC
46
47 my @foo = eval "-$op \$o";
48 is @foo, 1, "-$op \$overld did not leave \$overld on the stack";
c410dd6a 49}