[前][次][番号順一覧][スレッド一覧]

ruby-changes:5249

From: knu <ko1@a...>
Date: Mon, 2 Jun 2008 15:58:27 +0900 (JST)
Subject: [ruby-changes:5249] Ruby:r16748 (ruby_1_8): * lib/erb.rb (ERB::Compiler::TrimScanner#scan_line): Fix a bug

knu	2008-06-02 15:58:05 +0900 (Mon, 02 Jun 2008)

  New Revision: 16748

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/lib/erb.rb
    branches/ruby_1_8/test/erb/test_erb.rb

  Log:
    * 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().


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?r1=16748&r2=16747&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/lib/erb.rb?r1=16748&r2=16747&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/test/erb/test_erb.rb?r1=16748&r2=16747&diff_format=u

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 16747)
+++ ruby_1_8/ChangeLog	(revision 16748)
@@ -1,3 +1,12 @@
+Mon Jun  2 15:56:36 2008  Akinori MUSHA  <knu@i...>
+
+	* 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:20:23 2008  NAKAMURA Usaku  <usa@r...>
 
 	* mkconfig.rb: hide build path from rbconfig.rb.
Index: ruby_1_8/lib/erb.rb
===================================================================
--- ruby_1_8/lib/erb.rb	(revision 16747)
+++ ruby_1_8/lib/erb.rb	(revision 16748)
@@ -327,16 +327,18 @@
       end
 
       def scan_line(line)
-        line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |token|
-	  next if token.empty?
-	  yield(token)
+        line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>|\n|\z)/m) do |tokens|
+          tokens.each do |token|
+            next if token.empty?
+            yield(token)
+          end
 	end
       end
 
       def trim_line1(line)
         line.scan(/(.*?)(<%%|%%>|<%=|<%#|<%|%>\n|%>|\n|\z)/m) do |tokens|
           tokens.each do |token|
-	  next if token.empty?
+            next if token.empty?
             if token == "%>\n"
               yield('%>')
               yield(:cr)
Index: ruby_1_8/test/erb/test_erb.rb
===================================================================
--- ruby_1_8/test/erb/test_erb.rb	(revision 16747)
+++ ruby_1_8/test/erb/test_erb.rb	(revision 16748)
@@ -54,16 +54,16 @@
 
   def _test_01(safe)
     erb = @erb.new("hello")
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     erb = @erb.new("hello", safe, 0)
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     erb = @erb.new("hello", safe, 1)
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     erb = @erb.new("hello", safe, 2)
-    assert_equal(erb.result, "hello")
+    assert_equal("hello", erb.result)
 
     src = <<EOS
 %% hi
@@ -159,7 +159,7 @@
 
   def test_02_safe_04
     erb = @erb.new('<%=$SAFE%>', 4)
-    assert_equal(erb.result(TOPLEVEL_BINDING.taint), '4')
+    assert_equal('4', erb.result(TOPLEVEL_BINDING.taint))
   end
 
   class Foo; end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]