Lots of consting
[p5sagit/p5-mst-13.2.git] / t / op / repeat.t
index ef462cb..d1083e8 100755 (executable)
@@ -6,13 +6,19 @@ BEGIN {
 }
 
 require './test.pl';
-plan(tests => 24);
+plan(tests => 42);
 
 # compile time
 
 is('-' x 5, '-----',    'compile time x');
+is('-' x 3.1, '---',    'compile time 3.1');
+is('-' x 3.9, '---',    'compile time 3.9');
 is('-' x 1, '-',        '  x 1');
 is('-' x 0, '',         '  x 0');
+is('-' x -1, '',        '  x -1');
+is('-' x undef, '',     '  x undef');
+is('-' x "foo", '',     '  x "foo"');
+is('-' x "3rd", '---',  '  x "3rd"');
 
 is('ab' x 3, 'ababab',  '  more than one char');
 
@@ -20,11 +26,21 @@ is('ab' x 3, 'ababab',  '  more than one char');
 
 $a = '-';
 is($a x 5, '-----',     'run time x');
+is($a x 3.1, '---',     '  x 3.1');
+is($a x 3.9, '---',     '  x 3.9');
 is($a x 1, '-',         '  x 1');
 is($a x 0, '',          '  x 0');
+is($a x -3, '',         '  x -3');
+is($a x undef, '',      '  x undef');
+is($a x "foo", '',      '  x "foo"');
+is($a x "3rd", '---',   '  x "3rd"');
 
 $a = 'ab';
 is($a x 3, 'ababab',    '  more than one char');
+$a = 'ab';
+is($a x 0, '',          '  more than one char');
+$a = 'ab';
+is($a x -12, '',        '  more than one char');
 
 $a = 'xyz';
 $a x= 2;
@@ -45,6 +61,9 @@ is(join(':', (9) x 4),      '9:9:9:9',              '(X) x Y');
 is(join(':', (9,9) x 4),    '9:9:9:9:9:9:9:9',      '(X,X) x Y');
 is(join('', (split(//,"123")) x 2), '123123',       'split and x');
 
+is(join('', @x x -12),      '',                     '@x x -12');
+is(join('', (@x) x -14),    '',                     '(@x) x -14');
+
 
 # This test is actually testing for Digital C compiler optimizer bug,
 # present in Dec C versions 5.* and 6.0 (used in Digital UNIX and VMS),
@@ -118,7 +137,20 @@ is(77, scalar ((1,7)x2),    'stack truncation');
 
 # perlbug 20011113.110 works in 5.6.1, broken in 5.7.2
 {
-    local $TODO = 'list repeat in anon array ref broken [ID 20011113.110]';
-    my $x= [("foo") x 1];
-    is( join('', @$x), 'foofoo' );
+    my $x= [("foo") x 2];
+    is( join('', @$x), 'foofoo', 'list repeat in anon array ref broken [ID 20011113.110]' );
 }
+
+# [ID 20010809.028] x operator not copying elements in 'for' list?
+{
+    local $TODO = "x operator not copying elements in 'for' list? [ID 20010809.028]";
+    my $x = 'abcd';
+    my $y = '';
+    for (($x =~ /./g) x 2) {
+       $y .= chop;
+    }
+    is($y, 'abcdabcd');
+}
+
+# [perl #35885]
+is( (join ',', (qw(a b c) x 3)), 'a,b,c,a,b,c,a,b,c', 'x on qw produces list' );