Add more known sprintf failures.
[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
00387047 8print "1..28\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
7bd40e26 17if (ord("\t") == 9) { # ASCII
18 print v111;
19 print v107.32;
20 print "$test\n"; ++$test;
21
22 # hash keys too
23 $h{v111.107} = "ok";
24 print "$h{ok} $test\n"; ++$test;
25}
26else { # EBCDIC
27 print v150;
28 print v146.64;
29 print "$test\n"; ++$test;
30
31 # hash keys too
32 $h{v150.146} = "ok";
33 print "$h{ok} $test\n"; ++$test;
34}
e526c9e6 35
36# poetry optimization should also
37sub v77 { "ok" }
38$x = v77;
39print "$x $test\n"; ++$test;
40
41# but not when dots are involved
7bd40e26 42if (ord("\t") == 9) { # ASCII
43 $x = v77.78.79;
44}
45else {
46 $x = v212.213.214;
47}
e526c9e6 48print "not " unless $x eq "MNO";
49print "ok $test\n"; ++$test;
50
3cb0bbe5 51print "not " unless v1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
52print "ok $test\n"; ++$test;
53
dd629d5b 54#
55# now do the same without the "v"
56use 5.5.640;
57require 5.5.640;
58print "ok $test\n"; ++$test;
59
60# hash keys too
7bd40e26 61if (ord("\t") == 9) { # ASCII
62 $h{111.107.32} = "ok";
63}
64else {
65 $h{150.146.64} = "ok";
66}
dd629d5b 67print "$h{ok } $test\n"; ++$test;
68
7bd40e26 69if (ord("\t") == 9) { # ASCII
70 $x = 77.78.79;
71}
72else {
73 $x = 212.213.214;
74}
dd629d5b 75print "not " unless $x eq "MNO";
76print "ok $test\n"; ++$test;
77
78print "not " unless 1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}";
79print "ok $test\n"; ++$test;
80
81# test sprintf("%vd"...) etc
7bd40e26 82if (ord("\t") == 9) { # ASCII
83 print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
84}
85else {
86 print "not " unless sprintf("%vd", "Perl") eq '215.133.153.147';
87}
3cb0bbe5 88print "ok $test\n"; ++$test;
89
b22c7a20 90print "not " unless sprintf("%vd", v1.22.333.4444) eq '1.22.333.4444';
91print "ok $test\n"; ++$test;
92
7bd40e26 93if (ord("\t") == 9) { # ASCII
94 print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
95}
96else {
97 print "not " unless sprintf("%vx", "Perl") eq 'd7.85.99.93';
98}
b22c7a20 99print "ok $test\n"; ++$test;
100
dd629d5b 101print "not " unless sprintf("%vX", 1.22.333.4444) eq '1.16.14D.115C';
b22c7a20 102print "ok $test\n"; ++$test;
103
7bd40e26 104if (ord("\t") == 9) { # ASCII
211dfcf1 105 print "not " unless sprintf("%#*vo", ":", "Perl") eq '0120:0145:0162:0154';
7bd40e26 106}
107else {
211dfcf1 108 print "not " unless sprintf("%#*vo", ":", "Perl") eq '0327:0205:0231:0223';
7bd40e26 109}
b22c7a20 110print "ok $test\n"; ++$test;
111
112print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
113 eq '1##10110##101001101##1000101011100';
3cb0bbe5 114print "ok $test\n"; ++$test;
115
8dbfaa5d 116print "not " unless sprintf("%vd", join("", map { chr }
117 unpack "U*", v2001.2002.2003))
118 eq '2001.2002.2003';
119print "ok $test\n"; ++$test;
120
3cb0bbe5 121{
8058d7ab 122 use bytes;
7bd40e26 123 if (ord("\t") == 9) { # ASCII
124 print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108';
125 }
126 else {
127 print "not " unless sprintf("%vd", "Perl") eq '215.133.153.147';
128 }
b22c7a20 129 print "ok $test\n"; ++$test;
130
3cb0bbe5 131 print "not " unless
dd629d5b 132 sprintf("%vd", 1.22.333.4444) eq '1.22.197.141.225.133.156';
b22c7a20 133 print "ok $test\n"; ++$test;
134
7bd40e26 135 if (ord("\t") == 9) { # ASCII
136 print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c';
137 }
138 else {
139 print "not " unless sprintf("%vx", "Perl") eq 'd7.85.99.93';
140 }
b22c7a20 141 print "ok $test\n"; ++$test;
142
143 print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C';
144 print "ok $test\n"; ++$test;
145
7bd40e26 146 if (ord("\t") == 9) { # ASCII
211dfcf1 147 print "not " unless sprintf("%#*vo", ":", "Perl") eq '0120:0145:0162:0154';
7bd40e26 148 }
149 else {
211dfcf1 150 print "not " unless sprintf("%#*vo", ":", "Perl") eq '0327:0205:0231:0223';
7bd40e26 151 }
b22c7a20 152 print "ok $test\n"; ++$test;
153
154 print "not " unless sprintf("%*vb", "##", v1.22.333.4444)
155 eq '1##10110##11000101##10001101##11100001##10000101##10011100';
3cb0bbe5 156 print "ok $test\n"; ++$test;
157}
00387047 158
159{
160 # bug id 20000323.056
161
162 print "not " unless "\x{41}" eq +v65;
163 print "ok $test\n";
164 $test++;
165
166 print "not " unless "\x41" eq +v65;
167 print "ok $test\n";
168 $test++;
169
170 print "not " unless "\x{c8}" eq +v200;
171 print "ok $test\n";
172 $test++;
173
174 print "not " unless "\xc8" eq +v200;
175 print "ok $test\n";
176 $test++;
177
178 print "not " unless "\x{221b}" eq v8731;
179 print "ok $test\n";
180 $test++;
181}