Unverified Commit d3fbac4d authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #5335 from shuujii/add-UncaughtThrowError-tagvalue-for-Ruby-compatibility

Add `UncaughtThrowError#{tag,value}` for Ruby compatibility
parents 5f71e0e7 955464ca
class UncaughtThrowError < ArgumentError class UncaughtThrowError < ArgumentError
attr_reader :_tag, :_val attr_reader :tag, :value
def initialize(tag, val) def initialize(tag, value)
@_tag = tag @tag = tag
@_val = val @value = value
super("uncaught throw #{tag.inspect}") super("uncaught throw #{tag.inspect}")
end end
end end
...@@ -3,10 +3,14 @@ assert "return throw value" do ...@@ -3,10 +3,14 @@ assert "return throw value" do
result = catch :foo do result = catch :foo do
loop do loop do
loop do loop do
begin
throw :foo, val throw :foo, val
rescue Exception
flunk("should not reach here 1")
end
break break
end end
flunk("should not reach here") flunk("should not reach here 2")
end end
false false
end end
...@@ -30,13 +34,16 @@ assert "pass the given tag to block" do ...@@ -30,13 +34,16 @@ assert "pass the given tag to block" do
catch(tag){|t| assert_same(tag, t)} catch(tag){|t| assert_same(tag, t)}
end end
assert "tag identity" do assert "tag identity, uncaught throw" do
assert_raise_with_message_pattern(Exception, "uncaught throw *") do tag, val = [:tag], [:val]
catch [:tag] do catch [:tag] do
throw [:tag] throw tag, val
end end
flunk("should not reach here") flunk("should not reach here")
end rescue Exception => e
assert_match("uncaught throw *", e.message)
assert_same(tag, e.tag)
assert_same(val, e.value)
end end
assert "without catch arguments" do assert "without catch arguments" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment