blob: f0c876b70f777196858f5b97d19325d615059c0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# frozen_string_literal: true
require 'test/unit'
class TestMicroJIT < Test::Unit::TestCase
# MicroJIT's code invalidation mechanism can't invalidate
# code that is executing. Test that we don't try to do that.
def test_code_invalidation
klass = Class.new do
def alias_then_hash(klass, method_to_redefine)
klass.alias_method(method_to_redefine, :itself)
hash
end
end
instance = klass.new
i = 0
while i < 12
if i < 11
instance.alias_then_hash(klass, :bar)
else
ret = instance.alias_then_hash(klass, :hash)
assert(instance.equal?(ret))
end
i += 1
end
end
end
|