require './test.pl';
}
-plan tests => 1319;
+plan tests => 1368;
use strict;
use Config;
for my $num (@$nums) {
my $w; local $SIG{__WARN__} = sub { $w = shift };
is(sprintf($fmt, $num), $Q ? $num : $fmt, "quad: $fmt -> $num");
- {
- local our $TODO = $Q ? "" : "warning doesn't contain length modifiers";
- like($w, $Q ? '' : qr/Invalid conversion in sprintf: "$fmt"/, "warning: $fmt");
- }
+ like($w, $Q ? '' : qr/Invalid conversion in sprintf: "$fmt"/, "warning: $fmt");
}
}
+# Check unicode vs byte length
+for my $width (1,2,3,4,5,6,7) {
+ for my $precis (1,2,3,4,5,6,7) {
+ my $v = "\x{20ac}\x{20ac}";
+ my $format = "%" . $width . "." . $precis . "s";
+ my $chars = ($precis > 2 ? 2 : $precis);
+ my $space = ($width < 2 ? 0 : $width - $chars);
+ fresh_perl_is(
+ 'my $v = "\x{20ac}\x{20ac}"; my $x = sprintf "'.$format.'", $v; $x =~ /^(\s*)(\S*)$/; print "$_" for map {length} $1, $2',
+ "$space$chars",
+ {},
+ q(sprintf ").$format.q(", "\x{20ac}\x{20ac}"),
+ );
+ }
+}