1#!./perl
2
3BEGIN {
4    chdir 't' if -d 't';
5    @INC = '../lib';
6}
7use strict;
8
9require './test.pl';
10
11# Test '-x'
12print runperl( switches => ['-x'],
13               progfile => 'run/switchx.aux' );
14
15# Test '-xdir'
16print runperl( switches => ['-x./run'],
17               progfile => 'run/switchx2.aux',
18               args     => [ 4 ] );
19
20curr_test(6);
21
22# Test the error message for not found
23like(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
27SKIP: {
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}
37