From 3895e300743be093c017dbd5569b946a549ce84b Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 29 Aug 2017 07:11:52 +0000 Subject: test/ruby: tweaked heredocs git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_alias.rb | 8 +++++--- test/ruby/test_argf.rb | 3 ++- test/ruby/test_array.rb | 21 ++++++++++++++------- test/ruby/test_beginendblock.rb | 32 +++++++++++++++++++------------- test/ruby/test_class.rb | 16 ++++++++++------ test/ruby/test_encoding.rb | 5 +++-- 6 files changed, 53 insertions(+), 32 deletions(-) diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index 3fc1bb4000..e81636fa43 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -122,7 +122,8 @@ class TestAlias < Test::Unit::TestCase 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 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 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 diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb index d6aa8f7295..5ab2cdc07d 100644 --- a/test/ruby/test_argf.rb +++ b/test/ruby/test_argf.rb @@ -934,7 +934,8 @@ class TestArgf < Test::Unit::TestCase 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} diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index d1a570099f..5bd4517f2e 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1899,8 +1899,10 @@ class TestArray < Test::Unit::TestCase 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 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 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 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; diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb index a09c963b3c..9238a53354 100644 --- a/test/ruby/test_beginendblock.rb +++ b/test/ruby/test_beginendblock.rb @@ -31,7 +31,8 @@ class TestBeginEndBlock < Test::Unit::TestCase 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::TestCase 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::TestCase 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::TestCase 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::TestCase "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::TestCase def test_callcc_at_exit bug9110 = '[ruby-core:58329][Bug #9110]' - script = <