This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
add Shell.t tests for VMS
[perl5.git] / t / op / override.t
CommitLineData
2adfde11
GS
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '.';
6 push @INC, '../lib';
7}
8
9print "1..10\n";
10
11#
12# This file tries to test builtin override using CORE::GLOBAL
13#
14my $dirsep = "/";
15
16BEGIN { package Foo; *main::getlogin = sub { "kilroy"; } }
17
18print "not " unless getlogin eq "kilroy";
19print "ok 1\n";
20
21my $t = 42;
22BEGIN { *CORE::GLOBAL::time = sub () { $t; } }
23
24print "not " unless 45 == time + 3;
25print "ok 2\n";
26
27#
28# require has special behaviour
29#
30my $r;
31BEGIN { *CORE::GLOBAL::require = sub { $r = shift; 1; } }
32
33require Foo;
34print "not " unless $r eq "Foo.pm";
35print "ok 3\n";
36
37require Foo::Bar;
38print "not " unless $r eq join($dirsep, "Foo", "Bar.pm");
39print "ok 4\n";
40
41require 'Foo';
42print "not " unless $r eq "Foo";
43print "ok 5\n";
44
45require 5.6;
46print "not " unless $r eq "5.6";
47print "ok 6\n";
48
49require v5.6;
5c7bc39a 50print "not " unless abs($r - 5.006) < 0.001 && $r eq "\x05\x06";
2adfde11
GS
51print "ok 7\n";
52
53eval "use Foo";
54print "not " unless $r eq "Foo.pm";
55print "ok 8\n";
56
57eval "use Foo::Bar";
58print "not " unless $r eq join($dirsep, "Foo", "Bar.pm");
59print "ok 9\n";
60
61eval "use 5.6";
62print "not " unless $r eq "5.6";
63print "ok 10\n";