Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Ruby 2.6 #16

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
32 changes: 21 additions & 11 deletions test/test-engines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def _test()
- name: ruby2_options
lang: ruby
class: Eruby
options: { :bufvar: '@_out_buf' }
options:
:bufvar: '@_out_buf'
input: |
<table>
<% for item in @items %>
Expand Down Expand Up @@ -137,7 +138,9 @@ def _test()
- name: c1
lang: c
class: Ec
options: { :filename: foo.html, :indent: ' ' }
options:
:filename: foo.html
:indent: ' '
input: |4
<table>
<tbody>
Expand Down Expand Up @@ -167,7 +170,9 @@ def _test()
- name: cpp1
lang: cpp
class: Ecpp
options: { :filename: foo.html, :indent: ' ' }
options:
:filename: foo.html
:indent: ' '
input: |4
<table>
<tbody>
Expand Down Expand Up @@ -197,7 +202,10 @@ def _test()
- name: java1
lang: java
class: Ejava
options: { :buf: _buf, :bufclass: StringBuilder, :indent: ' ' }
options:
:buf: _buf,
:bufclass: StringBuilder
:indent: ' '
input: |
<table>
<tbody>
Expand All @@ -220,19 +228,19 @@ def _test()
expected: |4
StringBuilder _buf = new StringBuilder(); _buf.append("<table>\n"
+ " <tbody>\n");

int i = 0;
for (Iterator it = list.iterator(); it.hasNext(); ) {
String s = (String)it.next();
i++;

_buf.append(" <tr class=\""); _buf.append(i%2==0 ? "even" : "odd"); _buf.append("\">\n"
+ " <td>"); _buf.append(i); _buf.append("</td>\n"
+ " <td>"); _buf.append(escape(s)); _buf.append("</td>\n"
+ " </tr>\n");

}

