From 646c53895f80358d153d04f04b726d0d14388cf2 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 9 Sep 2016 08:59:48 +0000 Subject: thread.c: set cause by Thread#raise * thread.c (rb_threadptr_raise): set cause from the called thread, but not from the thread to be interrupted. [ruby-core:77222] [Bug #12741] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_exception.rb | 46 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'test') diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 5023262e5d..03c0c819f5 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -698,6 +698,52 @@ end.join assert_nil(e.cause.cause) end + def test_cause_thread_no_cause + bug12741 = '[ruby-core:77222] [Bug #12741]' + + x = Thread.current + a = false + y = Thread.start do + Thread.pass until a + x.raise "stop" + end + + begin + raise bug12741 + rescue + e = assert_raise_with_message(RuntimeError, "stop") do + a = true + sleep 1 + end + end + assert_nil(e.cause) + end + + def test_cause_thread_with_cause + bug12741 = '[ruby-core:77222] [Bug #12741]' + + x = Thread.current + a = false + y = Thread.start do + Thread.pass until a + begin + raise "caller's cause" + rescue + x.raise "stop" + end + end + + begin + raise bug12741 + rescue + e = assert_raise_with_message(RuntimeError, "stop") do + a = true + sleep 1 + end + end + assert_equal("caller's cause", e.cause.message) + end + def test_unknown_option bug = '[ruby-core:63203] [Feature #8257] should pass unknown options' -- cgit v1.2.3 From 7f6410f02d3092075b9990705d0151ffb44f51a1 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 9 Sep 2016 09:27:38 +0000 Subject: json_generator_test.rb: no Bignum * test/json/json_generator_test.rb (test_broken_bignum): get rid of use of Bignum, obsolete name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/json/json_generator_test.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) mode change 100644 => 100755 test/json/json_generator_test.rb (limited to 'test') diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb old mode 100644 new mode 100755 index 18b08337f8..86be398f46 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -277,12 +277,13 @@ EOT if defined?(JSON::Ext::Generator) def test_broken_bignum # [ruby-core:38867] pid = fork do - Bignum.class_eval do + x = 1 << 64 + x.class.class_eval do def to_s end end begin - JSON::Ext::Generator::State.new.generate(1<<64) + JSON::Ext::Generator::State.new.generate(x) exit 1 rescue TypeError exit 0 -- cgit v1.2.3