Newer
Older
Ary Borenszweig
committed
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
require "../../spec_helper"
describe "Code gen: enum" do
it "codegens enum" do
run(%(
enum Foo
A = 1
end
Foo::A
)).to_i.should eq(1)
end
it "codegens enum without explicit value" do
run(%(
enum Foo
A
B
C
end
Foo::C
)).to_i.should eq(2)
end
it "codegens enum value" do
run(%(
enum Foo
A = 1
end
Foo::A.value
)).to_i.should eq(1)
end
it "creates enum from value" do
run(%(
enum Foo
A
B
end
Foo.new(1).value
)).to_i.should eq(1)
end
it "codegens enum bitflags (1)" do
run(%(
@[Flags]
enum Foo
A
end
Foo::A
)).to_i.should eq(1)
end
it "codegens enum bitflags (2)" do
run(%(
@[Flags]
enum Foo
A
B
end
Foo::B
)).to_i.should eq(2)
end
it "codegens enum bitflags (4)" do
run(%(
@[Flags]
enum Foo
A
B
C
end
Foo::C
)).to_i.should eq(4)
end
it "codegens enum bitflags None" do
run(%(
@[Flags]
enum Foo
A
end
Foo::None
)).to_i.should eq(0)
end
it "codegens enum bitflags All" do
run(%(
@[Flags]
enum Foo
A
B
C
end
Foo::All
)).to_i.should eq(1 + 2 + 4)
end
it "codegens enum None redefined" do
run(%(
@[Flags]
enum Foo
A
None = 10
end
Foo::None
)).to_i.should eq(10)
end
it "codegens enum All redefined" do
run(%(
@[Flags]
enum Foo
A
All = 10
end
Foo::All
)).to_i.should eq(10)
end
end