This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
generalize "%v" format into a flag for any integral format type:
[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..15\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 print "not " unless v1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
17 print "ok $test\n";  ++$test;
18
19 print "not " unless v1.20.300.4000 > 1.0203039 and v1.20.300.4000 < 1.0203041;
20 print "ok $test\n";  ++$test;
21
22 print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
23 print "ok $test\n";  ++$test;
24
25 print "not " unless sprintf("%vd", v1.22.333.4444) eq '1.22.333.4444';
26 print "ok $test\n";  ++$test;
27
28 print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
29 print "ok $test\n";  ++$test;
30
31 print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.14D.115C';
32 print "ok $test\n";  ++$test;
33
34 print "not " unless sprintf("%*v#o", ":", "Perl") eq '0120:0145:0162:0154';
35 print "ok $test\n";  ++$test;
36
37 print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
38     eq '1##10110##101001101##1000101011100';
39 print "ok $test\n";  ++$test;
40
41 {
42     use bytes;
43     print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
44     print "ok $test\n";  ++$test;
45
46     print "not " unless
47         sprintf("%vd", v1.22.333.4444) eq '1.22.197.141.225.133.156';
48     print "ok $test\n";  ++$test;
49
50     print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
51     print "ok $test\n";  ++$test;
52
53     print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C';
54     print "ok $test\n";  ++$test;
55
56     print "not " unless sprintf("%*v#o", ":", "Perl") eq '0120:0145:0162:0154';
57     print "ok $test\n";  ++$test;
58
59     print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
60         eq '1##10110##11000101##10001101##11100001##10000101##10011100';
61     print "ok $test\n";  ++$test;
62 }