HEX
Server: Apache
System: Linux s198.coreserver.jp 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025 x86_64
User: nagasaki (10062)
PHP: 7.1.33
Disabled: NONE
Upload Files
File: //usr/local/rvm/src/ruby-2.6.8/spec/mspec/lib/mspec/matchers/block_caller.rb
class BlockingMatcher
  def matches?(block)
    t = Thread.new do
      block.call
    end

    loop do
      case t.status
      when "sleep"    # blocked
        t.kill
        t.join
        return true
      when false      # terminated normally, so never blocked
        t.join
        return false
      when nil        # terminated exceptionally
        t.value
      else
        Thread.pass
      end
    end
  end

  def failure_message
    ['Expected the given Proc', 'to block the caller']
  end

  def negative_failure_message
    ['Expected the given Proc', 'to not block the caller']
  end
end

module MSpecMatchers
  private def block_caller
    BlockingMatcher.new
  end
end