This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
83a32aa1783e16014e340e2dca8324c110198c8f
[perl5.git] / t / base / term.t
1 #!./perl
2
3 BEGIN {
4     chdir 't' if -d 't';
5 }
6
7 print "1..7\n";
8
9 # check "" interpretation
10
11 $x = "\n";
12 # 10 is ASCII/Iso Latin, 13 is Mac OS, 21 is EBCDIC.
13 if ($x eq chr(10)) { print "ok 1\n";}
14 elsif ($x eq chr(13)) { print "ok 1 # Mac OS\n"; }
15 elsif ($x eq chr(21)) { print "ok 1 # EBCDIC\n"; }
16 else {print "not ok 1\n";}
17
18 # check `` processing
19
20 $x = `$^X -le "print 'hi there'"`;
21 if ($x eq "hi there\n") {print "ok 2\n";} else {print "not ok 2\n";}
22
23 # check $#array
24
25 $x[0] = 'foo';
26 $x[1] = 'foo';
27 $tmp = $#x;
28 print "#3\t:$tmp: == :1:\n";
29 if ($#x == '1') {print "ok 3\n";} else {print "not ok 3\n";}
30
31 # check numeric literal
32
33 $x = 1;
34 if ($x == '1') {print "ok 4\n";} else {print "not ok 4\n";}
35
36 $x = '1E2';
37 if (($x | 1) == 101) {print "ok 5\n";} else {print "not ok 5\n";}
38
39 # check <> pseudoliteral
40
41 if ($^O eq 'MacOS') {
42         open(try,"Dev:Null") || (die "Can't open /dev/null.");
43 } else {
44         open(try, "/dev/null") || open(try,"nla0:") || (die "Can't open /dev/null.");
45 }
46
47 if (<try> eq '') {
48     print "ok 6\n";
49 }
50 else {
51     print "not ok 6\n";
52     die "/dev/null IS NOT A CHARACTER SPECIAL FILE!!!!\n" unless -c '/dev/null';
53 }
54
55 open(try, "harness") || (die "Can't open harness.");
56 if (<try> ne '') {print "ok 7\n";} else {print "not ok 7\n";}