allow C<print v10>, $h{v13.10} etc.
[p5sagit/p5-mst-13.2.git] / t / op / ver.t
CommitLineData
3cb0bbe5 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 unshift @INC, "../lib";
6}
7
e526c9e6 8print "1..18\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
b22c7a20 38print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
3cb0bbe5 39print "ok $test\n"; ++$test;
40
b22c7a20 41print "not " unless sprintf("%vd", v1.22.333.4444) eq '1.22.333.4444';
42print "ok $test\n"; ++$test;
43
44print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
45print "ok $test\n"; ++$test;
46
47print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.14D.115C';
48print "ok $test\n"; ++$test;
49
50print "not " unless sprintf("%*v#o", ":", "Perl") eq '0120:0145:0162:0154';
51print "ok $test\n"; ++$test;
52
53print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
54 eq '1##10110##101001101##1000101011100';
3cb0bbe5 55print "ok $test\n"; ++$test;
56
57{
8058d7ab 58 use bytes;
b22c7a20 59 print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
60 print "ok $test\n"; ++$test;
61
3cb0bbe5 62 print "not " unless
b22c7a20 63 sprintf("%vd", v1.22.333.4444) eq '1.22.197.141.225.133.156';
64 print "ok $test\n"; ++$test;
65
66 print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
67 print "ok $test\n"; ++$test;
68
69 print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C';
70 print "ok $test\n"; ++$test;
71
72 print "not " unless sprintf("%*v#o", ":", "Perl") eq '0120:0145:0162:0154';
73 print "ok $test\n"; ++$test;
74
75 print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
76 eq '1##10110##11000101##10001101##11100001##10000101##10011100';
3cb0bbe5 77 print "ok $test\n"; ++$test;
78}