Commit | Line | Data |
3cb0bbe5 |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
20822f61 |
5 | @INC = '../lib'; |
3cb0bbe5 |
6 | } |
7 | |
00387047 |
8 | print "1..28\n"; |
3cb0bbe5 |
9 | |
10 | my $test = 1; |
11 | |
12 | use v5.5.640; |
13 | require v5.5.640; |
14 | print "ok $test\n"; ++$test; |
15 | |
e526c9e6 |
16 | # printing characters should work |
7bd40e26 |
17 | if (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 | } |
26 | else { # 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 |
37 | sub v77 { "ok" } |
38 | $x = v77; |
39 | print "$x $test\n"; ++$test; |
40 | |
41 | # but not when dots are involved |
7bd40e26 |
42 | if (ord("\t") == 9) { # ASCII |
43 | $x = v77.78.79; |
44 | } |
45 | else { |
46 | $x = v212.213.214; |
47 | } |
e526c9e6 |
48 | print "not " unless $x eq "MNO"; |
49 | print "ok $test\n"; ++$test; |
50 | |
3cb0bbe5 |
51 | print "not " unless v1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}"; |
52 | print "ok $test\n"; ++$test; |
53 | |
dd629d5b |
54 | # |
55 | # now do the same without the "v" |
56 | use 5.5.640; |
57 | require 5.5.640; |
58 | print "ok $test\n"; ++$test; |
59 | |
60 | # hash keys too |
7bd40e26 |
61 | if (ord("\t") == 9) { # ASCII |
62 | $h{111.107.32} = "ok"; |
63 | } |
64 | else { |
65 | $h{150.146.64} = "ok"; |
66 | } |
dd629d5b |
67 | print "$h{ok } $test\n"; ++$test; |
68 | |
7bd40e26 |
69 | if (ord("\t") == 9) { # ASCII |
70 | $x = 77.78.79; |
71 | } |
72 | else { |
73 | $x = 212.213.214; |
74 | } |
dd629d5b |
75 | print "not " unless $x eq "MNO"; |
76 | print "ok $test\n"; ++$test; |
77 | |
78 | print "not " unless 1.20.300.4000 eq "\x{1}\x{14}\x{12c}\x{fa0}"; |
79 | print "ok $test\n"; ++$test; |
80 | |
81 | # test sprintf("%vd"...) etc |
7bd40e26 |
82 | if (ord("\t") == 9) { # ASCII |
83 | print "not " unless sprintf("%vd", "Perl") eq '80.101.114.108'; |
84 | } |
85 | else { |
86 | print "not " unless sprintf("%vd", "Perl") eq '215.133.153.147'; |
87 | } |
3cb0bbe5 |
88 | print "ok $test\n"; ++$test; |
89 | |
b22c7a20 |
90 | print "not " unless sprintf("%vd", v1.22.333.4444) eq '1.22.333.4444'; |
91 | print "ok $test\n"; ++$test; |
92 | |
7bd40e26 |
93 | if (ord("\t") == 9) { # ASCII |
94 | print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c'; |
95 | } |
96 | else { |
97 | print "not " unless sprintf("%vx", "Perl") eq 'd7.85.99.93'; |
98 | } |
b22c7a20 |
99 | print "ok $test\n"; ++$test; |
100 | |
dd629d5b |
101 | print "not " unless sprintf("%vX", 1.22.333.4444) eq '1.16.14D.115C'; |
b22c7a20 |
102 | print "ok $test\n"; ++$test; |
103 | |
7bd40e26 |
104 | if (ord("\t") == 9) { # ASCII |
211dfcf1 |
105 | print "not " unless sprintf("%#*vo", ":", "Perl") eq '0120:0145:0162:0154'; |
7bd40e26 |
106 | } |
107 | else { |
211dfcf1 |
108 | print "not " unless sprintf("%#*vo", ":", "Perl") eq '0327:0205:0231:0223'; |
7bd40e26 |
109 | } |
b22c7a20 |
110 | print "ok $test\n"; ++$test; |
111 | |
112 | print "not " unless sprintf("%*vb", "##", v1.22.333.4444) |
113 | eq '1##10110##101001101##1000101011100'; |
3cb0bbe5 |
114 | print "ok $test\n"; ++$test; |
115 | |
8dbfaa5d |
116 | print "not " unless sprintf("%vd", join("", map { chr } |
c4d5f83a |
117 | unpack 'U*', pack('U*',2001,2002,2003))) |
8dbfaa5d |
118 | eq '2001.2002.2003'; |
119 | print "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 | |
210db7fc |
131 | if (ord("\t") == 9) { # ASCII |
132 | print "not " unless |
133 | sprintf("%vd", 1.22.333.4444) eq '1.22.197.141.225.133.156'; |
134 | } |
135 | else { |
136 | print "not " unless |
137 | sprintf("%vd", 1.22.333.4444) eq '1.22.142.84.187.81.112'; |
138 | } |
b22c7a20 |
139 | print "ok $test\n"; ++$test; |
140 | |
7bd40e26 |
141 | if (ord("\t") == 9) { # ASCII |
142 | print "not " unless sprintf("%vx", "Perl") eq '50.65.72.6c'; |
143 | } |
144 | else { |
145 | print "not " unless sprintf("%vx", "Perl") eq 'd7.85.99.93'; |
146 | } |
b22c7a20 |
147 | print "ok $test\n"; ++$test; |
148 | |
210db7fc |
149 | if (ord("\t") == 9) { # ASCII |
150 | print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.C5.8D.E1.85.9C'; |
151 | } |
152 | else { |
153 | print "not " unless sprintf("%vX", v1.22.333.4444) eq '1.16.8E.54.BB.51.70'; |
154 | } |
b22c7a20 |
155 | print "ok $test\n"; ++$test; |
156 | |
7bd40e26 |
157 | if (ord("\t") == 9) { # ASCII |
211dfcf1 |
158 | print "not " unless sprintf("%#*vo", ":", "Perl") eq '0120:0145:0162:0154'; |
7bd40e26 |
159 | } |
160 | else { |
211dfcf1 |
161 | print "not " unless sprintf("%#*vo", ":", "Perl") eq '0327:0205:0231:0223'; |
7bd40e26 |
162 | } |
b22c7a20 |
163 | print "ok $test\n"; ++$test; |
164 | |
210db7fc |
165 | if (ord("\t") == 9) { # ASCII |
166 | print "not " unless sprintf("%*vb", "##", v1.22.333.4444) |
167 | eq '1##10110##11000101##10001101##11100001##10000101##10011100'; |
168 | } |
169 | else { |
170 | print "not " unless sprintf("%*vb", "##", v1.22.333.4444) |
171 | eq '1##10110##10001110##1010100##10111011##1010001##1110000'; |
172 | } |
3cb0bbe5 |
173 | print "ok $test\n"; ++$test; |
174 | } |
00387047 |
175 | |
176 | { |
177 | # bug id 20000323.056 |
178 | |
179 | print "not " unless "\x{41}" eq +v65; |
180 | print "ok $test\n"; |
181 | $test++; |
182 | |
183 | print "not " unless "\x41" eq +v65; |
184 | print "ok $test\n"; |
185 | $test++; |
186 | |
187 | print "not " unless "\x{c8}" eq +v200; |
188 | print "ok $test\n"; |
189 | $test++; |
190 | |
191 | print "not " unless "\xc8" eq +v200; |
192 | print "ok $test\n"; |
193 | $test++; |
194 | |
195 | print "not " unless "\x{221b}" eq v8731; |
196 | print "ok $test\n"; |
197 | $test++; |
198 | } |