Skip to content

Commit

Permalink
Merge pull request #25850 from JuliaLang/ksh/testenums
Browse files Browse the repository at this point in the history
Two small tests for enums
  • Loading branch information
StefanKarpinski authored Feb 2, 2018
2 parents f0994c2 + a264a5d commit 0702f7a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/enums.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ macro macrocall(ex)
end

@test_throws ArgumentError("no arguments given for Enum Foo") @macrocall(@enum Foo)
@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.)

@enum Fruit apple orange kiwi
@test typeof(Fruit) == DataType
Expand Down Expand Up @@ -138,6 +139,11 @@ end

@test reprmime("text/plain", Fruit) == "Enum $(string(Fruit)):\napple = 0\norange = 1\nkiwi = 2"
@test reprmime("text/plain", orange) == "orange::$(curmod_prefix)Fruit = 1"
let io = IOBuffer()
ioc = IOContext(io, :compact=>false)
show(io, Fruit)
@test String(take!(io)) == sprint(print, Fruit)
end

@enum LogLevel DEBUG INFO WARN ERROR CRITICAL
@test DEBUG < CRITICAL
Expand Down

0 comments on commit 0702f7a

Please sign in to comment.