blob: 21dc4081e22e612afff2d18bf3409d557681ad80 (
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
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
54
|
module ConstantSpecs
CS_SINGLETON1 = Object.new
class << CS_SINGLETON1
CONST = 1
def foo
CONST
end
end
CS_SINGLETON2 = [Object.new, Object.new]
2.times do |i|
obj = CS_SINGLETON2[i]
$spec_i = i
class << obj
CONST = ($spec_i + 1)
def foo
CONST
end
end
end
CS_SINGLETON3 = [Object.new, Object.new]
2.times do |i|
obj = CS_SINGLETON3[i]
class << obj
class X
# creates <singleton class::X>
end
def x
X
end
end
end
CS_SINGLETON4 = [Object.new, Object.new]
CS_SINGLETON4_CLASSES = []
2.times do |i|
obj = CS_SINGLETON4[i]
$spec_i = i
class << obj
class X
CS_SINGLETON4_CLASSES << self
CONST = ($spec_i + 1)
def foo
CONST
end
end
end
end
end
|