ruby-changes:47912
From: k0kubun <ko1@a...>
Date: Tue, 26 Sep 2017 20:30:50 +0900 (JST)
Subject: [ruby-changes:47912] k0kubun:r60031 (trunk): test_erb.rb: add test cases for uncovered methods
k0kubun 2017-09-26 20:30:45 +0900 (Tue, 26 Sep 2017) New Revision: 60031 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60031 Log: test_erb.rb: add test cases for uncovered methods Modified files: trunk/test/erb/test_erb.rb Index: test/erb/test_erb.rb =================================================================== --- test/erb/test_erb.rb (revision 60030) +++ test/erb/test_erb.rb (revision 60031) @@ -86,6 +86,10 @@ class TestERBCore < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/erb/test_erb.rb#L86 @erb = ERB end + def test_version + assert_equal(String, @erb.version.class) + end + def test_core _test_core(nil) _test_core(0) @@ -221,6 +225,18 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/erb/test_erb.rb#L225 assert_equal("line\r\n" * 3, erb.result) end + def test_run + out = StringIO.new + orig, $stdout = $stdout, out + + num = 3 + @erb.new('<%= num * 3 %>').run(binding) + + $stdout = orig + out.rewind + assert_equal('9', out.read) + end + class Foo; end def test_def_class @@ -320,6 +336,12 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/erb/test_erb.rb#L336 assert_match(/\Atest fname:1\b/, e.backtrace[0]) end + def test_def_module + klass = Class.new + klass.include ERB.new('<%= val %>').def_module('render(val)') + assert_equal('1', klass.new.render(1)) + end + def test_escape src = <<EOS 1.<%% : <%="<%%"%> -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/