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