This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Get t/uni/cache.t working under minitest
[perl5.git] / t / op / filetest_stack_ok.t
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
7 BEGIN {
8     chdir 't' if -d 't';
9     @INC = '../lib';
10     require './test.pl';
11 }
12
13 my @ops = split //, 'rwxoRWXOezsfdlpSbctugkTMBAC';
14
15 plan( tests => @ops * 5 );
16
17 package o { use overload '-X' => sub { 1 } }
18 my $o = bless [], 'o';
19
20 for my $op (@ops) {
21     ok( 1 == @{ [ eval "-$op 'TEST'" ] }, "-$op returns single value" );
22     ok( 1 == @{ [ eval "-$op *TEST" ] }, "-$op *gv returns single value" );
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) {
42             is($m, "d", "-$op -e \$^X did not remove too many values from the stack");
43         }
44         $count++;
45     }
46
47     my @foo = eval "-$op \$o";
48     is @foo, 1, "-$op \$overld did not leave \$overld on the stack";
49 }