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

ruby-changes:47566

From: nobu <ko1@a...>
Date: Tue, 29 Aug 2017 16:11:57 +0900 (JST)
Subject: [ruby-changes:47566] nobu:r59682 (trunk): test/ruby: tweaked heredocs

nobu	2017-08-29 16:11:52 +0900 (Tue, 29 Aug 2017)

  New Revision: 59682

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

  Log:
    test/ruby: tweaked heredocs

  Modified files:
    trunk/test/ruby/test_alias.rb
    trunk/test/ruby/test_argf.rb
    trunk/test/ruby/test_array.rb
    trunk/test/ruby/test_beginendblock.rb
    trunk/test/ruby/test_class.rb
    trunk/test/ruby/test_encoding.rb
Index: test/ruby/test_argf.rb
===================================================================
--- test/ruby/test_argf.rb	(revision 59681)
+++ test/ruby/test_argf.rb	(revision 59682)
@@ -934,7 +934,8 @@ class TestArgf < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_argf.rb#L934
   end
 
   def test_wrong_type
-    assert_separately([], <<-'end;')
+    assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
+    begin;
       bug11610 = '[ruby-core:71140] [Bug #11610]'
       ARGV[0] = nil
       assert_raise(TypeError, bug11610) {gets}
Index: test/ruby/test_class.rb
===================================================================
--- test/ruby/test_class.rb	(revision 59681)
+++ test/ruby/test_class.rb	(revision 59682)
@@ -297,7 +297,8 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L297
   end
 
   def test_cannot_reinitialize_class_with_initialize_copy # [ruby-core:50869]
-    assert_in_out_err([], <<-'end;', ["Object"], [])
+    assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", ["Object"], [])
+    begin;
       class Class
         def initialize_copy(*); super; end
       end
@@ -579,7 +580,8 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L580
       m.module_eval "class #{n}; end"
     }
 
-    assert_separately([], <<-"end;")
+    assert_separately([], "#{<<~"begin;"}\n#{<<~"end;"}")
+    begin;
       Date = (class C\u{1f5ff}; self; end).new
       assert_raise_with_message(TypeError, /C\u{1f5ff}/) {
         require 'date'
@@ -588,22 +590,24 @@ class TestClass < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_class.rb#L590
   end
 
   def test_should_not_expose_singleton_class_without_metaclass
-    assert_normal_exit %q{
+    assert_normal_exit "#{<<~"begin;"}\n#{<<~'end;'}", '[Bug #11740]'
+    begin;
       klass = Class.new(Array)
       # The metaclass of +klass+ should handle #bla since it should inherit methods from meta:meta:Array
       def (Array.singleton_class).bla; :bla; end
       hidden = ObjectSpace.each_object(Class).find { |c| klass.is_a? c and c.inspect.include? klass.inspect }
       raise unless hidden.nil?
-    }, '[Bug #11740]'
+    end;
 
-    assert_normal_exit %q{
+    assert_normal_exit "#{<<~"begin;"}\n#{<<~'end;'}", '[Bug #11740]'
+    begin;
       klass = Class.new(Array)
       klass.singleton_class
       # The metaclass of +klass+ should handle #bla since it should inherit methods from meta:meta:Array
       def (Array.singleton_class).bla; :bla; end
       hidden = ObjectSpace.each_object(Class).find { |c| klass.is_a? c and c.inspect.include? klass.inspect }
       raise if hidden.nil?
-    }, '[Bug #11740]'
+    end;
 
   end
 end
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 59681)
+++ test/ruby/test_array.rb	(revision 59682)
@@ -1899,8 +1899,10 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L1899
 
   def test_permutation_stack_error
     bug9932 = '[ruby-core:63103] [Bug #9932]'
-    assert_separately([], <<-"end;", timeout: 30) #    do
-      assert_nothing_raised(SystemStackError, "#{bug9932}") do
+    assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 30)
+    bug = "#{bug9932}"
+    begin;
+      assert_nothing_raised(SystemStackError, bug) do
         assert_equal(:ok, Array.new(100_000, nil).permutation {break :ok})
       end
     end;
