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
2021-07-10 19:14:40 +09:00

28 lines
543 B
Ruby

# frozen_string_literal: true
begin
require_relative 'helper'
rescue LoadError
return
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