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

ruby-changes:42325

From: naruse <ko1@a...>
Date: Tue, 29 Mar 2016 21:26:16 +0900 (JST)
Subject: [ruby-changes:42325] naruse:r54399 (ruby_2_3): merge revision(s) 53541, 53555, 53570: [Backport #11990]

naruse	2016-03-29 21:26:12 +0900 (Tue, 29 Mar 2016)

  New Revision: 54399

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54399

  Log:
    merge revision(s) 53541,53555,53570: [Backport #11990]
    
    * parse.y (string1): reset heredoc indent fore each string leteral
      so that concatenated string would not be dedented.
      [ruby-core:72857] [Bug #11990]
    
    * parse.y (xstring): reset heredoc indent after dedenting,
      so that following string literal would not be dedented.
      [ruby-core:72857] [Bug #11990]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/parse.y
    branches/ruby_2_3/test/ruby/test_syntax.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/test/ruby/test_syntax.rb
===================================================================
--- ruby_2_3/test/ruby/test_syntax.rb	(revision 54398)
+++ ruby_2_3/test/ruby/test_syntax.rb	(revision 54399)
@@ -2,6 +2,14 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_syntax.rb#L2
 require 'test/unit'
 
 class TestSyntax < Test::Unit::TestCase
+  using Module.new {
+    refine(Object) do
+      def `(s) #`
+        s
+      end
+    end
+  }
+
   def assert_syntax_files(test)
     srcdir = File.expand_path("../../..", __FILE__)
     srcdir = File.join(srcdir, test)
@@ -493,10 +501,13 @@ e" https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_syntax.rb#L501
   end
 
   def assert_dedented_heredoc(expect, result, mesg = "")
-    %w[eos "eos" 'eos'].each do |eos|
-      assert_equal(eval("<<-#{eos}\n#{expect}eos\n"),
-                   eval("<<~#{eos}\n#{result}eos\n"),
-                   message(mesg) {"with #{eos}"})
+    all_assertions(mesg) do |a|
+      %w[eos "eos" 'eos' `eos`].each do |eos|
+        a.for(eos) do
+          assert_equal(eval("<<-#{eos}\n#{expect}eos\n"),
+                       eval("<<~#{eos}\n#{result}eos\n"))
+        end
+      end
     end
   end
 
@@ -580,6 +591,19 @@ e" https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_syntax.rb#L591
     assert_dedented_heredoc(expect, result)
   end
 
+  def test_dedented_heredoc_with_concatenation
+    bug11990 = '[ruby-core:72857] [Bug #11990] concatenated string should not be dedented'
+    %w[eos "eos" 'eos'].each do |eos|
+      assert_equal("x\n  y",
+                   eval("<<~#{eos} '  y'\n  x\neos\n"),
+                   "#{bug11990} with #{eos}")
+    end
+    %w[eos "eos" 'eos' `eos`].each do |eos|
+      _, expect = eval("[<<~#{eos}, '  x']\n""  y\n""eos\n")
+      assert_equal('  x', expect, bug11990)
+    end
+  end
+
   def test_lineno_after_heredoc
     bug7559 = '[ruby-dev:46737]'
     expected, _, actual = __LINE__, <<eom, __LINE__
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 54398)
+++ ruby_2_3/ChangeLog	(revision 54399)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Tue Mar 29 21:22:22 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (xstring): reset heredoc indent after dedenting,
+	  so that following string literal would not be dedented.
+	  [ruby-core:72857] [Bug #11990]
+
+Tue Mar 29 21:22:22 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (string1): reset heredoc indent fore each string leteral
+	  so that concatenated string would not be dedented.
+	  [ruby-core:72857] [Bug #11990]
+
 Tue Mar 29 21:18:09 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (parser_here_document): update indent for each line in
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 54398)
+++ ruby_2_3/version.h	(revision 54399)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.0"
 #define RUBY_RELEASE_DATE "2016-03-29"
-#define RUBY_PATCHLEVEL 48
+#define RUBY_PATCHLEVEL 49
 
 #define RUBY_RELEASE_YEAR 2016
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_3/parse.y
===================================================================
--- ruby_2_3/parse.y	(revision 54398)
+++ ruby_2_3/parse.y	(revision 54399)
@@ -3907,7 +3907,6 @@ strings		: string https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L3907
 			else {
 			    node = evstr2dstr(node);
 			}
-			heredoc_indent = 0;
 			$$ = node;
 		    /*%
 			$$ = $1;
@@ -3930,6 +3929,7 @@ string		: tCHAR https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L3929
 string1		: tSTRING_BEG string_contents tSTRING_END
 		    {
 			heredoc_dedent($2);
+			heredoc_indent = 0;
 		    /*%%%*/
 			$$ = $2;
 		    /*%
@@ -3945,6 +3945,7 @@ xstring		: tXSTRING_BEG xstring_contents https://github.com/ruby/ruby/blob/trunk/ruby_2_3/parse.y#L3945
 		    /*%
 		    %*/
 			heredoc_dedent($2);
+			heredoc_indent = 0;
 		    /*%%%*/
 			if (!node) {
 			    node = NEW_XSTR(STR_NEW0());

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r53541,53555,53570


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

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