lib/core/facets/symbol/thrown.rb in facets-2.9.3 vs lib/core/facets/symbol/thrown.rb in facets-3.0.0

- old
+ new

@@ -1,18 +1,22 @@ class Symbol - # Does the block throw the symbol? - # + # Returns truew if the given block throws the symbol, otherwise false. + # Note that +throw+ inside the block must be used in one-argument form. + # + # @return [true,false] def thrown? + thrown = true catch(self) do begin yield - true + thrown = false rescue ArgumentError => err # 1.9 exception - false #msg += ", not #{err.message.split(/ /).last}" + thrown = false if err.message.index('uncaught throw') rescue NameError => err # 1.8 exception - false #msg += ", not #{err.name.inspect}" + thrown = false if err.message.index('uncaught throw') end end + thrown end end