mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/erb.rb (ERB::Compiler::TrimScanner#scan_line): Fix a bug
where tokens are not yilelded one by one. * test/erb/test_erb.rb (TestERBCore#_test_01) (TestERBCore#test_02_safe_04): The expected value should come first for assert_equal(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
edcbe2ac45
commit
92623d3db8
3 changed files with 20 additions and 9 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Mon Jun 2 16:08:24 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* lib/erb.rb (ERB::Compiler::TrimScanner#scan_line): Fix a bug
|
||||||
|
where tokens are not yilelded one by one.
|
||||||
|
|
||||||
|
* test/erb/test_erb.rb (TestERBCore#_test_01)
|
||||||
|
(TestERBCore#test_02_safe_04): The expected value should come
|
||||||
|
first for assert_equal().
|
||||||
|
|
||||||
Mon Jun 2 13:06:38 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
Mon Jun 2 13:06:38 2008 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* mkconfig.rb: hide build path from rbconfig.rb.
|
* mkconfig.rb: hide build path from rbconfig.rb.
|
||||||
|
|
10
lib/erb.rb
10
lib/erb.rb
|
@ -329,15 +329,17 @@ class ERB
|
||||||
end
|
end
|
||||||
|
|
||||||
def scan_line(line)
|
def scan_line(line)
|
||||||
line.split(SplitRegexp).each do |token|
|
line.split(SplitRegexp).each do |tokens|
|
||||||
next if token.empty?
|
tokens.each do |token|
|
||||||
yield(token)
|
next if token.empty?
|
||||||
|
yield(token)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def trim_line1(line)
|
def trim_line1(line)
|
||||||
line.split(TrimSplitRegexp).each do |token|
|
line.split(TrimSplitRegexp).each do |token|
|
||||||
next if token.empty?
|
next if token.empty?
|
||||||
if token == "%>\n"
|
if token == "%>\n"
|
||||||
yield('%>')
|
yield('%>')
|
||||||
yield(:cr)
|
yield(:cr)
|
||||||
|
|
|
@ -54,16 +54,16 @@ class TestERBCore < Test::Unit::TestCase
|
||||||
|
|
||||||
def _test_core(safe)
|
def _test_core(safe)
|
||||||
erb = @erb.new("hello")
|
erb = @erb.new("hello")
|
||||||
assert_equal(erb.result, "hello")
|
assert_equal("hello", erb.result)
|
||||||
|
|
||||||
erb = @erb.new("hello", safe, 0)
|
erb = @erb.new("hello", safe, 0)
|
||||||
assert_equal(erb.result, "hello")
|
assert_equal("hello", erb.result)
|
||||||
|
|
||||||
erb = @erb.new("hello", safe, 1)
|
erb = @erb.new("hello", safe, 1)
|
||||||
assert_equal(erb.result, "hello")
|
assert_equal("hello", erb.result)
|
||||||
|
|
||||||
erb = @erb.new("hello", safe, 2)
|
erb = @erb.new("hello", safe, 2)
|
||||||
assert_equal(erb.result, "hello")
|
assert_equal("hello", erb.result)
|
||||||
|
|
||||||
src = <<EOS
|
src = <<EOS
|
||||||
%% hi
|
%% hi
|
||||||
|
@ -159,7 +159,7 @@ EOS
|
||||||
|
|
||||||
def test_safe_04
|
def test_safe_04
|
||||||
erb = @erb.new('<%=$SAFE%>', 4)
|
erb = @erb.new('<%=$SAFE%>', 4)
|
||||||
assert_equal(erb.result(TOPLEVEL_BINDING.taint), '4')
|
assert_equal('4', erb.result(TOPLEVEL_BINDING.taint))
|
||||||
end
|
end
|
||||||
|
|
||||||
class Foo; end
|
class Foo; end
|
||||||
|
|
Loading…
Add table
Reference in a new issue