Add `UncaughtThrowError#{tag,value}` for Ruby compatibility
MODIFY
mrbgems/mruby-catch/mrblib/catch.rb
mrbgems/mruby-catch/mrblib/catch.rb
class UncaughtThrowError < ArgumentError
- attr_reader :_tag, :_val
- def initialize(tag, val)
- @_tag = tag
- @_val = val
+ attr_reader :tag, :value
+ def initialize(tag, value)
+ @tag = tag
+ @value = value
super("uncaught throw #{tag.inspect}")
end
end

MODIFY
mrbgems/mruby-catch/test/catch.rb
mrbgems/mruby-catch/test/catch.rb
@@ -3,10 +3,14 @@ assert "return throw value" do
result = catch :foo do
loop do
loop do
+ begin
throw :foo, val
+ rescue Exception
+ flunk("should not reach here 1")
+ end
break
end
- flunk("should not reach here")
+ flunk("should not reach here 2")
end
false
end
@@ -30,13 +34,16 @@ assert "pass the given tag to block" do
catch(tag){|t| assert_same(tag, t)}
end
-assert "tag identity" do
- assert_raise_with_message_pattern(Exception, "uncaught throw *") do
+assert "tag identity, uncaught throw" do
+ tag, val = [:tag], [:val]
catch [:tag] do
- throw [:tag]
+ throw tag, val
end
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
assert "without catch arguments" do

Add `UncaughtThrowError#{tag,value}` for Ruby compatibility