diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-29 07:11:52 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-08-29 07:11:52 +0000 |
commit | 3895e300743be093c017dbd5569b946a549ce84b (patch) | |
tree | 27da35c9fab876220c7c05848568af9b0649d486 /test | |
parent | 480c84e1afbe54d4b63da64d26fab2d39819557a (diff) | |
download | ruby-3895e300743be093c017dbd5569b946a549ce84b.tar.gz |
test/ruby: tweaked heredocs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_alias.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_argf.rb | 3 | ||||
-rw-r--r-- | test/ruby/test_array.rb | 21 | ||||
-rw-r--r-- | test/ruby/test_beginendblock.rb | 32 | ||||
-rw-r--r-- | test/ruby/test_class.rb | 16 | ||||
-rw-r--r-- | 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 = <<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 diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 072729d4e5..5250d4b44a 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -297,7 +297,8 @@ class TestClass < Test::Unit::TestCase 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 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 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 diff --git a/test/ruby/test_encoding.rb b/test/ruby/test_encoding.rb index 06559651c5..8f73a8fce1 100644 --- a/test/ruby/test_encoding.rb +++ b/test/ruby/test_encoding.rb @@ -117,9 +117,10 @@ class TestEncoding < Test::Unit::TestCase 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; |