This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix a2p translation of '{print "a" "b" "c"}'
[perl5.git] / t / op / write.t
CommitLineData
a687059c
LW
1#!./perl
2
79072805 3# $RCSfile: write.t,v $$Revision: 4.1 $$Date: 92/08/07 18:28:38 $
a687059c 4
0f85fab0 5print "1..3\n";
a687059c
LW
6
7format OUT =
8the quick brown @<<
9$fox
10jumped
11@*
12$multiline
13^<<<<<<<<<
14$foo
15^<<<<<<<<<
16$foo
17^<<<<<<...
18$foo
19now @<<the@>>>> for all@|||||men to come @<<<<
a0d0e21e
LW
20{
21 'i' . 's', "time\n", $good, 'to'
22}
a687059c
LW
23.
24
a0d0e21e 25open(OUT, '>Op_write.tmp') || die "Can't create Op_write.tmp";
a687059c
LW
26
27$fox = 'foxiness';
28$good = 'good';
29$multiline = "forescore\nand\nseven years\n";
30$foo = 'when in the course of human events it becomes necessary';
31write(OUT);
32close OUT;
33
34$right =
35"the quick brown fox
36jumped
37forescore
38and
39seven years
40when in
41the course
42of huma...
43now is the time for all good men to come to\n";
44
a0d0e21e
LW
45if (`cat Op_write.tmp` eq $right)
46 { print "ok 1\n"; unlink 'Op_write.tmp'; }
a687059c
LW
47else
48 { print "not ok 1\n"; }
49
748a9306
LW
50$fox = 'wolfishness';
51my $fox = 'foxiness'; # Test a lexical variable.
52
a687059c
LW
53format OUT2 =
54the quick brown @<<
55$fox
56jumped
57@*
58$multiline
59^<<<<<<<<< ~~
60$foo
61now @<<the@>>>> for all@|||||men to come @<<<<
62'i' . 's', "time\n", $good, 'to'
63.
64
a0d0e21e 65open OUT2, '>Op_write.tmp' or die "Can't create Op_write.tmp";
a687059c 66
a687059c
LW
67$good = 'good';
68$multiline = "forescore\nand\nseven years\n";
69$foo = 'when in the course of human events it becomes necessary';
70write(OUT2);
71close OUT2;
72
73$right =
74"the quick brown fox
75jumped
76forescore
77and
78seven years
79when in
80the course
81of human
82events it
83becomes
84necessary
85now is the time for all good men to come to\n";
86
a0d0e21e
LW
87if (`cat Op_write.tmp` eq $right)
88 { print "ok 2\n"; unlink 'Op_write.tmp'; }
a687059c
LW
89else
90 { print "not ok 2\n"; }
91
0f85fab0
LW
92eval <<'EOFORMAT';
93format OUT2 =
94the brown quick @<<
95$fox
96jumped
97@*
98$multiline
a0d0e21e 99and
0f85fab0
LW
100^<<<<<<<<< ~~
101$foo
102now @<<the@>>>> for all@|||||men to come @<<<<
103'i' . 's', "time\n", $good, 'to'
104.
105EOFORMAT
106
a0d0e21e 107open(OUT2, '>Op_write.tmp') || die "Can't create Op_write.tmp";
0f85fab0
LW
108
109$fox = 'foxiness';
110$good = 'good';
111$multiline = "forescore\nand\nseven years\n";
112$foo = 'when in the course of human events it becomes necessary';
113write(OUT2);
114close OUT2;
115
116$right =
117"the brown quick fox
118jumped
119forescore
120and
121seven years
a0d0e21e 122and
0f85fab0
LW
123when in
124the course
125of human
126events it
127becomes
128necessary
129now is the time for all good men to come to\n";
130
a0d0e21e
LW
131if (`cat Op_write.tmp` eq $right)
132 { print "ok 3\n"; unlink 'Op_write.tmp'; }
0f85fab0
LW
133else
134 { print "not ok 3\n"; }
135