diff --git a/Project.toml b/Project.toml index eecf274..e877b88 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "EnumX" uuid = "4e289a0a-7415-4d19-859d-a7e5c4648b56" -version = "1.0.4" +version = "1.0.5" [compat] julia = "1.6" diff --git a/src/EnumX.jl b/src/EnumX.jl index 22a87d2..1f90592 100644 --- a/src/EnumX.jl +++ b/src/EnumX.jl @@ -133,6 +133,12 @@ function enumx(_module_, args) EnumX.symbol_map(::Base.Type{$(esc(T))}) = $(name_value_map) end end + if VERSION >= v"1.11.0-DEV.469" + push!( + module_block.args, + esc(Expr(:public, values(value_name_map)...)) + ) + end for (k, v) in name_value_map push!( module_block.args, diff --git a/test/runtests.jl b/test/runtests.jl index 5e8a5e7..601e46a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,7 +16,6 @@ const Ananab = -1 @enumx Fruit Apple Banana @test Fruit isa Module - @test Set(names(Fruit)) == Set([:Fruit]) @test_broken Set(names(Fruit; all = true)) == Set([:Fruit, :Apple, :Banana, :T]) @test issubset(Set([:Fruit, :Apple, :Banana, :T]), Set(names(Fruit; all = true))) @test Fruit.T <: EnumX.Enum{Int32} <: Base.Enum{Int32} @@ -48,6 +47,15 @@ const Ananab = -1 @test_throws ArgumentError("invalid value for Enum Fruit: 123.") Fruit.T(Int32(123)) @test_throws ArgumentError("invalid value for Enum Fruit: 123.") Fruit.T(123) + # Public enum member values (#11) + if VERSION >= v"1.11.0-DEV.469" + @test Set(names(Fruit)) == Set([:Fruit, :Apple, :Banana]) + @test Base.ispublic(Fruit, :Apple) + @test Base.ispublic(Fruit, :Banana) + else + @test Set(names(Fruit)) == Set([:Fruit]) + end + @test Fruit.Apple < Fruit.Banana let io = IOBuffer()