diff options
author | makoto kuwata <kwa@kuwata-lab.com> | 2006-08-02 08:20:20 +0000 |
---|---|---|
committer | makoto kuwata <kwa@kuwata-lab.com> | 2006-08-02 08:20:20 +0000 |
commit | 9058fefd0b905bc4fac9f681fe76624e042330e8 (patch) | |
tree | 9a1513532f85bceed7ffcc8fed998248dd7cd329 /test | |
parent | 749ac6327f2bc2aabb32acd2f7299b8216f571da (diff) | |
download | erubis-9058fefd0b905bc4fac9f681fe76624e042330e8.tar.gz |
- [refactor] divide Engine class into Converter, Generator, and Evaluator
- [refactor] merge 'pi/enhancer.rb' into 'engine.rb'
- [refacotr] remove 'pi/*.rb'
- [enhance] add PI::TinyEruby
- [change] property ':escape' is renamed to ':escapefunc'
- [enhance] new property '--escape={true|false}'
Diffstat (limited to 'test')
-rw-r--r-- | test/test-engines.rb | 2 | ||||
-rw-r--r-- | test/test-erubis.rb | 171 | ||||
-rw-r--r-- | test/test-main.rb | 108 | ||||
-rw-r--r-- | test/test-notext.rb | 27 | ||||
-rw-r--r-- | test/test-notext.yaml | 514 |
5 files changed, 819 insertions, 3 deletions
diff --git a/test/test-engines.rb b/test/test-engines.rb index cac0591..7c70828 100644 --- a/test/test-engines.rb +++ b/test/test-engines.rb @@ -75,7 +75,7 @@ __END__ <% $i = 0; foreach ($list as $item) { - $i++; + $i++; %> <tr> <td><%= $i %></td> diff --git a/test/test-erubis.rb b/test/test-erubis.rb index 468041a..4fd94df 100644 --- a/test/test-erubis.rb +++ b/test/test-erubis.rb @@ -23,7 +23,13 @@ class ErubisTest < Test::Unit::TestCase def _test() @src.gsub!(/\^/, ' ') @output.gsub!(/\^/, ' ') if @output.is_a?(String) - @klass = @class ? Erubis.const_get(@class) : Erubis::Eruby + if @class + k = Erubis + @class.split('::').each do |name| k = k.const_get(name) end + @klass = k + else + @klass = Erubis::Eruby + end @options ||= {} @chomp.each do |target| case target @@ -59,7 +65,7 @@ class ErubisTest < Test::Unit::TestCase context[:list] = list case @testopt - when/\Aeval\(/ + when /\Aeval\(/ eval eruby.src actual = eval @testopt assert_text_equal(@output, actual) @@ -114,6 +120,7 @@ __END__ <li>b&b</li> <li>"ccc"</li> </ul> + ## - name: basic2 input: | @@ -142,6 +149,7 @@ __END__ # <li>b&b</li> # <li>"ccc"</li> # </ul> + ## - name: basic3 input: | @@ -159,6 +167,7 @@ __END__ output: | <ul><li><aaa></li><li>b&b</li><li>"ccc"</li> </ul> + ## - name: context1 testopt: context @@ -177,6 +186,7 @@ __END__ '; _buf.join output: *basic1_output + ## - name: ignore1 input: | @@ -209,6 +219,7 @@ __END__ <li> : b&b </li> <li> : "ccc" </li> </ul> + ## - name: quotation1 desc: single quotation and backslash @@ -224,6 +235,7 @@ __END__ '; _buf.join output: *quotation1_input + ## - name: pattern1 options: @@ -248,6 +260,7 @@ __END__ # <li>b&b</li> # <li>"ccc"</li> # </ul> + ## - name: pattern2 options: @@ -272,6 +285,7 @@ __END__ # <li>b&b</li> # <li>"ccc"</li> # </ul> + ## - name: trim1 options: @@ -300,6 +314,7 @@ __END__ <li>"ccc"</li> ^ </ul> + ## - name: bodyonly1 testopt: skip_output @@ -314,6 +329,7 @@ __END__ '; chomp: [src] expected: null + ## - name: loadfile1 testopt: load_file @@ -343,6 +359,7 @@ __END__ output: "<ul>\n <li><aaa></li>\n <li>b&b</li>\n <li>\"ccc\"</li>\n</ul>\n" # "<ul>\r\n <li><aaa></li>\r\n <li>b&b</li>\r\n <li>\"ccc\"</li>\r\n</ul>\r\n" + ## - name: nomatch1 desc: bug @@ -357,6 +374,24 @@ __END__ '; _buf.join output: *nomatch1 + +## +- name: escape1 + options: { :escape: true } + input: | + <% str = '<>&"' %> + <%= str %> + <%== str %> + src: | + _buf = []; str = '<>&"' + _buf << Erubis::XmlHelper.escape_xml( str ); _buf << ' + '; _buf << ( str ).to_s; _buf << ' + '; + _buf.join + output: | + <>&" + <>&" + ## - name: xml1 class: XmlEruby @@ -385,6 +420,7 @@ __END__ "ccc" "ccc" </pre> + ## - name: xml2 class: XmlEruby @@ -405,6 +441,7 @@ __END__ '; end _buf.join output: | + ## - name: printout1 class: PrintOutEruby @@ -418,6 +455,7 @@ __END__ print '</ul> '; output: *basic1_output + ## - name: printenabled1 class: PrintEnabledEruby @@ -441,6 +479,7 @@ __END__ # <li>b&b</li> # <li>"ccc"</li> # </ul> + ## - name: stdout1 class: StdoutEruby @@ -465,6 +504,7 @@ __END__ # <li>b&b</li> # <li>"ccc"</li> # </ul> + ## - name: array1 class: ArrayEruby @@ -494,6 +534,7 @@ __END__ - "\"ccc\"" - "</li>\n" - "</ul>\n" + ## - name: stringbuffer1 class: StringBufferEruby @@ -517,6 +558,7 @@ __END__ # <li>b&b</li> # <li>"ccc"</li> # </ul> + ## - name: notext1 class: NoTextEruby @@ -529,6 +571,7 @@ __END__ _buf.join output: '<aaa>b&b"ccc"' + ## - name: nocode1 class: NoCodeEruby @@ -541,6 +584,7 @@ __END__ </ul> output: + ## - name: simplified class: SimplifiedEruby @@ -578,6 +622,7 @@ __END__ </li> ^ </ul> + ## - name: bipattern1 class: BiPatternEruby @@ -600,6 +645,7 @@ __END__ b&b = b&b "ccc" % "ccc" "ccc" = "ccc" + ## - name: bipattern2 class: BiPatternEruby @@ -622,6 +668,7 @@ __END__ b&b = b&b "ccc" % "ccc" "ccc" = "ccc" + ## - name: percentline1 class: PercentLineEruby @@ -673,6 +720,7 @@ __END__ % double percent % spaced percent </pre> + ## - name: headerfooter1 class: HeaderFooterEruby @@ -706,6 +754,7 @@ __END__ <li>b&b</li> <li>"ccc"</li> </ol> + ## - name: optimized1 class: OptimizedEruby @@ -747,6 +796,7 @@ __END__ </tr> </table> <ul><li><aaa></li><li>b&b</li><li>"ccc"</li></ul> + ## - name: optimized2 class: OptimizedXmlEruby @@ -788,6 +838,7 @@ __END__ </tr> </table> <ul><li><aaa></li><li>b&b</li><li>"ccc"</li></ul> + ## - name: optimized3 desc: bug @@ -809,6 +860,7 @@ __END__ <aaa> b&b "ccc" + ## - name: optimized4 desc: single quotation and backslash @@ -824,6 +876,7 @@ __END__ '; _buf output: *optimized4_input + ## - name: tiny1 class: TinyEruby @@ -852,6 +905,7 @@ __END__ <li>"ccc"</li> ^ </ul> + ## - name: tiny2 class: TinyEruby @@ -880,4 +934,117 @@ __END__ <li>"ccc"</li> ^ </ul> + ## +- name: pi1 + class: PI::Eruby + testopt: evaluate + input: &input_pi1| + <ul> + <?rb for item in @list ?> + <li>${item} / $!{item}</li> + <li><%= item %> / <%== item %></li> + <?rb end ?> + </ul> + src: &src_pi1| + _buf = []; _buf << '<ul> + '; for item in @list + _buf << ' <li>'; _buf << Erubis::XmlHelper.escape_xml(item); _buf << ' / '; _buf << (item).to_s; _buf << '</li> + <li>'; _buf << ( item ).to_s; _buf << ' / '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</li> + '; end + _buf << '</ul> + '; + _buf.join + output: &output_pi1| + <ul> + <li><aaa> / <aaa></li> + <li><aaa> / <aaa></li> + <li>b&b / b&b</li> + <li>b&b / b&b</li> + <li>"ccc" / "ccc"</li> + <li>"ccc" / "ccc"</li> + </ul> + +## +- name: pi2 + class: PI::Eruby + options: { :escape: false } + testopt: evaluate + input: *input_pi1 + src: | + _buf = []; _buf << '<ul> + '; for item in @list + _buf << ' <li>'; _buf << (item).to_s; _buf << ' / '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << '</li> + <li>'; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << ' / '; _buf << ( item ).to_s; _buf << '</li> + '; end + _buf << '</ul> + '; + _buf.join + output: | + <ul> + <li><aaa> / <aaa></li> + <li><aaa> / <aaa></li> + <li>b&b / b&b</li> + <li>b&b / b&b</li> + <li>"ccc" / "ccc"</li> + <li>"ccc" / "ccc"</li> + </ul> + +## +- name: pi3 + class: PI::Eruby + options: { :pi: hoge, :prefix: '@' } + testopt: evaluate + input: | + <ul> + <?hoge for item in @list ?> + <li>@{item} / @!{item}</li> + <li><%= item %> / <%== item %></li> + <?hoge end ?> + </ul> + src: *src_pi1 + output: *output_pi1 + +- name: pi4 + class: PI::Eruby + testopt: evaluate + input: | + <?rb-header + def show(list) + ?> + <ul> + <?rb for item in list ?> + <?rb-value item ?> + <?rb end ?> + <?rb-comment + # comment + # comment + ?> + </ul> + <?rb-footer + end + show(@list) ?> + + src: |4 + + def show(list) + + _buf = []; _buf << '<ul> + '; for item in list + _buf << ( item + ).to_s; end + + + + + _buf << '</ul> + '; + _buf.join + + end + show(@list) + + output: | + <ul> + <aaa>b&b"ccc"</ul> + diff --git a/test/test-main.rb b/test/test-main.rb index a486a54..2910d60 100644 --- a/test/test-main.rb +++ b/test/test-main.rb @@ -75,6 +75,62 @@ user: (none) END + PI_INPUT = <<'END' +<ul> + <?rb @list = ['<aaa>', 'b&b', '"ccc"'] + for item in @list ?> + <li>${item} / $!{item} + <%= item %> / <%== item %></li> + <?rb end ?> +<ul> +END + + PI_SRC = <<'END' +_buf = []; _buf << '<ul> +'; @list = ['<aaa>', 'b&b', '"ccc"'] + for item in @list + _buf << ' <li>'; _buf << Erubis::XmlHelper.escape_xml(item); _buf << ' / '; _buf << (item).to_s; _buf << ' + '; _buf << ( item ).to_s; _buf << ' / '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << '</li> +'; end + _buf << '<ul> +'; +_buf.join +END + + PI_ESCAPED_SRC = <<'END' +_buf = []; _buf << '<ul> +'; @list = ['<aaa>', 'b&b', '"ccc"'] + for item in @list + _buf << ' <li>'; _buf << (item).to_s; _buf << ' / '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << ' + '; _buf << Erubis::XmlHelper.escape_xml( item ); _buf << ' / '; _buf << ( item ).to_s; _buf << '</li> +'; end + _buf << '<ul> +'; +_buf.join +END + + PI_OUTPUT = <<'END' +<ul> + <li><aaa> / <aaa> + <aaa> / <aaa></li> + <li>b&b / b&b + b&b / b&b</li> + <li>"ccc" / "ccc" + "ccc" / "ccc"</li> +<ul> +END + + PI_ESCAPED_OUTPUT = <<'END' +<ul> + <li><aaa> / <aaa> + <aaa> / <aaa></li> + <li>b&b / b&b + b&b / b&b</li> + <li>"ccc" / "ccc" + "ccc" / "ccc"</li> +<ul> +END + def _test() if $target name = (caller()[0] =~ /in `test_(.*?)'/) && $1 @@ -397,4 +453,56 @@ END end + def test_pi1 # --pi -x + @input = PI_INPUT + @expected = PI_SRC + @options = '-x --pi' + _test() + end + + def test_pi2 # --pi -x --escape=false + @input = PI_INPUT + @expected = PI_ESCAPED_SRC + @options = '-x --pi --escape=false' + _test() + end + + def test_pi3 # --pi + @input = PI_INPUT + @expected = PI_OUTPUT + @options = '--pi' + _test() + end + + def test_pi4 # --pi --escape=false + @input = PI_INPUT + @expected = PI_ESCAPED_OUTPUT + @options = '--pi --escape=false' + _test() + end + + def test_pi5 # --pi=ruby -x + @input = PI_INPUT.gsub(/<\?rb/, '<?ruby') + @expected = PI_SRC + @options = '--pi=ruby -x' + _test() + end + + def test_pi6 # --pi -xl java + @input = <<'END' +<?java for (int i = 0; i < arr.length; i++) { ?> + - ${arr[i]} / $!{arr[i]} +<?java } ?> +END + @expected = <<'END' +StringBuffer _buf = new StringBuffer(); for (int i = 0; i < arr.length; i++) { +_buf.append(" - "); _buf.append(escape(arr[i])); _buf.append(" / "); _buf.append(arr[i]); _buf.append("\n"); + } +return _buf.toString(); +END + @options = '--pi -xl java' + _test() + end + + end diff --git a/test/test-notext.rb b/test/test-notext.rb new file mode 100644 index 0000000..05ed2a1 --- /dev/null +++ b/test/test-notext.rb @@ -0,0 +1,27 @@ +## +## $Rev$ +## $Release$ +## $Copyright$ +## + +require File.dirname(__FILE__) + '/test' + + +class NoTextTest < Test::Unit::TestCase + + filename = __FILE__.sub(/\.\w+$/, '.yaml') + testdata_list = load_yaml_datafile(filename) + define_testmethods(testdata_list) + + def _test + File.open(@filename, 'w') { |f| f.write(@input) } + begin + result = `notext #{@options} #{@filename}` + expected = @output.gsub(/^\./, '') + assert_text_equal(expected, result) + ensure + File.unlink @filename if test(?f, @filename) + end + end + +end diff --git a/test/test-notext.yaml b/test/test-notext.yaml new file mode 100644 index 0000000..98a1b11 --- /dev/null +++ b/test/test-notext.yaml @@ -0,0 +1,514 @@ +--- +- name: notext_eruby + options: '' + filename: ex-notext.rhtml + document: | + + .$$ Command 'notext' | cmd-notext + + Command 'notext' is a utility to extract only program code from eRuby/PHP/ePerl script. + It is an application of NoTextEnhancer. + + For example, see the following eRuby script. + This is some complex, so it is difficult to grasp the program code. + + .? ex-notext.rhtml + .-------------------- ex-notext.rhtml + [%= ydoc['notext_eruby']['input'].chomp %] + .-------------------- + + Command 'notext' extracts the ruby code from eRuby script. + + .? result + .==================== + $ notext ex-notext.rhtml + [%= ydoc['notext_eruby']['output'].chomp %] + .==================== + + Option '-c' ({{*c*}}ompact) deletes empty lines. + + .? result + .==================== + $ notext -c ex-notext.rhtml + [%= ydoc['notext_eruby_c']['output'].chomp %] + .==================== + + Option '-u' ({{*u*}}nique) replace some empty lines with a empty line. + + .? result + .==================== + $ notext -u ex-notext.rhtml + [%= ydoc['notext_eruby_u']['output'].chomp %] + .==================== + + Option '-n' ({{*n*}}umber) adds line number. + It is available with '-c' or '-n'. + + .? result + .==================== + $ notext -nu ex-notext.rhtml + [%= ydoc['notext_eruby_nu']['output'].chomp %] + .==================== + + 'notext' is available with PHP or ePerl script. + Language is automatically detected by suffix of filename. + And you can specify language with option '-l' ({{*l*}}anguage). + + .? ex-notext.php + .-------------------- + [%= ydoc['notext_php']['input'].chomp %] + .-------------------- + + .? result + .==================== + $ notext -nu ex-notext.php + [%= ydoc['notext_php_nu']['output'].chomp %] + .==================== + + .? ex-notext.eperl + .-------------------- + [%= ydoc['notext_eperl']['input'] %].chomp + .-------------------- + + .? result + .==================== + $ notext -nul eperl ex-notext.eperl + [%= ydoc['notext_eperl_nu']['input'].chomp %] + .==================== + + input: &input_eruby | + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <?xml version="1.0"?> + <!DOCTYPE html + <html> + <body> + <h3>List</h3> + <% if @list.nil? || @list.empty? %> + <p>not found.</p> + <% else %> + <table> + <tbody> + <% @list.each_with_index do |item, i| %> + <tr bgcolor="<%= i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>"> + <td><%= item %></td> + </tr> + <% end %> + </tbody> + </table> + <% end %> + </body> + </html> + output: | + ._buf = []; + . + . + . + . + . + . + . + . + . if @list.nil? || @list.empty? ; + . + . else ; + . + . + . @list.each_with_index do |item, i| ; + . _buf << ( i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ).to_s; + . _buf << ( item ).to_s; + . + . end ; + . + . + . end ; + . + . + ._buf.join + +## +- name: notext_eruby_n + options: '-n' + filename: ex-notext.rhtml + input: *input_eruby + output: | + . 1: _buf = []; + . 2: + . 3: + . 4: + . 5: + . 6: + . 7: + . 8: + . 9: + . 10: if @list.nil? || @list.empty? ; + . 11: + . 12: else ; + . 13: + . 14: + . 15: @list.each_with_index do |item, i| ; + . 16: _buf << ( i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ).to_s; + . 17: _buf << ( item ).to_s; + . 18: + . 19: end ; + . 20: + . 21: + . 22: end ; + . 23: + . 24: + . 25: _buf.join + +## +- name: notext_eruby_c + options: '-c' + filename: ex-notext.rhtml + input: *input_eruby + output: | + ._buf = []; + . if @list.nil? || @list.empty? ; + . else ; + . @list.each_with_index do |item, i| ; + . _buf << ( i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ).to_s; + . _buf << ( item ).to_s; + . end ; + . end ; + ._buf.join + +## +- name: notext_eruby_u + options: '-u' + filename: ex-notext.rhtml + input: &input_eruby | + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> + <?xml version="1.0"?> + <!DOCTYPE html + <html> + <body> + <h3>List</h3> + <% if @list.nil? || @list.empty? %> + <p>not found.</p> + <% else %> + <table> + <tbody> + <% @list.each_with_index do |item, i| %> + <tr bgcolor="<%= i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' %>"> + <td><%= item %></td> + </tr> + <% end %> + </tbody> + </table> + <% end %> + </body> + </html> + output: | + ._buf = []; + . + . if @list.nil? || @list.empty? ; + . + . else ; + . + . @list.each_with_index do |item, i| ; + . _buf << ( i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ).to_s; + . _buf << ( item ).to_s; + . + . end ; + . + . end ; + . + ._buf.join + +## +- name: notext_eruby_nc + options: '-nc' + filename: ex-notext.rhtml + input: *input_eruby + output: | + . 1: _buf = []; + . 10: if @list.nil? || @list.empty? ; + . 12: else ; + . 15: @list.each_with_index do |item, i| ; + . 16: _buf << ( i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ).to_s; + . 17: _buf << ( item ).to_s; + . 19: end ; + . 22: end ; + . 25: _buf.join + +## +- name: notext_eruby_nu + options: '-un' + filename: ex-notext.rhtml + input: *input_eruby + output: | + . 1: _buf = []; + . + . 10: if @list.nil? || @list.empty? ; + . + . 12: else ; + . + . 15: @list.each_with_index do |item, i| ; + . 16: _buf << ( i % 2 == 0 ? '#FFCCCC' : '#CCCCFF' ).to_s; + . 17: _buf << ( item ).to_s; + . + . 19: end ; + . + . 22: end ; + . + . 25: _buf.join +## +--- +- name: notext_php + options: '' + filename: ex-notext.php + input: &input_php | + <?xml version="1.0"?> + <html> + <body> + <h3>List</h3> + <?php if (!$list) { ?> + <p>not found.</p> + <?php } else { ?> + <table> + <tbody> + <?php $i = 0; ?> + <?php foreach ($list as $item) { ?> + <tr bgcolor="<?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?>"> + <td><?php echo $item; ?></td> + </tr> + <?php } ?> + </tbody> + </table> + <?php } ?> + </body> + </html> + output: &output_php | + . + . + . + . + . <?php if (!$list) { ?> + . + . <?php } else { ?> + . + . + . <?php $i = 0; ?> + . <?php foreach ($list as $item) { ?> + . <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + . <?php echo $item; ?> + . + . <?php } ?> + . + . + . <?php } ?> + . + . + +## +- name: notext_php_n + options: '-n' + filename: ex-notext.php + input: *input_php + output: &output_php | + . 1: + . 2: + . 3: + . 4: + . 5: <?php if (!$list) { ?> + . 6: + . 7: <?php } else { ?> + . 8: + . 9: + . 10: <?php $i = 0; ?> + . 11: <?php foreach ($list as $item) { ?> + . 12: <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + . 13: <?php echo $item; ?> + . 14: + . 15: <?php } ?> + . 16: + . 17: + . 18: <?php } ?> + . 19: + . 20: + +## +- name: notext_php_c + options: '-c' + filename: ex-notext.php + input: *input_php + output: &output_php | + . <?php if (!$list) { ?> + . <?php } else { ?> + . <?php $i = 0; ?> + . <?php foreach ($list as $item) { ?> + . <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + . <?php echo $item; ?> + . <?php } ?> + . <?php } ?> + +## +- name: notext_php_u + options: '-u' + filename: ex-notext.php + input: *input_php + output: &output_php | + . + . <?php if (!$list) { ?> + . + . <?php } else { ?> + . + . <?php $i = 0; ?> + . <?php foreach ($list as $item) { ?> + . <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + . <?php echo $item; ?> + . + . <?php } ?> + . + . <?php } ?> + . + +## +- name: notext_php_nc + options: '-nc' + filename: ex-notext.php + input: *input_php + output: &output_php | + . 5: <?php if (!$list) { ?> + . 7: <?php } else { ?> + . 10: <?php $i = 0; ?> + . 11: <?php foreach ($list as $item) { ?> + . 12: <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + . 13: <?php echo $item; ?> + . 15: <?php } ?> + . 18: <?php } ?> + +## +- name: notext_php_nu + options: '-nu' + filename: ex-notext.php + input: *input_php + output: &output_php | + . + . 5: <?php if (!$list) { ?> + . + . 7: <?php } else { ?> + . + . 10: <?php $i = 0; ?> + . 11: <?php foreach ($list as $item) { ?> + . 12: <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + . 13: <?php echo $item; ?> + . + . 15: <?php } ?> + . + . 18: <?php } ?> + . + +## +- name: notext_php_shortnotation + options: '' + filename: ex-short-notation.php + input: | + . <table> + . <? $i = 0; ?> + . <? foreach ($list as $item) { ?> + . <tr bgcolor="<?= ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF' ?>"> + . <td><?= $item ?></td> + . </tr> + . <? } ?> + . </table> + output: | + . + . <?php $i = 0; ?> + . <?php foreach ($list as $item) { ?> + . <?php echo ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'; ?> + . <?php echo $item; ?> + . + . <?php } ?> + . + +## +--- +- name: notext_eperl + options: '' + filename: ex-notext.eperl + input: &input_eperl | + <?xml version="1.0"?> + <html> + <body> + <h3>List</h3> + <? if (!@list) { !> + <p>not found.</p> + <? } else { !> + <table> + <tbody> + <? $i = 0; !> + <? foreach ($item in @list) { !> + <tr bgcolor="<?= ++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF' !>"> + <td><?= $item !></td> + </tr> + <? } !> + </tbody> + </table> + <? } !> + </body> + </html> + output: | + . + . + . + . + . if (!@list) { + . + . } else { + . + . + . $i = 0; + . foreach ($item in @list) { + . print(++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'); + . print($item); + . + . } + . + . + . } + . + . + +## +- name: notext_eperl_nc + options: '-nc' + filename: ex-notext.eperl + input: *input_eperl + output: | + . 5: if (!@list) { + . 7: } else { + . 10: $i = 0; + . 11: foreach ($item in @list) { + . 12: print(++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'); + . 13: print($item); + . 15: } + . 18: } + +## +- name: notext_eperl_nu + options: '-nu' + filename: ex-notext.eperl + input: *input_eperl + output: | + . + . 5: if (!@list) { + . + . 7: } else { + . + . 10: $i = 0; + . 11: foreach ($item in @list) { + . 12: print(++$i % 2 == 1 ? '#FFCCCC' : '#CCCCFF'); + . 13: print($item); + . + . 15: } + . + . 18: } + . |