1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/test/fiddle/test_pinned.rb

28 lines
534 B
Ruby
Raw Normal View History

# frozen_string_literal: true
begin
require_relative 'helper'
rescue LoadError
end
module Fiddle
class TestPinned < Fiddle::TestCase
def test_pin_object
x = Object.new
pinner = Pinned.new x
assert_same x, pinner.ref
end
def test_clear
pinner = Pinned.new Object.new
refute pinner.cleared?
pinner.clear
assert pinner.cleared?
ex = assert_raise(Fiddle::ClearedReferenceError) do
pinner.ref
end
assert_match "called on", ex.message
end
end
end