@@ -1932,7 +1934,8 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L1934
   end
 
   def test_repeated_permutation_stack_error
-    assert_separately([], <<-"end;", timeout: 30) #    do
+    assert_separately([], "#{<<-"begin;"}\n#{<<~'end;'}", timeout: 30)
+    begin;
       assert_nothing_raised(SystemStackError) do
         assert_equal(:ok, Array.new(100_000, nil).repeated_permutation(500_000) {break :ok})
       end
@@ -1969,7 +1972,8 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L1972
   end
 
   def test_repeated_combination_stack_error
-    assert_separately([], <<-"end;", timeout: 20) #    do
+    assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 20)
+    begin;
       assert_nothing_raised(SystemStackError) do
         assert_equal(:ok, Array.new(100_000, nil).repeated_combination(500_000) {break :ok})
       end
@@ -2752,21 +2756,24 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2756
     Bug11235 = '[ruby-dev:49043] [Bug #11235]'
 
     def test_push_over_ary_max
-      assert_separately(['-', ARY_MAX.to_s, Bug11235], <<-"end;", timeout: 30)
+      assert_separately(['-', ARY_MAX.to_s, Bug11235], "#{<<~"begin;"}\n#{<<~'end;'}", timeout: 30)
+      begin;
         a = Array.new(ARGV[0].to_i)
         assert_raise(IndexError, ARGV[1]) {0x1000.times {a.push(1)}}
       end;
     end
 
     def test_unshift_over_ary_max
-      assert_separately(['-', ARY_MAX.to_s, Bug11235], <<-"end;")
+      assert_separately(['-', ARY_MAX.to_s, Bug11235], "#{<<~"begin;"}\n#{<<~'end;'}")
+      begin;
         a = Array.new(ARGV[0].to_i)
         assert_raise(IndexError, ARGV[1]) {0x1000.times {a.unshift(1)}}
       end;
     end
 
     def test_splice_over_ary_max
-      assert_separately(['-', ARY_MAX.to_s, Bug11235], <<-"end;")
+      assert_separately(['-', ARY_MAX.to_s, Bug11235], "#{<<~"begin;"}\n#{<<~'end;'}")
+      begin;
         a = Array.new(ARGV[0].to_i)
         assert_raise(IndexError, ARGV[1]) {a[0, 0] = Array.new(0x1000)}
       end;
Index: test/ruby/test_beginendblock.rb
===================================================================
--- test/ruby/test_beginendblock.rb	(revision 59681)
+++ test/ruby/test_beginendblock.rb	(revision 59682)
@@ -31,7 +31,8 @@ class TestBeginEndBlock < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_beginendblock.rb#L31
   end
 
   def test_endblockwarn
-    assert_in_out_err([], <<-'end;', [], ['-:2: warning: END in method; use at_exit'])
+    assert_in_out_err([], "#{<<~"begin;"}#{<<~'end;'}", [], ['-:2: warning: END in method; use at_exit'])
+    begin;
       def end1
         END {}
       end
@@ -39,7 +40,8 @@ class TestBeginEndBlock < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_beginendblock.rb#L40
   end
 
   def test_endblockwarn_in_eval
-    assert_in_out_err([], <<-'end;', [], ['(eval):2: warning: END in method; use at_exit'])
+    assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", [], ['(eval):2: warning: END in method; use at_exit'])
+    begin;
       eval <<-EOE
         def end2
           END {}
@@ -72,7 +74,8 @@ class TestBeginEndBlock < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_beginendblock.rb#L74
   end
 
   def test_propagate_signaled
-    status = assert_in_out_err([], <<-'end;', [], /Interrupt$/)
+    status = assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", [], /Interrupt$/)
+    begin;
       trap(:INT, "DEFAULT")
       at_exit{Process.kill(:INT, $$)}
     end;
@@ -82,7 +85,8 @@ class TestBeginEndBlock < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_beginendblock.rb#L85
   end
 
   def test_endblock_raise
