forked from jruby/jruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_method_override_and_caching.rb
54 lines (44 loc) · 1.17 KB
/
test_method_override_and_caching.rb
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require 'test/unit'
# JRUBY-2921
class TestMethodOverrideAndCaching < Test::Unit::TestCase
def calling_meth1
MySub.meth1
end
def calling_meth2
MySub.meth2
end
class MySuper
def self.meth1
'MySuper::meth1'
end
def self.meth2
'MySuper::meth2'
end
end
class MySub < MySuper
end
def test_jruby_2921
assert_equal 1, MySub.methods.select {|m| m == 'meth1'}.size
assert_equal 1, MySub.methods.select {|m| m == 'meth2'}.size
assert_equal('MySuper::meth1', MySub::meth1)
assert_equal('MySuper::meth1', calling_meth1)
assert_equal('MySuper::meth2', MySub::meth2)
# Note: calling_meth2 is not called here
self.class.class_eval "
class MySub
def self.meth1
'MySub::meth1'
end
def self.meth2
'MySub::meth2'
end
end
"
assert_equal 1, MySub.methods.select {|m| m == 'meth1'}.size
assert_equal 1, MySub.methods.select {|m| m == 'meth2'}.size
assert_equal('MySub::meth1', MySub::meth1)
assert_equal('MySub::meth1', calling_meth1)
assert_equal('MySub::meth2', MySub::meth2)
assert_equal('MySub::meth2', calling_meth2)
end
end