formatr 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (18) hide show
  1. data/lib/formatr.rb +1462 -0
  2. data/test/1 +55 -0
  3. data/test/10 +7 -0
  4. data/test/11 +2 -0
  5. data/test/12 +3 -0
  6. data/test/13 +290 -0
  7. data/test/14 +5 -0
  8. data/test/15 +8 -0
  9. data/test/2 +129 -0
  10. data/test/3 +9 -0
  11. data/test/4 +100 -0
  12. data/test/5 +200 -0
  13. data/test/6 +6 -0
  14. data/test/7 +6 -0
  15. data/test/8 +40 -0
  16. data/test/format_test.pl +377 -0
  17. data/test/test_formatr.rb +761 -0
  18. metadata +62 -0
data/test/3 ADDED
@@ -0,0 +1,9 @@
1
+ Piggy Locations for Sep 18, 2001
2
+
3
+ Number: location toe size
4
+ -------------------------------------------
5
+ 1) Market 3.50
6
+ 2) Home 7.00
7
+ 3) Eating Roast Beef 10.50
8
+ 4) Having None 14.00
9
+ 5) On the way home 17.50
data/test/4 ADDED
@@ -0,0 +1,100 @@
1
+ Piggy Locations for Sep 18, 2001
2
+
3
+ Number: location toe size
4
+ -------------------------------------------
5
+ 1) Market 3.50
6
+ 2) Home 7.00
7
+ 3) Eating Roast Beef 10.50
8
+ 4) Having None 14.00
9
+ 5) On the way home 17.50
10
+ -------------------------------------------
11
+ Piggy Locations for Sep 18, 2001
12
+
13
+ Number: location toe size
14
+ -------------------------------------------
15
+ 1) Market 3.50
16
+ 2) Home 7.00
17
+ 3) Eating Roast Beef 10.50
18
+ 4) Having None 14.00
19
+ 5) On the way home 17.50
20
+ -------------------------------------------
21
+ Piggy Locations for Sep 18, 2001
22
+
23
+ Number: location toe size
24
+ -------------------------------------------
25
+ 1) Market 3.50
26
+ 2) Home 7.00
27
+ 3) Eating Roast Beef 10.50
28
+ 4) Having None 14.00
29
+ 5) On the way home 17.50
30
+ -------------------------------------------
31
+ Piggy Locations for Sep 18, 2001
32
+
33
+ Number: location toe size
34
+ -------------------------------------------
35
+ 1) Market 3.50
36
+ 2) Home 7.00
37
+ 3) Eating Roast Beef 10.50
38
+ 4) Having None 14.00
39
+ 5) On the way home 17.50
40
+ -------------------------------------------
41
+ Piggy Locations for Sep 18, 2001
42
+
43
+ Number: location toe size
44
+ -------------------------------------------
45
+ 1) Market 3.50
46
+ 2) Home 7.00
47
+ 3) Eating Roast Beef 10.50
48
+ 4) Having None 14.00
49
+ 5) On the way home 17.50
50
+ -------------------------------------------
51
+ Piggy Locations for Sep 18, 2001
52
+
53
+ Number: location toe size
54
+ -------------------------------------------
55
+ 1) Market 3.50
56
+ 2) Home 7.00
57
+ 3) Eating Roast Beef 10.50
58
+ 4) Having None 14.00
59
+ 5) On the way home 17.50
60
+ -------------------------------------------
61
+ Piggy Locations for Sep 18, 2001
62
+
63
+ Number: location toe size
64
+ -------------------------------------------
65
+ 1) Market 3.50
66
+ 2) Home 7.00
67
+ 3) Eating Roast Beef 10.50
68
+ 4) Having None 14.00
69
+ 5) On the way home 17.50
70
+ -------------------------------------------
71
+ Piggy Locations for Sep 18, 2001
72
+
73
+ Number: location toe size
74
+ -------------------------------------------
75
+ 1) Market 3.50
76
+ 2) Home 7.00
77
+ 3) Eating Roast Beef 10.50
78
+ 4) Having None 14.00
79
+ 5) On the way home 17.50
80
+ -------------------------------------------
81
+ Piggy Locations for Sep 18, 2001
82
+
83
+ Number: location toe size
84
+ -------------------------------------------
85
+ 1) Market 3.50
86
+ 2) Home 7.00
87
+ 3) Eating Roast Beef 10.50
88
+ 4) Having None 14.00
89
+ 5) On the way home 17.50
90
+ -------------------------------------------
91
+ Piggy Locations for Sep 18, 2001
92
+
93
+ Number: location toe size
94
+ -------------------------------------------
95
+ 1) Market 3.50
96
+ 2) Home 7.00
97
+ 3) Eating Roast Beef 10.50
98
+ 4) Having None 14.00
99
+ 5) On the way home 17.50
100
+ -------------------------------------------
data/test/5 ADDED
@@ -0,0 +1,200 @@
1
+ Piggy Locations for Sep 19, 2001
2
+
3
+ Number: location toe size
4
+ -------------------------------------------
5
+ 1) Market 1
6
+ 2) Home 1
7
+ 3) Eating Roast Beef 1
8
+ 4) Having None 1
9
+ 5) On the way home 1
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+ -------------------------------------------
21
+ Piggy Locations for Sep 19, 2001
22
+
23
+ Number: location toe size
24
+ -------------------------------------------
25
+ 1) Market 1
26
+ 2) Home 1
27
+ 3) Eating Roast Beef 1
28
+ 4) Having None 1
29
+ 5) On the way home 1
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+ -------------------------------------------
41
+ Piggy Locations for Sep 19, 2001
42
+
43
+ Number: location toe size
44
+ -------------------------------------------
45
+ 1) Market 1
46
+ 2) Home 1
47
+ 3) Eating Roast Beef 1
48
+ 4) Having None 1
49
+ 5) On the way home 1
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+ -------------------------------------------
61
+ Piggy Locations for Sep 19, 2001
62
+
63
+ Number: location toe size
64
+ -------------------------------------------
65
+ 1) Market 1
66
+ 2) Home 1
67
+ 3) Eating Roast Beef 1
68
+ 4) Having None 1
69
+ 5) On the way home 1
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+ -------------------------------------------
81
+ Piggy Locations for Sep 19, 2001
82
+
83
+ Number: location toe size
84
+ -------------------------------------------
85
+ 1) Market 1
86
+ 2) Home 1
87
+ 3) Eating Roast Beef 1
88
+ 4) Having None 1
89
+ 5) On the way home 1
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ -------------------------------------------
101
+ Piggy Locations for Sep 19, 2001
102
+
103
+ Number: location toe size
104
+ -------------------------------------------
105
+ 1) Market 1
106
+ 2) Home 1
107
+ 3) Eating Roast Beef 1
108
+ 4) Having None 1
109
+ 5) On the way home 1
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ -------------------------------------------
121
+ Piggy Locations for Sep 19, 2001
122
+
123
+ Number: location toe size
124
+ -------------------------------------------
125
+ 1) Market 1
126
+ 2) Home 1
127
+ 3) Eating Roast Beef 1
128
+ 4) Having None 1
129
+ 5) On the way home 1
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+ -------------------------------------------
141
+ Piggy Locations for Sep 19, 2001
142
+
143
+ Number: location toe size
144
+ -------------------------------------------
145
+ 1) Market 1
146
+ 2) Home 1
147
+ 3) Eating Roast Beef 1
148
+ 4) Having None 1
149
+ 5) On the way home 1
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+ -------------------------------------------
161
+ Piggy Locations for Sep 19, 2001
162
+
163
+ Number: location toe size
164
+ -------------------------------------------
165
+ 1) Market 1
166
+ 2) Home 1
167
+ 3) Eating Roast Beef 1
168
+ 4) Having None 1
169
+ 5) On the way home 1
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+ -------------------------------------------
181
+ Piggy Locations for Sep 19, 2001
182
+
183
+ Number: location toe size
184
+ -------------------------------------------
185
+ 1) Market 1
186
+ 2) Home 1
187
+ 3) Eating Roast Beef 1
188
+ 4) Having None 1
189
+ 5) On the way home 1
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+ -------------------------------------------
data/test/6 ADDED
@@ -0,0 +1,6 @@
1
+ Format that uses the hat
2
+ 012 012 345
3
+ 67890 abcde abcde 123.46 123.46 123.5
4
+ Run out of chars!
5
+ 123.4 56 --
6
+ fg *h i *jklmn123456789
data/test/7 ADDED
@@ -0,0 +1,6 @@
1
+ non_blank: |
2
+ repeat: abc.
3
+ repeat: def.
4
+ repeat: ghi.
5
+ repeat: jkl.
6
+ repeat: mn .
data/test/8 ADDED
@@ -0,0 +1,40 @@
1
+ non_blank: |
2
+ repeat: aaa.
3
+ repeat: aaa.
4
+ repeat: aaa.
5
+ repeat: aaa.
6
+ repeat: aaa.
7
+ repeat: aaa.
8
+ repeat: aaa.
9
+ repeat: aaa.
10
+ repeat: aaa.
11
+ repeat: aaa.
12
+ repeat: aaa.
13
+ repeat: aaa.
14
+ repeat: aaa.
15
+ repeat: aaa.
16
+ repeat: aaa.
17
+ repeat: aaa.
18
+ repeat: aaa.
19
+ repeat: aaa.
20
+ repeat: aaa.
21
+ repeat: aaa.
22
+ repeat: aaa.
23
+ repeat: aaa.
24
+ repeat: aaa.
25
+ repeat: aaa.
26
+ repeat: aaa.
27
+ repeat: aaa.
28
+ repeat: aaa.
29
+ repeat: aaa.
30
+ repeat: aaa.
31
+ repeat: aaa.
32
+ repeat: aaa.
33
+ repeat: aaa.
34
+ repeat: aaa.
35
+ repeat: ab .
36
+
37
+
38
+
39
+
40
+
@@ -0,0 +1,377 @@
1
+ #!/usr/bin/env perl
2
+
3
+ #print "page size is " .$= . "\n"; # 60
4
+
5
+ format TEST_1_TOP =
6
+ Passwd File
7
+ Name Name Login Office Uid Gid Home
8
+ ------------------------------------------------------
9
+ .
10
+
11
+ format TEST_1 =
12
+ @###.# @##########.### @##.###| @.### @##.. .
13
+ $num, $num, $snum, $snum, $snum
14
+ 1234567 1234567.890 -12.340| -12.3 -12.. .
15
+ left|@<<<<| right|@>>>>| |center|@||||| | num|@##.#|
16
+ $twenty_two, $twenty_two, $twenty_two, $snum
17
+ left|22 | right| 22| |center| 22 | num|-12.3|
18
+ .
19
+
20
+ format TEST_2_TOP =
21
+ Passwd File
22
+ Name Name Login Office Uid Gid Home
23
+ ------------------------------------------------------
24
+ .
25
+
26
+ format TEST_2 =
27
+ Foo @<<<< @>>>> @<<<< @>>>>> @##.##### @# @.### @##.#.
28
+ $name, $name, $login, $office, $uid, $uid, $gid, $gid,
29
+ safdsdfsdfsdf
30
+ sdfsdfsdfdfs
31
+ bar @<<<< @>>>> @<<<< @>>>>> @|||||+ +@#####+ @<<<<
32
+ $name, $name, $login, $office, $uid, $gid, $home
33
+ baz ^<<<* *^<<<* ^<< @<_^_<< @||| ^#.## ^##.###
34
+ $name, $name, $name, $login, $login, $home, $uid, $uid
35
+ @#@#
36
+ $uid,$uid
37
+ .
38
+
39
+
40
+ format TEST_3_TOP =
41
+ Piggy Locations for @<< @#, @###
42
+ $month, $day, $year
43
+
44
+ Number: location toe size
45
+ -------------------------------------------
46
+ .
47
+
48
+ format TEST_3 =
49
+ @) @<<<<<<<<<<<<<<<< @#.##
50
+ $num, $location, $toe_size
51
+ .
52
+
53
+ format TEST_4_TOP =
54
+ Piggy Locations for Sep 18, 2001
55
+
56
+ .
57
+
58
+ format TEST_4 =
59
+ Number: location toe size
60
+ -------------------------------------------
61
+ 1) Market 3.50
62
+ 2) Home 7.00
63
+ 3) Eating Roast Beef 10.50
64
+ 4) Having None 14.00
65
+ 5) On the way home 17.50
66
+ -------------------------------------------
67
+ .
68
+ format TEST_5_TOP =
69
+ Piggy Locations for Sep 19, 2001
70
+
71
+ .
72
+ format TEST_5 =
73
+ Number: location toe size
74
+ -------------------------------------------
75
+ 1) Market 1
76
+ 2) Home 1
77
+ 3) Eating Roast Beef 1
78
+ 4) Having None 1
79
+ 5) On the way home 1
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+ -------------------------------------------
91
+ .
92
+
93
+ format TEST_6 =
94
+ Format that uses the hat
95
+ @|| ^<< ^||
96
+ $long, $long, $long
97
+ ^|||| @<<<< ^|||| ^###.## ^###.## ^###.#
98
+ $long, $long, $long, $num, $num, $num
99
+ Run out of chars!
100
+ ^|||| ^<<<< ^|||| --
101
+ $short, $short,$short
102
+ ^<<<*^<<<<*^<<<<<<<<<<<<<
103
+ $long, $long, $long
104
+ .
105
+
106
+ format TEST_11 =
107
+ <?xml version="1.0"?>
108
+ @@@ @@@
109
+ $one,$one,$one,$one,$one,$one
110
+ .
111
+
112
+ format TEST_12 =
113
+ <?xml version="1.0"?>
114
+ @@@ Paul @@@ }Rubel @< @|| @#.#
115
+ $var_one,$var_one,$var_one,$var_one,$var_one,$var_one, $var_two, $var_three, $var_four
116
+ @<<< @<<<
117
+ $var_one,$var_one
118
+ .
119
+
120
+ format TEST_13_TOP =
121
+ ---- Top --- Page Number @<<<----
122
+ $i
123
+ .
124
+
125
+ format TEST_13 =
126
+ @) @<<<<<<<<<<<<<<<< @#.##
127
+ $num, $location, $toe_size
128
+ @) @<<<<<<<<<<<<<<<< @#.##
129
+ $num, $location, $toe_size
130
+ @) @<<<<<<<<<<<<<<<< @#.##
131
+ $num, $location, $toe_size
132
+ @) @<<<<<<<<<<<<<<<< @#.##
133
+ $num, $location, $toe_size
134
+ @) @<<<<<<<<<<<<<<<< @#.##
135
+ $num, $location, $toe_size
136
+ @) @<<<<<<<<<<<<<<<< @#.##
137
+ $num, $location, $toe_size
138
+ @) @<<<<<<<<<<<<<<<< @#.##
139
+ $num, $location, $toe_size
140
+ ---- Bot --- Page Number @<<<----
141
+ $i
142
+ @<
143
+ $ff
144
+ .
145
+
146
+ format TEST_15 =
147
+ @>>>>>>>>>>>>>> ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
148
+ $author, $quote
149
+ ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
150
+ $quote
151
+ .
152
+
153
+ format TEST_14 =
154
+ 1)Test of add @<<<< @|||||
155
+ $b.$a, $c++ + $d++
156
+
157
+ 2)Test of add @<<<< @|||
158
+ $a . $b, $c++ + $d++
159
+ .
160
+
161
+ #this test is at the bottom as it breaks syntax highlighting on my emacs :(
162
+ format TEST_7 =
163
+ ~ non_blank: @<<<|
164
+ $non_blank
165
+ ~ blank unless $blank holds something, which it doesn't @<<<
166
+ $blank
167
+ ~~ repeat: ^<<.
168
+ $string
169
+ .
170
+
171
+
172
+
173
+ #this is just broken in the rounding front, I don't think
174
+ # this bug should be replicated
175
+ format TEST_FORMAT =
176
+ ^#.### ^##.##
177
+ $num, $num
178
+ .
179
+
180
+ $test_num = $ARGV[0];
181
+
182
+ ## Test 1
183
+
184
+ if ($test_num == 1) {
185
+ open (TEST_1, ">-");
186
+ $twenty_two = '22';
187
+ $num = 1234567.89012455;
188
+ $snum = -12.34;
189
+ # how do you set the number of lines per page, $= ($FORMAT_LINES_PER_PAGE) is
190
+ # supposedly helpful
191
+ for ($i = 0; $i < 13; $i++) {
192
+ write TEST_1;
193
+ }
194
+ }
195
+
196
+ elsif ($test_num == 2) {
197
+ $name = 'Paul Rubel';
198
+ $login = 'rubel@crhc.uiuc.edu';
199
+ $office ='6/301';
200
+ $uid = 124.135791357;
201
+ $gid = -13;
202
+ $home = "/home/rubel";
203
+
204
+ open (TEST_2, ">-");
205
+ for ($i = 0; $i < 20; $i++) {
206
+ write TEST_2;
207
+ }
208
+ }
209
+
210
+ elsif ($test_num == 3) {
211
+ open (TEST_3, ">-");
212
+ $month = "Sep";
213
+ $day = 18;
214
+ $year = 2001;
215
+ @locations = ("Market", "Home", "Eating Roast Beef", "Having None", "On the way home");
216
+ for ($i = 1; $i <= 5; $i++) {
217
+ $num = $i;
218
+ $toe_size = ($num * 3.5);
219
+ $location = $locations[($i-1)];
220
+ write TEST_3;
221
+ }
222
+ }
223
+
224
+ elsif ($test_num == 4) {
225
+ open (TEST_4, ">-");
226
+ $month = "Sep";
227
+ $day = 18;
228
+ $year = 2001;
229
+ $old = select (TEST_4);
230
+ $= = 10;
231
+ for ($i = 0; $i < 10; $i++) {
232
+ write TEST_4
233
+ }
234
+ select($old)
235
+ }
236
+
237
+ elsif ($test_num == 5) {
238
+ open (TEST_5, ">-");
239
+ $month = "Sep";
240
+ $day = 18;
241
+ $year = 2001;
242
+ $old = select (TEST_5);
243
+ $= = 20;
244
+ for ($i = 0; $i < 10; $i++) {
245
+ write TEST_5
246
+ }
247
+ select($old)
248
+ }
249
+
250
+ elsif ($test_num == 6) {
251
+ open (TEST_6, ">-");
252
+ $num = 123.456;
253
+ $long = "01234567890abcde fg h i jklmn12345678901234567890123456.789";
254
+ $short = 123.456;
255
+ write TEST_6;
256
+ }
257
+
258
+ elsif ($test_num == 7) {
259
+ open (TEST_7, ">-");
260
+ $blank = "";
261
+ $non_blank = " ";
262
+ $string = "abcdefghijklmn";
263
+ write TEST_7;
264
+ }
265
+
266
+ elsif ($test_num == 8) {
267
+ print " non_blank: |\n";
268
+ for ($i = 0; $i < 9; $i++) {
269
+ print (" repeat: aaa.\n");
270
+ }
271
+ for ($i = 0; $i < 2; $i++) {
272
+ print " ";
273
+ for ($j = 0; $j < 10; $j++) {
274
+ print (" repeat: aaa.\n");
275
+ }
276
+ }
277
+ print " ";
278
+ for ($i = 0; $i < 4; $i++) {
279
+ print (" repeat: aaa.\n");
280
+ }
281
+ print " repeat: ab .\n";
282
+ print "\n\n\n\n\n";
283
+ }
284
+
285
+ #what about 9? We used 8 twice, this keeps the files and the numbers synched
286
+
287
+ elsif ($test_num == 10) {
288
+ $exp = 1.234e-14;
289
+ $mid = 123.4567E23;
290
+ $big = 123.4567E200;
291
+ $little = 12.34e-20;
292
+ $int = 12;
293
+
294
+ printf ("1 %8.3G %8.2e\n", $exp, $exp);
295
+ printf ("2 %11.6g %9.1E\n", $big, $big);
296
+ printf ("3 %6.2G %6.1e\n", $little, $little);
297
+ printf ("4 %4.0E\n", $mid);# The -n1 says don't wait for peole to join before you send out messages
298
+ printf ("5 %6.1E %4.0e\n", $little,$mid);
299
+ printf ("6 int %6.2g %6.1e\n", $int, $int);
300
+ printf ("7 int %5.1G %5.0E\n", $int, $int);
301
+ }
302
+
303
+ elsif ($test_num == 11) {
304
+ open (TEST_11, ">-");
305
+ $one = 1;
306
+ write TEST_11;
307
+ }
308
+
309
+ elsif ($test_num == 12) {
310
+ open (TEST_12, ">-");
311
+ $var_one = 1;
312
+ $var_two = 2;
313
+ $var_three = 3;
314
+ $var_four = 4.3;
315
+ write TEST_12;
316
+ }
317
+
318
+ elsif ($test_num == 13) {
319
+ open (TEST_13, ">-");
320
+ $old = select (TEST_13);
321
+ $= = 11;
322
+ for ($i = 1; $i < 30 ; $i++) {
323
+ $num = $i;
324
+ $location = "Who Knows";
325
+ $toe_size = $i;
326
+ $ff = "\f";
327
+ write TEST_13;
328
+ }
329
+ select($old)
330
+ }
331
+
332
+ elsif ($test_num == 14) {
333
+ open (TEST_14, ">-");
334
+ $a = "Ruby";
335
+ $b = " Rocks";
336
+ $c = 111;
337
+ $d = 222;
338
+ $d[111] = "ones";
339
+ print ("a + b $d[111]\n");
340
+ print ($d++ . "\n");
341
+ $old = select (TEST_14);
342
+ write TEST_14;
343
+ select($old)
344
+ }
345
+
346
+ elsif ($test_num == 15) {
347
+ open (TEST_15, ">-");
348
+ $author = "Robert Frost";
349
+ $quote = "Whose woods these are I think I know His house is by the village, though ... But I have promises to keep And miles to go before I sleep.";
350
+ $old = select (TEST_15);
351
+ write TEST_15;
352
+ $author = "Bill";
353
+ $quote = "Shall I compare thee to a Summer's day and branch if the result is negative?";
354
+ write TEST_15;
355
+ select($old)
356
+ }
357
+
358
+ elsif ($test_num =~ /x/) {
359
+ print "test x -$test_num-\n";
360
+ open (TEST_FORMAT, ">-");
361
+ $num = 123.355555;
362
+ write TEST_FORMAT;
363
+ }
364
+
365
+ elsif ($test_num =~ /y/) {
366
+ print "test y -$test_num-\n";
367
+ open (TEST_7, ">-");
368
+ $= = 2;
369
+ $blank = "";
370
+ $non_blank = " ";
371
+ $string = "abcdefghijklmn";
372
+ write TEST_7;
373
+ }
374
+
375
+ else {
376
+ print " Usage: format_test.pl test_number\n Where test_number is from 1 to 13\n"
377
+ }