source: trunk/essentials/dev-lang/perl/t/op/repeat.t@ 3212

Last change on this file since 3212 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 4.6 KB
Line 
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
8require './test.pl';
9plan(tests => 42);
10
11# compile time
12
13is('-' x 5, '-----', 'compile time x');
14is('-' x 3.1, '---', 'compile time 3.1');
15is('-' x 3.9, '---', 'compile time 3.9');
16is('-' x 1, '-', ' x 1');
17is('-' x 0, '', ' x 0');
18is('-' x -1, '', ' x -1');
19is('-' x undef, '', ' x undef');
20is('-' x "foo", '', ' x "foo"');
21is('-' x "3rd", '---', ' x "3rd"');
22
23is('ab' x 3, 'ababab', ' more than one char');
24
25# run time
26
27$a = '-';
28is($a x 5, '-----', 'run time x');
29is($a x 3.1, '---', ' x 3.1');
30is($a x 3.9, '---', ' x 3.9');
31is($a x 1, '-', ' x 1');
32is($a x 0, '', ' x 0');
33is($a x -3, '', ' x -3');
34is($a x undef, '', ' x undef');
35is($a x "foo", '', ' x "foo"');
36is($a x "3rd", '---', ' x "3rd"');
37
38$a = 'ab';
39is($a x 3, 'ababab', ' more than one char');
40$a = 'ab';
41is($a x 0, '', ' more than one char');
42$a = 'ab';
43is($a x -12, '', ' more than one char');
44
45$a = 'xyz';
46$a x= 2;
47is($a, 'xyzxyz', 'x=2');
48$a x= 1;
49is($a, 'xyzxyz', 'x=1');
50$a x= 0;
51is($a, '', 'x=0');
52
53@x = (1,2,3);
54
55is(join('', @x x 4), '3333', '@x x Y');
56is(join('', (@x) x 4), '123123123123', '(@x) x Y');
57is(join('', (@x,()) x 4), '123123123123', '(@x,()) x Y');
58is(join('', (@x,1) x 4), '1231123112311231', '(@x,1) x Y');
59is(join(':', () x 4), '', '() x Y');
60is(join(':', (9) x 4), '9:9:9:9', '(X) x Y');
61is(join(':', (9,9) x 4), '9:9:9:9:9:9:9:9', '(X,X) x Y');
62is(join('', (split(//,"123")) x 2), '123123', 'split and x');
63
64is(join('', @x x -12), '', '@x x -12');
65is(join('', (@x) x -14), '', '(@x) x -14');
66
67
68# This test is actually testing for Digital C compiler optimizer bug,
69# present in Dec C versions 5.* and 6.0 (used in Digital UNIX and VMS),
70# found in December 1998. The bug was reported to Digital^WCompaq as
71# DECC 2745 (21-Dec-1998)
72# GEM_BUGS 7619 (23-Dec-1998)