Skip to content

Commit 551947b

Browse files
bramtaylJeffBezanson
authored andcommitted
Missing enum tests (#34468)
1 parent f579d14 commit 551947b

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/enums.jl

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ using Main.MacroCalls
1010

1111
@test_throws MethodError convert(Enum, 1.0)
1212

13+
@test_throws ArgumentError("invalid type expression for enum 1 + 1") @macrocall(@enum 1 + 1 2)
1314
@test_throws ArgumentError("no arguments given for Enum Foo") @macrocall(@enum Foo)
1415
@test_throws ArgumentError("invalid base type for Enum Foo2, Foo2::Float64=::Float64; base type must be an integer primitive type") @macrocall(@enum Foo2::Float64 apple=1.)
1516

@@ -89,6 +90,7 @@ end
8990
2
9091
end""") @macrocall(@enum Test2 x ? 1 : 2)
9192
@test_throws ArgumentError("invalid argument for Enum Test22: 1 = 2") @macrocall(@enum Test22 1=2)
93+
@test_throws ArgumentError("invalid name for Enum TestEnum; \"1 + 1\" is not a valid identifier") var"@enum"(LineNumberNode(@__LINE__), @__MODULE__, :TestEnum, Symbol("1 + 1"))
9294

9395
# other Integer types of enum members
9496
@enum Test3::UInt8 _one_Test3=0x01 _two_Test3=0x02 _three_Test3=0x03
@@ -167,3 +169,34 @@ end
167169
@test Int(haggis) == 4
168170

169171
@test (Vector{Fruit}(undef, 3) .= apple) == [apple, apple, apple]
172+
173+
# long, discongruous
174+
@enum Alphabet begin
175+
alphabet_a
176+
alphabet_b
177+
alphabet_c
178+
alphabet_d
179+
alphabet_e
180+
alphabet_f
181+
alphabet_g
182+
alphabet_h
183+
alphabet_i
184+
alphabet_j
185+
alphabet_k
186+
alphabet_l
187+
alphabet_m
188+
alphabet_n
189+
alphabet_o
190+
alphabet_p
191+
alphabet_q
192+
alphabet_r
193+
alphabet_s
194+
alphabet_t
195+
alphabet_u
196+
alphabet_v
197+
alphabet_w
198+
alphabet_x
199+
alphabet_y
200+
alphabet_z = 26
201+
end
202+
@test alphabet_z == Alphabet(26)

0 commit comments

Comments
 (0)