public void ConstantCaching_Unqualified6() {
TestOutput(@"
X = [1] # assign a non-primitive value so that the cache needs to use a WeakRef
class C
$C = self
def self.foo
X # tested cache
end
end
p $C.foo, $C.foo # test twice - 1) Op-call returns the value 2) the cache returns the value
module M
$M = self
X = 1 # assign primitive value
end
class C
include $M # changes cached value from non-primitive (weak ref) to primitive (strong ref)
end
p $C.foo, $C.foo
", @"
[1]
[1]
1
1
");
}