This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Create subdirectory t/opbasic. Move 5 test files there.
[perl5.git] / t / run / switchx.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6 }
7 use strict;
8
9 require './test.pl';
10
11 # Test '-x'
12 print runperl( switches => ['-x'],
13                progfile => 'run/switchx.aux' );
14
15 # Test '-xdir'
16 print runperl( switches => ['-x./run'],
17                progfile => 'run/switchx2.aux',
18                args     => [ 3 ] );
19
20 curr_test(5);
21
22 # Test the error message for not found
23 like(runperl(switches => ['-x'], progfile => 'run/switchx3.aux', stderr => 1),
24      qr/^No Perl script found in input\r?\n\z/,
25      "Test the error message when -x can't find a #!perl line");
26
27 SKIP: {
28     skip("These tests embed newlines in command line arguments, which isn't portable to $^O", 2)
29         if $^O eq 'MSWin32' or $^O eq 'VMS';
30     my @progs = ("die;\n", "#!perl\n", "warn;\n");
31     is(runperl(progs => \@progs, stderr => 1, non_portable => 1),
32        "Died at -e line 1.\n", 'Test program dies');
33     is(runperl(progs => \@progs, stderr => 1, non_portable => 1,
34                switches => ['-x']),
35        "No Perl script found in input\n", '-x and -e gives expected error');
36 }