_buf.append(" <tbody>\n"
+ "</table>\n");
System.err.println("*** debug: i="+(i)); _buf.append("\n");
Expand All @@ -242,7 +250,7 @@ def _test()
lang: scheme
class: Escheme
options:
input: &scheme1_input|
input: &scheme1_input |
<% (let ((i 0)) %>
<table>
<tbody>
Expand Down Expand Up @@ -290,7 +298,8 @@ def _test()
- name: scheme2
lang: scheme
class: Escheme
options: { :func: 'display' }
options:
:func: 'display'
input: *scheme1_input
expected: |4
(let ((i 0))
Expand Down Expand Up @@ -401,7 +410,8 @@ def _test()
- name: javascript2
lang: javascript
class: Ejavascript
options: { :docwrite: false }
options:
:docwrite: false
input: *javascript_input
expected: |4
var _buf = [];
Expand Down
14 changes: 8 additions & 6 deletions test/test-enhancers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,21 @@ def _test()
##
- name: basic1
class: Eruby
input: &basic1_input|
input: &basic1_input |
<ul>
<% for item in list %>
<li><%= item %></li>
<% end %>
</ul>
src: &basic1_src|
src: &basic1_src |
_buf = ''; _buf << '<ul>
'; for item in list
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
'; end
_buf << '</ul>
';
_buf.to_s
output: &basic1_output|
output: &basic1_output |
<ul>
<li><aaa></li>
<li>b&b</li>
Expand Down Expand Up @@ -193,7 +193,7 @@ def _test()
##
- name: printenabled1
class: PrintEnabledEruby
input: &printenabled1_input|
input: &printenabled1_input |
<ul>
<% for item in list %>
<li><% print item %></li>
Expand Down Expand Up @@ -425,7 +425,8 @@ def _test()
##
- name: bipattern2
class: BiPatternEruby
options: { :bipattern: '\$\{ \}' }
options:
:bipattern: '\$\{ \}'
input: |
<% for item in list %>
<%=item%> % <%==item%>
Expand Down Expand Up @@ -500,7 +501,8 @@ def _test()
##
- name: prefixedline1
class: PrefixedLineEruby
options: { :prefixchar: '!' }
options:
:prefixchar: '!'
input: |
<table>
! for item in list
Expand Down
34 changes: 20 additions & 14 deletions test/test-erubis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,21 @@ def test_evaluate_creates_proc

__END__
- name: basic1
input: &basic1_input|
input: &basic1_input |
<ul>
<% for item in list %>
<li><%= item %></li>
<% end %>
</ul>
src: &basic1_src|
src: &basic1_src |
_buf = ''; _buf << '<ul>
'; for item in list
_buf << ' <li>'; _buf << ( item ).to_s; _buf << '</li>
'; end
_buf << '</ul>
';
_buf.to_s
output: &basic1_output|
output: &basic1_output |
<ul>
<li><aaa></li>
<li>b&b</li>
Expand Down Expand Up @@ -344,7 +344,7 @@ def test_evaluate_creates_proc
- name: quotation1
desc: single quotation and backslash
class: Eruby
input: &quotation1_input|
input: &quotation1_input |
a = "'"
b = "\""
c = '\''
Expand Down Expand Up @@ -451,7 +451,9 @@ def test_evaluate_creates_proc
##
- name: bodyonly1
testopt: skip_output
options: { :preamble: no, :postamble: no }
options:
:preamble: no
:postamble: no
input: *basic1_input
src: |4
_buf << '<ul>
Expand Down Expand Up @@ -496,7 +498,7 @@ def test_evaluate_creates_proc
##
- name: nomatch1
desc: bug
input: &nomatch1|
input: &nomatch1 |
<ul>
<li>foo</li>
</ul>
Expand All @@ -510,7 +512,8 @@ def test_evaluate_creates_proc

##
- name: escape1
options: { :escape: true }
options:
:escape: true
input: |
<% str = '<>&"' %>
<%= str %>
Expand Down Expand Up @@ -570,7 +573,7 @@ def test_evaluate_creates_proc
##
- name: optimized1
class: OptimizedEruby
input: &optimized1_input|
input: &optimized1_input |
<table>
<% for item in list %>
<tr>
Expand Down Expand Up @@ -677,7 +680,7 @@ def test_evaluate_creates_proc
- name: optimized4
desc: single quotation and backslash
class: OptimizedEruby
input: &optimized4_input|
input: &optimized4_input |
a = "'"
b = "\""
c = '\''
Expand Down Expand Up @@ -751,14 +754,14 @@ def test_evaluate_creates_proc
- name: pi1
class: PI::Eruby
testopt: evaluate
input: &input_pi1|
input: &input_pi1 |
<ul>
<?rb for item in @list ?>
<li>@{item}@ / @!{item}@</li>
<li><%= item %> / <%== item %></li>
<?rb end ?>
</ul>
src: &src_pi1|
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>
Expand All @@ -767,7 +770,7 @@ def test_evaluate_creates_proc
_buf << '</ul>
';
_buf.to_s
output: &output_pi1|
output: &output_pi1 |
<ul>
<li>&lt;aaa&gt; / <aaa></li>
<li><aaa> / &lt;aaa&gt;</li>
Expand All @@ -780,7 +783,8 @@ def test_evaluate_creates_proc
##
- name: pi2
class: PI::Eruby
options: { :escape: false }
options:
:escape: false
testopt: evaluate
input: *input_pi1
src: |
Expand All @@ -805,7 +809,9 @@ def test_evaluate_creates_proc
##
- name: pi3
class: PI::Eruby
options: { :pi: hoge, :embchar: '$' }
options:
:pi: hoge
:embchar: '$'
testopt: evaluate
input: |
<ul>
Expand Down
58 changes: 57 additions & 1 deletion test/test-main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def _with_dummy_file
begin
ENV['PATH'] = bindir + File::PATH_SEPARATOR + ENV['PATH']
ENV['_'] = 'erubis'
Tempfile.open(self.name.gsub(/[^\w]/,'_')) do |f|
Tempfile.open(self.method_name.gsub(/[^\w]/,'_')) do |f|
f.write(INPUT)
f.flush
yield(f.path)
Expand Down Expand Up @@ -272,6 +272,62 @@ def test_syntax2 # -z (syntax error)
END
errmsgs << <<'END'
7: syntax error, unexpected $end, expecting keyword_end
END
elsif ruby20? || ruby21? || ruby22? || ruby23?
errmsgs << <<'END'
3: syntax error, unexpected ']', expecting ')'
_buf << ' <li>'; _buf << ( item[:name]] ).to_s; _buf << '</li>
^
-:4: syntax error, unexpected keyword_end, expecting ')'
'; end
^
-:7: syntax error, unexpected end-of-input, expecting ')'
END
errmsgs << <<'END'
7: syntax error, unexpected end-of-input, expecting keyword_end
END
elsif ruby24?
errmsgs << <<'END'
3: syntax error, unexpected ']', expecting ')'
<li>'; _buf << ( item[:name]] ).to_s; _buf << '</li>
^
-:4: syntax error, unexpected keyword_end, expecting ')'
'; end
^
-:7: syntax error, unexpected end-of-input, expecting ')'
END
errmsgs << <<'END'
7: syntax error, unexpected end-of-input, expecting keyword_end
END
elsif ruby25?
errmsgs << <<'END'
3: syntax error, unexpected ']', expecting ')'
... <li>'; _buf << ( item[:name]] ).to_s; _buf << '</li>
... ^
-:4: syntax error, unexpected keyword_end, expecting ')'
'; end
^~~
-:7: syntax error, unexpected end-of-input, expecting ')'
_buf.to_s
^
END
errmsgs << <<'END'
7: syntax error, unexpected end-of-input, expecting keyword_end
_buf.to_s
^
END
elsif ruby26?
errmsgs << <<'END'
3: syntax error, unexpected ']', expecting ')'
... <li>'; _buf << ( item[:name]] ).to_s; _buf << '</li>
... ^
-:4: syntax error, unexpected end, expecting ')'
'; end
^~~
-:7: syntax error, unexpected end-of-input, expecting ')'
END
errmsgs << <<'END'
7: syntax error, unexpected end-of-input, expecting end
END
elsif rubinius?
errmsgs << <<'END'
Expand Down
2 changes: 1 addition & 1 deletion test/test-users-guide.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _test
s =~ /\A\$ (.*?)\n/
command = $1
expected = $'
if ruby19?
if ruby19? || ruby20? || ruby21? || ruby22? || ruby23? || ruby24? || ruby25? || ruby26?
case @name
when 'test_main_program1_result'
expected.sub!('["eruby", "items", "x", "_buf"]', '[:_buf, :eruby, :items, :x]')
Expand Down
Loading