This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make sprintf "%1s" and "%.1s" call overloading once
[perl5.git] / t / op / sprintf2.t
index 2e847ce..d914de0 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
     require './test.pl';
 }   
 
-plan tests => 1368;
+plan tests => 1370;
 
 use strict;
 use Config;
@@ -182,3 +182,12 @@ for my $width (1,2,3,4,5,6,7) {
         );
     }
 }
+
+# Overload count
+package o { use overload '""', sub { ++our $count; $_[0][0]; } }
+my $o = bless ["\x{100}"], o::;
+() = sprintf "%1s", $o;
+is $o::count, '1', 'sprinf %1s overload count';
+$o::count = 0;
+() = sprintf "%.1s", $o;
+is $o::count, '1', 'sprinf %.1s overload count';