erubis 1.1.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +45 -18
- data/README.txt +80 -0
- data/benchmark/erubybench-lib.rb +189 -0
- data/benchmark/erubybench.rb +364 -0
- data/benchmark/erubybench.rhtml +61 -0
- data/benchmark/erubybench.yaml +61 -0
- data/bin/erubis +4 -180
- data/contrib/erubis +2297 -0
- data/contrib/inline-require +151 -0
- data/doc-api/classes/Erubis.html +236 -0
- data/doc-api/classes/Erubis/ArrayBufferEnhancer.html +175 -0
- data/doc-api/classes/Erubis/ArrayBufferEruby.html +120 -0
- data/doc-api/classes/Erubis/ArrayEnhancer.html +174 -0
- data/doc-api/classes/Erubis/ArrayEruby.html +120 -0
- data/doc-api/classes/Erubis/BiPatternEnhancer.html +212 -0
- data/doc-api/classes/Erubis/BiPatternEruby.html +120 -0
- data/doc-api/classes/Erubis/CommandOptionError.html +113 -0
- data/doc-api/classes/Erubis/Context.html +249 -0
- data/doc-api/classes/Erubis/Ec.html +399 -0
- data/doc-api/classes/Erubis/Ejava.html +366 -0
- data/doc-api/classes/Erubis/Ejavascript.html +390 -0
- data/doc-api/classes/Erubis/Engine.html +711 -0
- data/doc-api/classes/Erubis/Eperl.html +350 -0
- data/doc-api/classes/Erubis/Ephp.html +308 -0
- data/doc-api/classes/Erubis/ErubisError.html +117 -0
- data/doc-api/classes/Erubis/Eruby.html +310 -0
- data/doc-api/classes/Erubis/EscapeEnhancer.html +167 -0
- data/doc-api/classes/Erubis/EscapedEc.html +120 -0
- data/doc-api/classes/Erubis/EscapedEjava.html +120 -0
- data/doc-api/classes/Erubis/EscapedEjavascript.html +120 -0
- data/doc-api/classes/Erubis/EscapedEperl.html +120 -0
- data/doc-api/classes/Erubis/EscapedEphp.html +120 -0
- data/doc-api/classes/Erubis/EscapedEruby.html +127 -0
- data/doc-api/classes/Erubis/EscapedEscheme.html +120 -0
- data/doc-api/classes/Erubis/Escheme.html +389 -0
- data/doc-api/classes/Erubis/HeaderFooterEnhancer.html +264 -0
- data/doc-api/classes/Erubis/HeaderFooterEruby.html +120 -0
- data/doc-api/classes/Erubis/Main.html +318 -0
- data/doc-api/classes/Erubis/NoTextEnhancer.html +159 -0
- data/doc-api/classes/Erubis/NoTextEruby.html +120 -0
- data/doc-api/classes/Erubis/OptimizedEruby.html +445 -0
- data/doc-api/classes/Erubis/OptimizedXmlEruby.html +163 -0
- data/doc-api/classes/Erubis/PercentLineEnhancer.html +174 -0
- data/doc-api/classes/Erubis/PercentLineEruby.html +120 -0
- data/doc-api/classes/Erubis/PrintEnabledEnhancer.html +212 -0
- data/doc-api/classes/Erubis/PrintEnabledEruby.html +120 -0
- data/doc-api/classes/Erubis/PrintOutEnhancer.html +244 -0
- data/doc-api/classes/Erubis/PrintOutEruby.html +120 -0
- data/doc-api/classes/Erubis/PrintOutSimplifiedEruby.html +121 -0
- data/doc-api/classes/Erubis/SimplifiedEruby.html +120 -0
- data/doc-api/classes/Erubis/SimplifyEnhancer.html +185 -0
- data/doc-api/classes/Erubis/StdoutEnhancer.html +173 -0
- data/doc-api/classes/Erubis/StdoutEruby.html +120 -0
- data/doc-api/classes/Erubis/StdoutSimplifiedEruby.html +121 -0
- data/doc-api/classes/Erubis/StringBufferEnhancer.html +174 -0
- data/doc-api/classes/Erubis/StringBufferEruby.html +120 -0
- data/doc-api/classes/Erubis/StringIOEruby.html +120 -0
- data/doc-api/classes/Erubis/TinyEruby.html +305 -0
- data/doc-api/classes/Erubis/XmlEruby.html +130 -0
- data/doc-api/classes/Erubis/XmlHelper.html +193 -0
- data/doc-api/created.rid +1 -0
- data/doc-api/files/__/README_txt.html +214 -0
- data/doc-api/files/erubis/engine/ec_rb.html +115 -0
- data/doc-api/files/erubis/engine/ejava_rb.html +115 -0
- data/doc-api/files/erubis/engine/ejavascript_rb.html +115 -0
- data/doc-api/files/erubis/engine/enhanced_rb.html +115 -0
- data/doc-api/files/erubis/engine/eperl_rb.html +115 -0
- data/doc-api/files/erubis/engine/ephp_rb.html +115 -0
- data/doc-api/files/erubis/engine/eruby_rb.html +115 -0
- data/doc-api/files/erubis/engine/escheme_rb.html +115 -0
- data/doc-api/files/erubis/engine/optimized_rb.html +114 -0
- data/doc-api/files/erubis/engine_rb.html +114 -0
- data/doc-api/files/erubis/enhancer_rb.html +114 -0
- data/doc-api/files/erubis/helper_rb.html +107 -0
- data/doc-api/files/erubis/local-setting_rb.html +107 -0
- data/doc-api/files/erubis/main_rb.html +125 -0
- data/doc-api/files/erubis/tiny_rb.html +107 -0
- data/doc-api/files/erubis_rb.html +118 -0
- data/doc-api/fr_class_index.html +77 -0
- data/doc-api/fr_file_index.html +43 -0
- data/doc-api/fr_method_index.html +157 -0
- data/doc-api/index.html +24 -0
- data/doc-api/rdoc-style.css +208 -0
- data/doc/users-guide.html +1507 -375
- data/examples/Makefile +53 -0
- data/examples/example.ec +24 -0
- data/examples/example.ejava +41 -0
- data/examples/example.ejavascript +16 -0
- data/examples/example.eperl +16 -0
- data/examples/example.ephp +17 -0
- data/examples/example.eruby +15 -0
- data/examples/example.escheme +26 -0
- data/lib/erubis.rb +37 -269
- data/lib/erubis/engine.rb +260 -0
- data/lib/erubis/engine/ec.rb +106 -0
- data/lib/erubis/engine/ejava.rb +101 -0
- data/lib/erubis/engine/ejavascript.rb +104 -0
- data/lib/erubis/engine/enhanced.rb +102 -0
- data/lib/erubis/engine/eperl.rb +83 -0
- data/lib/erubis/engine/ephp.rb +84 -0
- data/lib/erubis/engine/eruby.rb +91 -0
- data/lib/erubis/engine/escheme.rb +96 -0
- data/lib/erubis/engine/optimized.rb +114 -0
- data/lib/erubis/enhancer.rb +487 -0
- data/lib/erubis/helper.rb +53 -0
- data/lib/erubis/local-setting.rb +10 -0
- data/lib/erubis/main.rb +368 -0
- data/lib/erubis/tiny.rb +65 -0
- data/test/assert-text-equal.rb +45 -0
- data/test/test-bin.rb +222 -45
- data/test/test-engines.rb +343 -0
- data/test/test-erubis.rb +836 -501
- data/test/test.rb +27 -0
- data/test/testutil.rb +86 -0
- metadata +131 -8
- data/README +0 -50
data/test/test-erubis.rb
CHANGED
@@ -1,537 +1,872 @@
|
|
1
1
|
##
|
2
|
-
## $Rev:
|
3
|
-
## $Release:
|
4
|
-
##
|
2
|
+
## $Rev: 21 $
|
3
|
+
## $Release: 2.0.0 $
|
4
|
+
## copyright(c) 2006 kuwata-lab all rights reserved.
|
5
5
|
##
|
6
6
|
|
7
|
-
|
8
|
-
libdir = testdir == '.' ? '../lib' : File.dirname(testdir) + '/lib'
|
9
|
-
$: << testdir
|
10
|
-
$: << libdir
|
7
|
+
require "#{File.dirname(__FILE__)}/test.rb"
|
11
8
|
|
12
|
-
require 'test/unit'
|
13
|
-
#require 'test/unit/ui/console/testrunner'
|
14
|
-
require 'assert-text-equal'
|
15
|
-
require 'yaml'
|
16
9
|
require 'stringio'
|
17
10
|
|
18
11
|
require 'erubis'
|
12
|
+
require 'erubis/engine/enhanced'
|
13
|
+
require 'erubis/engine/optimized'
|
14
|
+
require 'erubis/tiny'
|
15
|
+
|
19
16
|
|
20
17
|
class ErubisTest < Test::Unit::TestCase
|
18
|
+
extend TestEnhancer
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
str.gsub!(/.*^__END__$/m, '')
|
20
|
+
testdata_list = load_yaml_document(__FILE__)
|
21
|
+
define_testmethods(testdata_list)
|
25
22
|
|
26
|
-
@@ydocs = {}
|
27
|
-
YAML.load_documents(str) do |ydoc|
|
28
|
-
name = ydoc['name']
|
29
|
-
raise "*** test name '#{name}' is duplicated." if @@ydocs[name]
|
30
|
-
ydoc.each do |key, val|
|
31
|
-
if key[-1] == ?*
|
32
|
-
key = key.sub(/\*\z/, '')
|
33
|
-
val = val[$target]
|
34
|
-
ydoc[key] = val
|
35
|
-
end
|
36
|
-
end
|
37
|
-
@@ydocs[name] = ydoc
|
38
|
-
s = <<-END
|
39
|
-
def test_#{name}
|
40
|
-
@name = #{name.dump}
|
41
|
-
_test()
|
42
|
-
end
|
43
|
-
END
|
44
|
-
eval s
|
45
|
-
end
|
46
23
|
|
47
24
|
def _test()
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
25
|
+
@src.gsub!(/\^/, ' ')
|
26
|
+
@output.gsub!(/\^/, ' ') if @output.is_a?(String)
|
27
|
+
@klass = @class ? Erubis.const_get(@class) : Erubis::Eruby
|
28
|
+
@options ||= {}
|
29
|
+
@chomp.each do |target|
|
30
|
+
case target
|
31
|
+
when 'src' ; @src.chomp!
|
32
|
+
when 'input' ; @input.chomp!
|
33
|
+
when 'expected' ; @expected.chomp!
|
34
|
+
else
|
35
|
+
raise "#{@name}: invalid chomp value: #{@chomp.inspect}"
|
36
|
+
end
|
37
|
+
end if @chomp
|
55
38
|
|
56
|
-
if testopt != 'load_file'
|
57
|
-
|
39
|
+
if @testopt != 'load_file'
|
40
|
+
if @klass == Erubis::TinyEruby
|
41
|
+
eruby = @klass.new(@input)
|
42
|
+
else
|
43
|
+
eruby = @klass.new(@input, @options)
|
44
|
+
end
|
58
45
|
else
|
59
|
-
filename = "tmp.#{name}.eruby"
|
46
|
+
filename = "tmp.#{@name}.eruby"
|
60
47
|
begin
|
61
|
-
File.open(filename, 'w') { |f| f.write(input) }
|
62
|
-
eruby = klass.load_file(filename, options)
|
48
|
+
File.open(filename, 'w') { |f| f.write(@input) }
|
49
|
+
eruby = @klass.load_file(filename, @options)
|
63
50
|
ensure
|
64
51
|
File.unlink(filename) if test(?f, filename)
|
65
52
|
end
|
66
53
|
end
|
67
|
-
assert_text_equal(src, eruby.src)
|
54
|
+
assert_text_equal(@src, eruby.src)
|
68
55
|
|
69
|
-
return if testopt == '
|
56
|
+
return if @testopt == 'skip_bufput'
|
70
57
|
|
71
|
-
|
72
|
-
context
|
58
|
+
list = ['<aaa>', 'b&b', '"ccc"']
|
59
|
+
context = @testopt == 'context' ? Erubis::Context.new : {}
|
60
|
+
context[:list] = list
|
73
61
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
62
|
+
case @testopt
|
63
|
+
when/\Aeval\(/
|
64
|
+
eval eruby.src
|
65
|
+
actual = eval @testopt
|
66
|
+
assert_text_equal(@output, actual)
|
67
|
+
when 'stdout', 'print'
|
78
68
|
begin
|
79
69
|
orig = $stdout
|
80
70
|
$stdout = stringio = StringIO.new
|
81
|
-
actual = eruby.evaluate(context)
|
71
|
+
#actual = eruby.evaluate(context)
|
72
|
+
actual = eruby.result(context)
|
82
73
|
ensure
|
83
|
-
$stdout = orig
|
74
|
+
$stdout = orig
|
84
75
|
end
|
85
|
-
|
86
|
-
|
76
|
+
if @testopt == 'stdout'
|
77
|
+
assert_equal("", actual)
|
78
|
+
else
|
79
|
+
assert_nil(actual)
|
80
|
+
end
|
81
|
+
assert_text_equal(@output, stringio.string)
|
82
|
+
when 'evaluate', 'context'
|
83
|
+
actual = eruby.evaluate(context)
|
84
|
+
assert_text_equal(@output, actual)
|
85
|
+
when 'binding'
|
86
|
+
actual = eruby.result(binding())
|
87
|
+
assert_text_equal(@output, actual)
|
88
|
+
else
|
89
|
+
actual = eruby.result(context)
|
90
|
+
assert_text_equal(@output, actual)
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
90
94
|
end
|
91
95
|
|
92
96
|
__END__
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
output: |
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
##
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
output:
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
##
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
output: |
|
157
|
-
|
158
|
-
|
159
|
-
##
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
<
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
<
|
205
|
-
|
206
|
-
</
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
</
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
<
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
<
|
348
|
-
<
|
349
|
-
|
350
|
-
|
351
|
-
<
|
352
|
-
<
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
##
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
97
|
+
- name: basic1
|
98
|
+
input: &basic1_input|
|
99
|
+
<ul>
|
100
|
+
<% for item in list %>
|
101
|
+
<li><%= item %></li>
|
102
|
+
<% end %>
|
103
|
+
</ul>
|
104
|
+
src: |
|
105
|
+
_buf = []; _buf << '<ul>
|
106
|
+
'; for item in list
|
107
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
108
|
+
'; end
|
109
|
+
_buf << '</ul>
|
110
|
+
';
|
111
|
+
_buf.join
|
112
|
+
output: &basic1_bufput|
|
113
|
+
<ul>
|
114
|
+
<li><aaa></li>
|
115
|
+
<li>b&b</li>
|
116
|
+
<li>"ccc"</li>
|
117
|
+
</ul>
|
118
|
+
##
|
119
|
+
- name: basic2
|
120
|
+
input: |
|
121
|
+
<ul>
|
122
|
+
<% i = 0
|
123
|
+
for item in list
|
124
|
+
i += 1
|
125
|
+
%>
|
126
|
+
<li><%= item %></li>
|
127
|
+
<% end %>
|
128
|
+
</ul>
|
129
|
+
src: |
|
130
|
+
_buf = []; _buf << '<ul>
|
131
|
+
'; i = 0
|
132
|
+
for item in list
|
133
|
+
i += 1
|
134
|
+
^^^
|
135
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
136
|
+
'; end
|
137
|
+
_buf << '</ul>
|
138
|
+
';
|
139
|
+
_buf.join
|
140
|
+
output: *basic1_bufput
|
141
|
+
# <ul>
|
142
|
+
# <li><aaa></li>
|
143
|
+
# <li>b&b</li>
|
144
|
+
# <li>"ccc"</li>
|
145
|
+
# </ul>
|
146
|
+
##
|
147
|
+
- name: basic3
|
148
|
+
input: |
|
149
|
+
<ul><% i = 0
|
150
|
+
for item in list
|
151
|
+
i += 1 %><li><%= item %></li><% end %>
|
152
|
+
</ul>
|
153
|
+
src: |
|
154
|
+
_buf = []; _buf << '<ul>'; i = 0
|
155
|
+
for item in list
|
156
|
+
i += 1 ; _buf << '<li>'; _buf << ( item ).to_s; _buf << '</li>'; end ; _buf << '
|
157
|
+
'; _buf << '</ul>
|
158
|
+
';
|
159
|
+
_buf.join
|
160
|
+
output: |
|
161
|
+
<ul><li><aaa></li><li>b&b</li><li>"ccc"</li>
|
162
|
+
</ul>
|
163
|
+
##
|
164
|
+
- name: context1
|
165
|
+
testopt: context
|
166
|
+
input: |
|
167
|
+
<ul>
|
168
|
+
<% for item in @list %>
|
169
|
+
<li><%= item %></li>
|
170
|
+
<% end %>
|
171
|
+
</ul>
|
172
|
+
src: |
|
173
|
+
_buf = []; _buf << '<ul>
|
174
|
+
'; for item in @list
|
175
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
176
|
+
'; end
|
177
|
+
_buf << '</ul>
|
178
|
+
';
|
179
|
+
_buf.join
|
180
|
+
output: *basic1_bufput
|
181
|
+
##
|
182
|
+
- name: ignore1
|
183
|
+
input: |
|
184
|
+
<ul>
|
185
|
+
<%# i = 0 %>
|
186
|
+
<% for item in list %>
|
187
|
+
<%#
|
188
|
+
i += 1
|
189
|
+
color = i % 2 == 0 ? '#FFCCCC' : '#CCCCFF'
|
190
|
+
%>
|
191
|
+
<li> <%#= i %> : <%= item %> </li>
|
192
|
+
<% end %>
|
193
|
+
</ul>
|
194
|
+
src: |
|
195
|
+
_buf = []; _buf << '<ul>
|
196
|
+
';
|
197
|
+
for item in list
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
_buf << ' <li> ';; _buf << ' : '; _buf << ( item ).to_s; _buf << ' </li>
|
203
|
+
'; end
|
204
|
+
_buf << '</ul>
|
205
|
+
';
|
206
|
+
_buf.join
|
207
|
+
output: |
|
208
|
+
<ul>
|
209
|
+
<li> : <aaa> </li>
|
210
|
+
<li> : b&b </li>
|
211
|
+
<li> : "ccc" </li>
|
212
|
+
</ul>
|
213
|
+
##
|
214
|
+
- name: quotation1
|
215
|
+
desc: single quotation and backslash
|
216
|
+
class: Eruby
|
217
|
+
input: "ation1_input|
|
218
|
+
a = "'"
|
219
|
+
b = "\""
|
220
|
+
c = '\''
|
221
|
+
src: |
|
222
|
+
_buf = []; _buf << 'a = "\'"
|
223
|
+
b = "\\""
|
224
|
+
c = \'\\\'\'
|
225
|
+
';
|
226
|
+
_buf.join
|
227
|
+
output: *quotation1_input
|
228
|
+
##
|
229
|
+
- name: pattern1
|
230
|
+
options:
|
231
|
+
:pattern : '\[@ @\]'
|
232
|
+
input: |
|
233
|
+
<ul>
|
234
|
+
[@ for item in list @]
|
235
|
+
<li>[@= item @]</li>
|
236
|
+
[@ end @]
|
237
|
+
</ul>
|
238
|
+
src: |
|
239
|
+
_buf = []; _buf << '<ul>
|
240
|
+
'; for item in list
|
241
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
242
|
+
'; end
|
243
|
+
_buf << '</ul>
|
244
|
+
';
|
245
|
+
_buf.join
|
246
|
+
output: *basic1_bufput
|
247
|
+
# <ul>
|
248
|
+
# <li><aaa></li>
|
249
|
+
# <li>b&b</li>
|
250
|
+
# <li>"ccc"</li>
|
251
|
+
# </ul>
|
252
|
+
##
|
253
|
+
- name: pattern2
|
254
|
+
options:
|
255
|
+
:pattern : '<(?:!--)?% %(?:--)?>'
|
256
|
+
input: |
|
257
|
+
<ul>
|
258
|
+
<!--% for item in list %-->
|
259
|
+
<li><%= item %></li>
|
260
|
+
<!--% end %-->
|
261
|
+
</ul>
|
262
|
+
src: |
|
263
|
+
_buf = []; _buf << '<ul>
|
264
|
+
'; for item in list
|
265
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
266
|
+
'; end
|
267
|
+
_buf << '</ul>
|
268
|
+
';
|
269
|
+
_buf.join
|
270
|
+
output: *basic1_bufput
|
271
|
+
# <ul>
|
272
|
+
# <li><aaa></li>
|
273
|
+
# <li>b&b</li>
|
274
|
+
# <li>"ccc"</li>
|
275
|
+
# </ul>
|
276
|
+
##
|
277
|
+
- name: trim1
|
278
|
+
options:
|
279
|
+
:trim : false
|
280
|
+
input: *basic1_input
|
281
|
+
# <ul>
|
282
|
+
# <% for item in list %>
|
283
|
+
# <li><%= item %></li>
|
284
|
+
# <% end %>
|
285
|
+
# </ul>
|
286
|
+
src: |
|
287
|
+
_buf = []; _buf << '<ul>
|
288
|
+
'; _buf << ' '; for item in list ; _buf << '
|
289
|
+
'; _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
290
|
+
'; _buf << ' '; end ; _buf << '
|
291
|
+
'; _buf << '</ul>
|
292
|
+
';
|
293
|
+
_buf.join
|
294
|
+
output: |
|
295
|
+
<ul>
|
296
|
+
^
|
297
|
+
<li><aaa></li>
|
298
|
+
^
|
299
|
+
<li>b&b</li>
|
300
|
+
^
|
301
|
+
<li>"ccc"</li>
|
302
|
+
^
|
303
|
+
</ul>
|
304
|
+
##
|
305
|
+
- name: bodyonly1
|
306
|
+
testopt: skip_bufput
|
307
|
+
options: { :preamble: no, :postamble: no }
|
308
|
+
input: *basic1_input
|
309
|
+
src: |4
|
310
|
+
_buf << '<ul>
|
311
|
+
'; for item in list
|
312
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
313
|
+
'; end
|
314
|
+
_buf << '</ul>
|
315
|
+
';
|
316
|
+
chomp: [src]
|
317
|
+
expected: null
|
318
|
+
##
|
319
|
+
- name: loadfile1
|
320
|
+
testopt: load_file
|
321
|
+
#input: |
|
322
|
+
# <ul>
|
323
|
+
# <% for item in list %>
|
324
|
+
# <li><%= item %></li>
|
325
|
+
# <% end %>
|
326
|
+
# </ul>
|
327
|
+
input:
|
328
|
+
"<ul>\r\n <% for item in list %>\r\n <li><%= item %></li>\r\n <% end %>\r\n</ul>\r\n"
|
329
|
+
#src: |
|
330
|
+
# _buf = ''; _buf << "<ul>\n"
|
331
|
+
# for item in list
|
332
|
+
# _buf << " <li>"; _buf << ( item ).to_s; _buf << "</li>\n"
|
333
|
+
# end
|
334
|
+
# _buf << "</ul>\n"
|
335
|
+
# _buf
|
336
|
+
src:
|
337
|
+
"_buf = []; _buf << '<ul>\r\n'; for item in list \r\n _buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>\r\n'; end \r\n _buf << '</ul>\r\n';\n_buf.join\n"
|
338
|
+
#output: |
|
339
|
+
# <ul>
|
340
|
+
# <li><aaa></li>
|
341
|
+
# <li>b&b</li>
|
342
|
+
# <li>"ccc"</li>
|
343
|
+
# </ul>
|
344
|
+
output:
|
345
|
+
"<ul>\n <li><aaa></li>\n <li>b&b</li>\n <li>\"ccc\"</li>\n</ul>\n"
|
346
|
+
# "<ul>\r\n <li><aaa></li>\r\n <li>b&b</li>\r\n <li>\"ccc\"</li>\r\n</ul>\r\n"
|
347
|
+
##
|
348
|
+
- name: nomatch1
|
349
|
+
desc: bug
|
350
|
+
input: &nomatch1|
|
351
|
+
<ul>
|
352
|
+
<li>foo</li>
|
353
|
+
</ul>
|
354
|
+
src: |
|
355
|
+
_buf = []; _buf << '<ul>
|
356
|
+
<li>foo</li>
|
357
|
+
</ul>
|
358
|
+
';
|
359
|
+
_buf.join
|
360
|
+
output: *nomatch1
|
361
|
+
##
|
362
|
+
- name: xml1
|
363
|
+
class: XmlEruby
|
364
|
+
input: |
|
365
|
+
<pre>
|
366
|
+
<% for item in list %>
|
367
|
+
<%= item %>
|
368
|
+
<%== item %>
|
369
|
+
<% end %>
|
370
|
+
</pre>
|
371
|
+
src: |
|
372
|
+
_buf = []; _buf << '<pre>
|
373
|
+
'; for item in list
|
374
|
+
_buf << ' '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '
|
375
|
+
'; _buf << ' '; _buf << ( item ).to_s; _buf << '
|
376
|
+
'; end
|
377
|
+
_buf << '</pre>
|
378
|
+
';
|
379
|
+
_buf.join
|
380
|
+
output: |
|
381
|
+
<pre>
|
382
|
+
<aaa>
|
383
|
+
<aaa>
|
384
|
+
b&b
|
385
|
+
b&b
|
386
|
+
"ccc"
|
387
|
+
"ccc"
|
388
|
+
</pre>
|
389
|
+
##
|
390
|
+
- name: xml2
|
391
|
+
class: XmlEruby
|
392
|
+
testopt: skip_bufput
|
393
|
+
input: |
|
394
|
+
<% for item in list %>
|
395
|
+
<%= item["var#{n}"] %>
|
396
|
+
<%== item["var#{n}"] %>
|
397
|
+
<%=== item["var#{n}"] %>
|
398
|
+
<%==== item["var#{n}"] %>
|
399
|
+
<% end %>
|
400
|
+
src: |
|
401
|
+
_buf = []; for item in list
|
402
|
+
_buf << ' '; _buf << Erubis::XmlHelper.escape_xml( item["var#{n}"] ); _buf << '
|
403
|
+
'; _buf << ' '; _buf << ( item["var#{n}"] ).to_s; _buf << '
|
404
|
+
'; _buf << ' '; $stderr.puts("*** debug: item[\"var\#{n}\"]=#{(item["var#{n}"]).inspect}"); _buf << '
|
405
|
+
'; _buf << ' '; _buf << '
|
406
|
+
'; end
|
407
|
+
_buf.join
|
408
|
+
output: |
|
409
|
+
##
|
410
|
+
- name: printout1
|
411
|
+
class: PrintOutEruby
|
412
|
+
testopt: print
|
413
|
+
input: *basic1_input
|
414
|
+
src: |4
|
415
|
+
print '<ul>
|
416
|
+
'; for item in list
|
417
|
+
print ' <li>'; print(( item ).to_s); print '</li>
|
418
|
+
'; end
|
419
|
+
print '</ul>
|
420
|
+
';
|
421
|
+
output: *basic1_bufput
|
422
|
+
##
|
423
|
+
- name: printenabled1
|
424
|
+
class: PrintEnabledEruby
|
425
|
+
input: &printenabled1_input|
|
426
|
+
<ul>
|
427
|
+
<% for item in list %>
|
428
|
+
<li><% print item %></li>
|
429
|
+
<% end %>
|
430
|
+
</ul>
|
431
|
+
src: |
|
432
|
+
@_buf = _buf = []; _buf << '<ul>
|
433
|
+
'; for item in list
|
434
|
+
_buf << ' <li>'; print item ; _buf << '</li>
|
435
|
+
'; end
|
436
|
+
_buf << '</ul>
|
437
|
+
';
|
438
|
+
_buf.join
|
439
|
+
output: *basic1_bufput
|
440
|
+
# <ul>
|
441
|
+
# <li><aaa></li>
|
442
|
+
# <li>b&b</li>
|
443
|
+
# <li>"ccc"</li>
|
444
|
+
# </ul>
|
445
|
+
##
|
446
|
+
- name: stdout1
|
447
|
+
class: StdoutEruby
|
448
|
+
testopt: stdout
|
449
|
+
input: *basic1_input
|
450
|
+
# <ul>
|
451
|
+
# <% for item in list %>
|
452
|
+
# <li><%= item %></li>
|
453
|
+
# <% end %>
|
454
|
+
# </ul>
|
455
|
+
src: |
|
456
|
+
_buf = $stdout; _buf << '<ul>
|
457
|
+
'; for item in list
|
458
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
459
|
+
'; end
|
460
|
+
_buf << '</ul>
|
461
|
+
';
|
462
|
+
''
|
463
|
+
output: *basic1_bufput
|
464
|
+
# <ul>
|
465
|
+
# <li><aaa></li>
|
466
|
+
# <li>b&b</li>
|
467
|
+
# <li>"ccc"</li>
|
468
|
+
# </ul>
|
469
|
+
##
|
470
|
+
- name: array1
|
471
|
+
class: ArrayEruby
|
472
|
+
input: |
|
473
|
+
<ul>
|
474
|
+
<% for item in list %>
|
475
|
+
<li><%= item %></li>
|
476
|
+
<% end %>
|
477
|
+
</ul>
|
478
|
+
src: |
|
479
|
+
_buf = []; _buf << '<ul>
|
480
|
+
'; for item in list
|
481
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
482
|
+
'; end
|
483
|
+
_buf << '</ul>
|
484
|
+
';
|
485
|
+
_buf
|
486
|
+
output:
|
487
|
+
- "<ul>\n"
|
488
|
+
- " <li>"
|
489
|
+
- "<aaa>"
|
490
|
+
- "</li>\n"
|
491
|
+
- " <li>"
|
492
|
+
- "b&b"
|
493
|
+
- "</li>\n"
|
494
|
+
- " <li>"
|
495
|
+
- "\"ccc\""
|
496
|
+
- "</li>\n"
|
497
|
+
- "</ul>\n"
|
498
|
+
##
|
499
|
+
- name: stringbuffer1
|
500
|
+
class: StringBufferEruby
|
501
|
+
input: *basic1_input
|
502
|
+
# <ul>
|
503
|
+
# <% for item in list %>
|
504
|
+
# <li><%= item %></li>
|
505
|
+
# <% end %>
|
506
|
+
# </ul>
|
507
|
+
src: |
|
508
|
+
_buf = ''; _buf << '<ul>
|
509
|
+
'; for item in list
|
510
|
+
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
|
511
|
+
'; end
|
512
|
+
_buf << '</ul>
|
513
|
+
';
|
514
|
+
_buf
|
515
|
+
output: *basic1_bufput
|
516
|
+
# <ul>
|
517
|
+
# <li><aaa></li>
|
518
|
+
# <li>b&b</li>
|
519
|
+
# <li>"ccc"</li>
|
520
|
+
# </ul>
|
521
|
+
##
|
522
|
+
- name: notext1
|
523
|
+
class: NoTextEruby
|
524
|
+
input: *basic1_input
|
525
|
+
src: |
|
526
|
+
_buf = [];
|
527
|
+
for item in list
|
528
|
+
_buf << ( item ).to_s;
|
529
|
+
end
|
530
|
+
|
531
|
+
_buf.join
|
532
|
+
output: '<aaa>b&b"ccc"'
|
533
|
+
##
|
534
|
+
- name: simplified
|
535
|
+
class: SimplifiedEruby
|
536
|
+
input: |
|
537
|
+
<ul>
|
538
|
+
<% for item in list %>
|
539
|
+
<li>
|
540
|
+
<%= item %>
|
541
|
+
</li>
|
542
|
+
<% end %>
|
543
|
+
</ul>
|
544
|
+
src: |
|
545
|
+
_buf = []; _buf << '<ul>
|
546
|
+
'; for item in list ; _buf << '
|
547
|
+
<li>
|
548
|
+
'; _buf << ( item ).to_s; _buf << '
|
549
|
+
</li>
|
550
|
+
'; end ; _buf << '
|
551
|
+
</ul>
|
552
|
+
';
|
553
|
+
_buf.join
|
554
|
+
output: |
|
555
|
+
<ul>
|
556
|
+
^
|
557
|
+
<li>
|
558
|
+
<aaa>
|
559
|
+
</li>
|
560
|
+
^
|
561
|
+
<li>
|
562
|
+
b&b
|
563
|
+
</li>
|
564
|
+
^
|
565
|
+
<li>
|
566
|
+
"ccc"
|
567
|
+
</li>
|
568
|
+
^
|
569
|
+
</ul>
|
570
|
+
##
|
571
|
+
- name: bipattern1
|
572
|
+
class: BiPatternEruby
|
573
|
+
#options: { :bipattern : '\[= =\]' }
|
574
|
+
input: |
|
575
|
+
<% for item in list %>
|
576
|
+
<%= item %> % <%== item %>
|
577
|
+
[= item =] = [== item =]
|
578
|
+
<% end %>
|
579
|
+
src: |
|
580
|
+
_buf = []; for item in list
|
581
|
+
_buf << ' '; _buf << ( item ).to_s; _buf << ' % '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '
|
582
|
+
'; _buf << ' '; _buf << ( item ).to_s; _buf << ' = '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '
|
583
|
+
'; end
|
584
|
+
_buf.join
|
585
|
+
output: |4
|
586
|
+
<aaa> % <aaa>
|
587
|
+
<aaa> = <aaa>
|
588
|
+
b&b % b&b
|
589
|
+
b&b = b&b
|
590
|
+
"ccc" % "ccc"
|
591
|
+
"ccc" = "ccc"
|
592
|
+
##
|
593
|
+
- name: bipattern2
|
594
|
+
class: BiPatternEruby
|
595
|
+
options: { :bipattern: '\$\{ \}' }
|
596
|
+
input: |
|
597
|
+
<% for item in list %>
|
598
|
+
<%=item%> % <%==item%>
|
599
|
+
${item} = ${=item}
|
600
|
+
<% end %>
|
601
|
+
src: |
|
602
|
+
_buf = []; for item in list
|
603
|
+
_buf << ' '; _buf << (item).to_s; _buf << ' % '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '
|
604
|
+
'; _buf << ' '; _buf << (item).to_s; _buf << ' = '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '
|
605
|
+
'; end
|
606
|
+
_buf.join
|
607
|
+
output: |4
|
608
|
+
<aaa> % <aaa>
|
609
|
+
<aaa> = <aaa>
|
610
|
+
b&b % b&b
|
611
|
+
b&b = b&b
|
612
|
+
"ccc" % "ccc"
|
613
|
+
"ccc" = "ccc"
|
614
|
+
##
|
615
|
+
- name: percentline1
|
616
|
+
class: PercentLineEruby
|
617
|
+
options:
|
618
|
+
input: |
|
619
|
+
<table>
|
620
|
+
% for item in list
|
621
|
+
<tr>
|
622
|
+
<td><%= item %></td>
|
623
|
+
<td><%== item %></td>
|
624
|
+
</tr>
|
625
|
+
% end
|
626
|
+
</table>
|
627
|
+
<pre>
|
628
|
+
%% double percent
|
629
|
+
% spaced percent
|
630
|
+
</pre>
|
631
|
+
src: |
|
632
|
+
_buf = []; _buf << '<table>
|
633
|
+
'; for item in list
|
634
|
+
_buf << ' <tr>
|
635
|
+
<td>'; _buf << ( item ).to_s; _buf << '</td>
|
636
|
+
<td>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</td>
|
637
|
+
</tr>
|
638
|
+
'; end
|
639
|
+
_buf << '</table>
|
640
|
+
<pre>
|
641
|
+
'; _buf << '% double percent
|
642
|
+
'; _buf << ' % spaced percent
|
643
|
+
</pre>
|
644
|
+
';
|
645
|
+
_buf.join
|
646
|
+
output: |
|
647
|
+
<table>
|
648
|
+
<tr>
|
649
|
+
<td><aaa></td>
|
650
|
+
<td><aaa></td>
|
651
|
+
</tr>
|
652
|
+
<tr>
|
653
|
+
<td>b&b</td>
|
654
|
+
<td>b&b</td>
|
655
|
+
</tr>
|
656
|
+
<tr>
|
657
|
+
<td>"ccc"</td>
|
658
|
+
<td>"ccc"</td>
|
659
|
+
</tr>
|
660
|
+
</table>
|
661
|
+
<pre>
|
662
|
+
% double percent
|
663
|
+
% spaced percent
|
664
|
+
</pre>
|
665
|
+
##
|
666
|
+
- name: headerfooter1
|
667
|
+
class: HeaderFooterEruby
|
668
|
+
options:
|
669
|
+
testopt: eval('ordered_list(list)')
|
670
|
+
input: |
|
671
|
+
<!--#header:
|
672
|
+
def ordered_list(list)
|
673
|
+
#-->
|
674
|
+
<ol>
|
675
|
+
<% for item in list %>
|
676
|
+
<li><%==item%></li>
|
677
|
+
<% end %>
|
678
|
+
</ol>
|
679
|
+
<!--#footer: end #-->
|
680
|
+
src: |4
|
681
|
+
|
682
|
+
def ordered_list(list)
|
683
|
+
|
684
|
+
_buf = []; _buf << '<ol>
|
685
|
+
'; for item in list
|
686
|
+
_buf << ' <li>'; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '</li>
|
687
|
+
'; end
|
688
|
+
_buf << '</ol>
|
689
|
+
';
|
690
|
+
_buf.join
|
691
|
+
end
|
692
|
+
output: |
|
693
|
+
<ol>
|
694
|
+
<li><aaa></li>
|
695
|
+
<li>b&b</li>
|
696
|
+
<li>"ccc"</li>
|
697
|
+
</ol>
|
698
|
+
##
|
699
|
+
- name: optimized1
|
700
|
+
class: OptimizedEruby
|
701
|
+
input: &optimized1_input|
|
702
|
+
<table>
|
703
|
+
<% for item in list %>
|
704
|
+
<tr>
|
705
|
+
<td><%= item %></td>
|
706
|
+
<td><%== item %></td>
|
707
|
+
</tr>
|
708
|
+
<% end %>
|
709
|
+
</table>
|
710
|
+
<ul><% for item in list %><li><%= item %></li><% end %></ul>
|
711
|
+
src: |
|
712
|
+
_buf = '<table>
|
713
|
+
'; for item in list
|
714
|
+
_buf << ' <tr>
|
715
|
+
<td>' << ( item ).to_s << '</td>
|
716
|
+
<td>' << Erubis::XmlHelper.escape_xml( item ) << '</td>
|
717
|
+
</tr>
|
718
|
+
'; end
|
719
|
+
_buf << '</table>
|
720
|
+
<ul>'; for item in list ; _buf << '<li>' << ( item ).to_s << '</li>'; end ; _buf << '</ul>
|
721
|
+
'
|
722
|
+
_buf
|
723
|
+
output: |
|
724
|
+
<table>
|
725
|
+
<tr>
|
726
|
+
<td><aaa></td>
|
727
|
+
<td><aaa></td>
|
728
|
+
</tr>
|
729
|
+
<tr>
|
730
|
+
<td>b&b</td>
|
731
|
+
<td>b&b</td>
|
732
|
+
</tr>
|
733
|
+
<tr>
|
734
|
+
<td>"ccc"</td>
|
735
|
+
<td>"ccc"</td>
|
736
|
+
</tr>
|
737
|
+
</table>
|
738
|
+
<ul><li><aaa></li><li>b&b</li><li>"ccc"</li></ul>
|
739
|
+
##
|
740
|
+
- name: optimized2
|
741
|
+
class: OptimizedXmlEruby
|
742
|
+
input: *optimized1_input
|
743
|
+
# <table>
|
744
|
+
# <% for item in list %>
|
745
|
+
# <tr>
|
746
|
+
# <td><%= item %></td>
|
747
|
+
# <td><%== item %></td>
|
748
|
+
# </tr>
|
749
|
+
# <% end %>
|
750
|
+
# </table>
|
751
|
+
# <ul><% for item in list %><li><%= item %></li><% end %></ul>
|
752
|
+
src: |
|
753
|
+
_buf = '<table>
|
754
|
+
'; for item in list
|
755
|
+
_buf << ' <tr>
|
756
|
+
<td>' << Erubis::XmlHelper.escape_xml( item ) << '</td>
|
757
|
+
<td>' << ( item ).to_s << '</td>
|
758
|
+
</tr>
|
759
|
+
'; end
|
760
|
+
_buf << '</table>
|
761
|
+
<ul>'; for item in list ; _buf << '<li>' << Erubis::XmlHelper.escape_xml( item ) << '</li>'; end ; _buf << '</ul>
|
762
|
+
'
|
763
|
+
_buf
|
764
|
+
output: |
|
765
|
+
<table>
|
766
|
+
<tr>
|
767
|
+
<td><aaa></td>
|
768
|
+
<td><aaa></td>
|
769
|
+
</tr>
|
770
|
+
<tr>
|
771
|
+
<td>b&b</td>
|
772
|
+
<td>b&b</td>
|
773
|
+
</tr>
|
774
|
+
<tr>
|
775
|
+
<td>"ccc"</td>
|
776
|
+
<td>"ccc"</td>
|
777
|
+
</tr>
|
778
|
+
</table>
|
779
|
+
<ul><li><aaa></li><li>b&b</li><li>"ccc"</li></ul>
|
780
|
+
##
|
781
|
+
- name: optimized3
|
782
|
+
desc: bug
|
783
|
+
class: OptimizedEruby
|
784
|
+
input: |
|
785
|
+
user = <%= "Foo" %>
|
786
|
+
<% for item in list %>
|
787
|
+
<%= item %>
|
788
|
+
<% end %>
|
789
|
+
src: |
|
790
|
+
_buf = 'user = '; _buf << ( "Foo" ).to_s << '
|
791
|
+
'; for item in list
|
792
|
+
_buf << ' ' << ( item ).to_s << '
|
793
|
+
'; end
|
377
794
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
name:
|
401
|
-
|
402
|
-
|
403
|
-
input: |
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
<
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
<
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
<% end %>
|
456
|
-
</ul>
|
457
|
-
src: |
|
458
|
-
@_out = _out = ''; _out << "<ul>\n"
|
459
|
-
for item in list
|
460
|
-
_out << " <li>"; print item ; _out << "</li>\n"
|
461
|
-
end
|
462
|
-
_out << "</ul>\n"
|
463
|
-
_out
|
464
|
-
output: |
|
465
|
-
<ul>
|
466
|
-
<li><aaa></li>
|
467
|
-
<li>b&b</li>
|
468
|
-
<li>"ccc"</li>
|
469
|
-
</ul>
|
470
|
-
---
|
471
|
-
name: print2
|
472
|
-
class: PrintXmlEruby
|
473
|
-
input: |
|
474
|
-
<ul>
|
475
|
-
<% for item in list %>
|
476
|
-
<li><% print item %></li>
|
477
|
-
<% end %>
|
478
|
-
</ul>
|
479
|
-
src: |
|
480
|
-
@_out = _out = ''; _out << "<ul>\n"
|
481
|
-
for item in list
|
482
|
-
_out << " <li>"; print item ; _out << "</li>\n"
|
483
|
-
end
|
484
|
-
_out << "</ul>\n"
|
485
|
-
_out
|
486
|
-
output: |
|
487
|
-
<ul>
|
488
|
-
<li><aaa></li>
|
489
|
-
<li>b&b</li>
|
490
|
-
<li>"ccc"</li>
|
491
|
-
</ul>
|
492
|
-
---
|
493
|
-
name: loadfile1
|
494
|
-
testopt: load_file
|
495
|
-
#input: |
|
496
|
-
# <ul>
|
497
|
-
# <% for item in list %>
|
498
|
-
# <li><%= item %></li>
|
499
|
-
# <% end %>
|
500
|
-
# </ul>
|
501
|
-
input:
|
502
|
-
"<ul>\r\n <% for item in list %>\r\n <li><%= item %></li>\r\n <% end %>\r\n</ul>\r\n"
|
503
|
-
#src: |
|
504
|
-
# _out = ''; _out << "<ul>\n"
|
505
|
-
# for item in list
|
506
|
-
# _out << " <li>"; _out << ( item ).to_s; _out << "</li>\n"
|
507
|
-
# end
|
508
|
-
# _out << "</ul>\n"
|
509
|
-
# _out
|
510
|
-
src:
|
511
|
-
"_out = ''; _out << \"<ul>\\r\\n\"\n for item in list \r\n_out << \" <li>\"; _out << ( item ).to_s; _out << \"</li>\\r\\n\"\n end \r\n_out << \"</ul>\\r\\n\"\n_out\n"
|
512
|
-
#output: |
|
513
|
-
# <ul>
|
514
|
-
# <li><aaa></li>
|
515
|
-
# <li>b&b</li>
|
516
|
-
# <li>"ccc"</li>
|
517
|
-
# </ul>
|
518
|
-
output:
|
519
|
-
"<ul>\r\n <li><aaa></li>\r\n <li>b&b</li>\r\n <li>\"ccc\"</li>\r\n</ul>\r\n"
|
520
|
-
##
|
521
|
-
---
|
522
|
-
name: nomatch1
|
523
|
-
desc: bug
|
524
|
-
input: |
|
525
|
-
<ul>
|
526
|
-
<li>foo</li>
|
527
|
-
</ul>
|
528
|
-
src: |
|
529
|
-
_out = ''; _out << "<ul>\n"
|
530
|
-
_out << " <li>foo</li>\n"
|
531
|
-
_out << "</ul>\n"
|
532
|
-
_out
|
533
|
-
output: |
|
534
|
-
<ul>
|
535
|
-
<li>foo</li>
|
536
|
-
</ul>
|
795
|
+
_buf
|
796
|
+
output: |
|
797
|
+
user = Foo
|
798
|
+
<aaa>
|
799
|
+
b&b
|
800
|
+
"ccc"
|
801
|
+
##
|
802
|
+
- name: optimized4
|
803
|
+
desc: single quotation and backslash
|
804
|
+
class: OptimizedEruby
|
805
|
+
input: &optimized4_input|
|
806
|
+
a = "'"
|
807
|
+
b = "\""
|
808
|
+
c = '\''
|
809
|
+
src: |
|
810
|
+
_buf = 'a = "\'"
|
811
|
+
b = "\\""
|
812
|
+
c = \'\\\'\'
|
813
|
+
';
|
814
|
+
_buf
|
815
|
+
output: *optimized4_input
|
816
|
+
##
|
817
|
+
- name: tiny1
|
818
|
+
class: TinyEruby
|
819
|
+
testopt: binding
|
820
|
+
input: |
|
821
|
+
<ul>
|
822
|
+
<% for item in list %>
|
823
|
+
<li><%= item %></li>
|
824
|
+
<% end %>
|
825
|
+
</ul>
|
826
|
+
src: |
|
827
|
+
_buf = []; _buf << '<ul>
|
828
|
+
'; for item in list ; _buf << '
|
829
|
+
<li>'; _buf << ( item ).to_s; _buf << '</li>
|
830
|
+
'; end ; _buf << '
|
831
|
+
</ul>
|
832
|
+
';
|
833
|
+
_buf.join
|
834
|
+
output: |
|
835
|
+
<ul>
|
836
|
+
^
|
837
|
+
<li><aaa></li>
|
838
|
+
^
|
839
|
+
<li>b&b</li>
|
840
|
+
^
|
841
|
+
<li>"ccc"</li>
|
842
|
+
^
|
843
|
+
</ul>
|
844
|
+
##
|
845
|
+
- name: tiny2
|
846
|
+
class: TinyEruby
|
847
|
+
testopt: evaluate
|
848
|
+
input: |
|
849
|
+
<ul>
|
850
|
+
<% for item in @list %>
|
851
|
+
<li><%= item %></li>
|
852
|
+
<% end %>
|
853
|
+
</ul>
|
854
|
+
src: |
|
855
|
+
_buf = []; _buf << '<ul>
|
856
|
+
'; for item in @list ; _buf << '
|
857
|
+
<li>'; _buf << ( item ).to_s; _buf << '</li>
|
858
|
+
'; end ; _buf << '
|
859
|
+
</ul>
|
860
|
+
';
|
861
|
+
_buf.join
|
862
|
+
output: |
|
863
|
+
<ul>
|
864
|
+
^
|
865
|
+
<li><aaa></li>
|
866
|
+
^
|
867
|
+
<li>b&b</li>
|
868
|
+
^
|
869
|
+
<li>"ccc"</li>
|
870
|
+
^
|
871
|
+
</ul>
|
537
872
|
##
|