diff --git a/test/test-engines.rb b/test/test-engines.rb
index 8f0705a..a183231 100644
--- a/test/test-engines.rb
+++ b/test/test-engines.rb
@@ -71,7 +71,8 @@ def _test()
- name: ruby2_options
lang: ruby
class: Eruby
- options: { :bufvar: '@_out_buf' }
+ options:
+ :bufvar: '@_out_buf'
input: |
<% for item in @items %>
@@ -137,7 +138,9 @@ def _test()
- name: c1
lang: c
class: Ec
- options: { :filename: foo.html, :indent: ' ' }
+ options:
+ :filename: foo.html
+ :indent: ' '
input: |4
@@ -167,7 +170,9 @@ def _test()
- name: cpp1
lang: cpp
class: Ecpp
- options: { :filename: foo.html, :indent: ' ' }
+ options:
+ :filename: foo.html
+ :indent: ' '
input: |4
@@ -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: |
@@ -220,19 +228,19 @@ def _test()
expected: |4
StringBuilder _buf = new StringBuilder(); _buf.append("\n"
+ " \n");
-
+
int i = 0;
for (Iterator it = list.iterator(); it.hasNext(); ) {
String s = (String)it.next();
i++;
-
+
_buf.append(" \n"
+ " "); _buf.append(i); _buf.append(" | \n"
+ " "); _buf.append(escape(s)); _buf.append(" | \n"
+ "
\n");
-
+
}
-
+
_buf.append(" \n"
+ "
\n");
System.err.println("*** debug: i="+(i)); _buf.append("\n");
@@ -242,7 +250,7 @@ def _test()
lang: scheme
class: Escheme
options:
- input: &scheme1_input|
+ input: &scheme1_input |
<% (let ((i 0)) %>
@@ -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))
@@ -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 = [];
diff --git a/test/test-enhancers.rb b/test/test-enhancers.rb
index 3b46721..0ad9f65 100644
--- a/test/test-enhancers.rb
+++ b/test/test-enhancers.rb
@@ -106,13 +106,13 @@ def _test()
##
- name: basic1
class: Eruby
- input: &basic1_input|
+ input: &basic1_input |
<% for item in list %>
- <%= item %>
<% end %>
- src: &basic1_src|
+ src: &basic1_src |
_buf = ''; _buf << '
'; for item in list
_buf << ' - '; _buf << ( item ).to_s; _buf << '
@@ -120,7 +120,7 @@ def _test()
_buf << '
';
_buf.to_s
- output: &basic1_output|
+ output: &basic1_output |
- b&b
@@ -193,7 +193,7 @@ def _test()
##
- name: printenabled1
class: PrintEnabledEruby
- input: &printenabled1_input|
+ input: &printenabled1_input |
<% for item in list %>
- <% print item %>
@@ -425,7 +425,8 @@ def _test()
##
- name: bipattern2
class: BiPatternEruby
- options: { :bipattern: '\$\{ \}' }
+ options:
+ :bipattern: '\$\{ \}'
input: |
<% for item in list %>
<%=item%> % <%==item%>
@@ -500,7 +501,8 @@ def _test()
##
- name: prefixedline1
class: PrefixedLineEruby
- options: { :prefixchar: '!' }
+ options:
+ :prefixchar: '!'
input: |
! for item in list
diff --git a/test/test-erubis.rb b/test/test-erubis.rb
index ad00e5e..89e94f7 100644
--- a/test/test-erubis.rb
+++ b/test/test-erubis.rb
@@ -220,13 +220,13 @@ def test_evaluate_creates_proc
__END__
- name: basic1
- input: &basic1_input|
+ input: &basic1_input |
<% for item in list %>
- <%= item %>
<% end %>
- src: &basic1_src|
+ src: &basic1_src |
_buf = ''; _buf << '
'; for item in list
_buf << ' - '; _buf << ( item ).to_s; _buf << '
@@ -234,7 +234,7 @@ def test_evaluate_creates_proc
_buf << '
';
_buf.to_s
- output: &basic1_output|
+ output: &basic1_output |
- b&b
@@ -344,7 +344,7 @@ def test_evaluate_creates_proc
- name: quotation1
desc: single quotation and backslash
class: Eruby
- input: "ation1_input|
+ input: "ation1_input |
a = "'"
b = "\""
c = '\''
@@ -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 << '
@@ -496,7 +498,7 @@ def test_evaluate_creates_proc
##
- name: nomatch1
desc: bug
- input: &nomatch1|
+ input: &nomatch1 |
@@ -510,7 +512,8 @@ def test_evaluate_creates_proc
##
- name: escape1
- options: { :escape: true }
+ options:
+ :escape: true
input: |
<% str = '<>&"' %>
<%= str %>
@@ -570,7 +573,7 @@ def test_evaluate_creates_proc
##
- name: optimized1
class: OptimizedEruby
- input: &optimized1_input|
+ input: &optimized1_input |
<% for item in list %>
@@ -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 = '\''
@@ -751,14 +754,14 @@ def test_evaluate_creates_proc
- name: pi1
class: PI::Eruby
testopt: evaluate
- input: &input_pi1|
+ input: &input_pi1 |
- @{item}@ / @!{item}@
- <%= item %> / <%== item %>
- src: &src_pi1|
+ src: &src_pi1 |
_buf = ''; _buf << '
'; for item in @list
_buf << ' - '; _buf << Erubis::XmlHelper.escape_xml(item); _buf << ' / '; _buf << (item).to_s; _buf << '
@@ -767,7 +770,7 @@ def test_evaluate_creates_proc
_buf << '
';
_buf.to_s
- output: &output_pi1|
+ output: &output_pi1 |
- <aaa> /
- / <aaa>
@@ -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: |
@@ -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: |
diff --git a/test/test-main.rb b/test/test-main.rb
index 0e63229..212882d 100644
--- a/test/test-main.rb
+++ b/test/test-main.rb
@@ -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)
@@ -272,6 +272,49 @@ 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 << ' - '; _buf << ( item[:name]] ).to_s; _buf << '
+ ^
+-: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 ')'
+ - '; _buf << ( item[:name]] ).to_s; _buf << '
+ ^
+-: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 ')'
+... - '; _buf << ( item[:name]] ).to_s; _buf << '
+... ^
+-: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 rubinius?
errmsgs << <<'END'
diff --git a/test/test-users-guide.rb b/test/test-users-guide.rb
index 2687a83..c1c52af 100644
--- a/test/test-users-guide.rb
+++ b/test/test-users-guide.rb
@@ -28,7 +28,7 @@ def _test
s =~ /\A\$ (.*?)\n/
command = $1
expected = $'
- if ruby19?
+ if ruby19? || ruby20? || ruby21? || ruby22? || ruby23? || ruby24? || ruby25?
case @name
when 'test_main_program1_result'
expected.sub!('["eruby", "items", "x", "_buf"]', '[:_buf, :eruby, :items, :x]')
diff --git a/test/testutil.rb b/test/testutil.rb
index e5293a5..1005d31 100644
--- a/test/testutil.rb
+++ b/test/testutil.rb
@@ -17,6 +17,30 @@ def ruby19? # :nodoc:
RUBY_VERSION =~ /\A1.9/
end
+def ruby20? # :nodoc:
+ RUBY_VERSION =~ /\A2.0/
+end
+
+def ruby21? # :nodoc:
+ RUBY_VERSION =~ /\A2.1/
+end
+
+def ruby22? # :nodoc:
+ RUBY_VERSION =~ /\A2.2/
+end
+
+def ruby23? # :nodoc:
+ RUBY_VERSION =~ /\A2.3/
+end
+
+def ruby24? # :nodoc:
+ RUBY_VERSION =~ /\A2.4/
+end
+
+def ruby25? # :nodoc:
+ RUBY_VERSION =~ /\A2.5/
+end
+
def rubinius? # :nodoc:
defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
end
@@ -37,7 +61,7 @@ def self.load_yaml_datafile(filename, options={}, &block) # :nodoc:
s = _untabify(s) unless options[:tabify] == false
# load yaml document
testdata_list = []
- YAML.load_documents(s) do |ydoc|
+ YAML.load_stream(s) do |ydoc|
if ydoc.is_a?(Hash)
testdata_list << ydoc
elsif ydoc.is_a?(Array)