-    assert_in_out_err([], <<-'end;', %w(e6 e4 e2), [:*, /e5/, :*, /e3/, :*, /e1/, :*])
+    assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", %w(e6 e4 e2), [:*, /e5/, :*, /e3/, :*, /e1/, :*])
+    begin;
       END {raise "e1"}; END {puts "e2"}
       END {raise "e3"}; END {puts "e4"}
       END {raise "e5"}; END {puts "e6"}
@@ -99,7 +103,8 @@ class TestBeginEndBlock < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_beginendblock.rb#L103
                  "inner1",
                  "outer0" ]
 
-    assert_in_out_err([], <<-'end;', expected, [], "[ruby-core:35237]")
+    assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", expected, [], "[ruby-core:35237]")
+    begin;
       at_exit { puts :outer0 }
       at_exit { puts :outer1_begin; at_exit { puts :inner1 }; puts :outer1_end }
       at_exit { puts :outer2_begin; at_exit { puts :inner2 }; puts :outer2_end }
@@ -122,18 +127,19 @@ class TestBeginEndBlock < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/ruby/test_beginendblock.rb#L127
 
   def test_callcc_at_exit
     bug9110 = '[ruby-core:58329][Bug #9110]'
-    script = <<EOS
-require "continuation"
-c = nil
-at_exit { c.call }
-at_exit { callcc {|_c| c = _c } }
-EOS
-    assert_normal_exit(script, bug9110)
+    assert_ruby_status([], "#{<<~"begin;"}\n#{<<~'end;'}", bug9110)
+    begin;
+      require "continuation"
+      c = nil
+      at_exit { c.call }
+      at_exit { callcc {|_c| c = _c } }
+    end;
   end
 
   def test_errinfo_at_exit
     bug12302 = '[ruby-core:75038] [Bug #12302]'
-    assert_in_out_err([], <<-'end;', %w[2:exit 1:exit], [], bug12302)
+    assert_in_out_err([], "#{<<~"begin;"}\n#{<<~'end;'}", %w[2:exit 1:exit], [], bug12302)
+    begin;
       at_exit do
         puts "1:#{$!}"
       end
Index: test/ruby/test_encoding.rb
===================================================================
--- test/ruby/test_encoding.rb	(revision 59681)
+++ test/ruby/test_encoding.rb	(revision 59682)
@@ -117,9 +117,10 @@ class TestEncoding < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_encoding.rb#L117
   end
 
   def test_errinfo_after_autoload
+    assert_separately(%w[--disable=gems], "#{<<~"begin;"}\n#{<<~'end;'}")
     bug9038 = '[ruby-core:57949] [Bug #9038]'
-    assert_separately(%w[--disable=gems], <<-"end;")
-      assert_raise_with_message(SyntaxError, /unknown regexp option - Q/, #{bug9038.dump}) {
+    begin;
+      assert_raise_with_message(SyntaxError, /unknown regexp option - Q/, bug9038) {
         eval("/regexp/sQ")
       }
     end;
Index: test/ruby/test_alias.rb
===================================================================
--- test/ruby/test_alias.rb	(revision 59681)
+++ test/ruby/test_alias.rb	(revision 59682)
@@ -122,7 +122,8 @@ class TestAlias < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_alias.rb#L122
   end
 
   def test_alias_wb_miss
-    assert_normal_exit %q{
+    assert_normal_exit "#{<<-"begin;"}\n#{<<-'end;'}"
+    begin;
       require 'stringio'
       GC.verify_internal_consistency
       GC.start
@@ -130,7 +131,7 @@ class TestAlias < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_alias.rb#L131
         alias_method :read_nonblock, :sysread
       end
       GC.verify_internal_consistency
-    }
+    end;
   end
 
   def test_cyclic_zsuper
@@ -183,7 +184,8 @@ class TestAlias < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_alias.rb#L184
   def test_alias_in_module
     bug9663 = '[ruby-core:61635] [Bug #9663]'
 
-    assert_separately(['-', bug9663], <<-'end;')
+    assert_separately(['-', bug9663], "#{<<-"begin;"}\n#{<<-'end;'}")
+    begin;
       bug = ARGV[0]
 
       m = Module.new do

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

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