Use minimal @INC in tests, most of the time just '../lib',
[p5sagit/p5-mst-13.2.git] / t / op / ver.t
CommitLineData
3cb0bbe5 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @INC = '../lib';
3cb0bbe5 6}
7
8dbfaa5d 8print "1..23\n";
3cb0bbe5 9
10my $test = 1;
11
12use v5.5.640;
13require v5.5.640;
14print "ok $test\n"; ++$test;
15
e526c9e6 16# printing characters should work
17print v111;
18print v107.32;
19print "$test\n"; ++$test;
20
21# hash keys too
22$h{v111.107} = "ok";
23print "$h{ok} $test\n"; ++$test;
24
25# poetry optimization should also
26sub v77 { "ok" }
27$x = v77;
28print "$x $test\n"; ++$test;
29
30# but not when dots are involved
31$x = v77.78.79;
32print "not " unless $x eq "MNO";
33print "ok $test\n"; ++$test;
34
3cb0bbe5 35print "not " unless v1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
36print "ok $test\n"; ++$test;
37
dd629d5b 38#
39# now do the same without the "v"
40use 5.5.640;
41require 5.5.640;
42print "ok $test\n"; ++$test;
43
44# hash keys too
45$h{111.107.32} = "ok";
46print "$h{ok } $test\n"; ++$test;
47
48$x = 77.78.79;
49print "not " unless $x eq "MNO";
50print "ok $test\n"; ++$test;
51
52print "not " unless 1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
53print "ok $test\n"; ++$test;
54
55# test sprintf("%vd"...) etc
b22c7a20 56print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
3cb0bbe5 57print "ok $test\n"; ++$test;
58
b22c7a20 59print "not " unless sprintf("%vd", v1.22.333.4444) eq '1.22.333.4444';
60print "ok $test\n"; ++$test;
61
62print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
63print "ok $test\n"; ++$test;
64
dd629d5b 65print "not " unless sprintf("%vX", 1.22.333.4444) eq '1.16.14D.115C';
b22c7a20 66print "ok $test\n"; ++$test;
67
68print "not " unless sprintf("%*v#o", ":", "Perl") eq '0120:0145:0162:0154';
69print "ok $test\n"; ++$test;
70
71print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
72 eq '1##10110##101001101##1000101011100';
3cb0bbe5 73print "ok $test\n"; ++$test;
74
8dbfaa5d 75print "not " unless sprintf("%vd", join("", map { chr }
76 unpack "U*", v2001.2002.2003))
77 eq '2001.2002.2003';
78print "ok $test\n"; ++$test;
79
3cb0bbe5 80{
8058d7ab 81 use bytes;
b22c7a20 82 print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
83 print "ok $test\n"; ++$test;
84
3cb0bbe5 85 print "not " unless
dd629d5b 86 sprintf("%vd", 1.22.333.4444) eq '1.22.197.141.225.133.156';
b22c7a20 87 print "ok $test\n"; ++$test;
88
89 print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
90 print "ok $test\n"; ++$test;
91
92 print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C';
93 print "ok $test\n"; ++$test;
94
95 print "not " unless sprintf("%*v#o", ":", "Perl") eq '0120:0145:0162:0154';
96 print "ok $test\n"; ++$test;
97
98 print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
99 eq '1##10110##11000101##10001101##11100001##10000101##10011100';
3cb0bbe5 100 print "ok $test\n"; ++$test;
101}