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