Skip to content

Commit

Permalink
Merge pull request JuliaLang#14304 from bicycle1885/nullable-show
Browse files Browse the repository at this point in the history
print the type parameter of Nullable
  • Loading branch information
jakebolewski committed Dec 16, 2015
2 parents 56f9140 + 958eb9a commit afcbab1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions base/nullable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ convert{T}(::Type{Nullable{T}}, ::Void) = Nullable{T}()
convert( ::Type{Nullable }, ::Void) = Nullable{Union{}}()

function show{T}(io::IO, x::Nullable{T})
if x.isnull
print(io, "Nullable{"); show(io, T); print(io, "}()")
else
print(io, "Nullable("); show(io, x.value); print(io, ")")
print(io, "Nullable{", T, "}(")
if !isnull(x)
show(io, x.value)
end
print(io, ')')
end

get(x::Nullable) = x.isnull ? throw(NullException()) : x.value
Expand Down
56 changes: 28 additions & 28 deletions test/nullable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,37 +94,37 @@ p1s = [
]

p2s = [
"Nullable(false)",
"Nullable('\0')",
"Nullable(Float16(0.0))",
"Nullable(0.0f0)",
"Nullable(0.0)",
"Nullable(0)",
"Nullable(0)",
"Nullable(0)",
"Nullable(0)",
"Nullable(0)",
"Nullable(0x0000)",
"Nullable(0x00000000)",
"Nullable(0x0000000000000000)",
"Nullable(0x00)",
"Nullable{Bool}(false)",
"Nullable{Char}('\0')",
"Nullable{Float16}(Float16(0.0))",
"Nullable{Float32}(0.0f0)",
"Nullable{Float64}(0.0)",
"Nullable{Int128}(0)",
"Nullable{Int16}(0)",
"Nullable{Int32}(0)",
"Nullable{Int64}(0)",
"Nullable{Int8}(0)",
"Nullable{UInt16}(0x0000)",
"Nullable{UInt32}(0x00000000)",
"Nullable{UInt64}(0x0000000000000000)",
"Nullable{UInt8}(0x00)",
]

p3s = [
"Nullable(true)",
"Nullable('\x01')",
"Nullable(Float16(1.0))",
"Nullable(1.0f0)",
"Nullable(1.0)",
"Nullable(1)",
"Nullable(1)",
"Nullable(1)",
"Nullable(1)",
"Nullable(1)",
"Nullable(0x0001)",
"Nullable(0x00000001)",
"Nullable(0x0000000000000001)",
"Nullable(0x01)",
"Nullable{Bool}(true)",
"Nullable{Char}('\x01')",
"Nullable{Float16}(Float16(1.0))",
"Nullable{Float32}(1.0f0)",
"Nullable{Float64}(1.0)",
"Nullable{Int128}(1)",
"Nullable{Int16}(1)",
"Nullable{Int32}(1)",
"Nullable{Int64}(1)",
"Nullable{Int8}(1)",
"Nullable{UInt16}(0x0001)",
"Nullable{UInt32}(0x00000001)",
"Nullable{UInt64}(0x0000000000000001)",
"Nullable{UInt8}(0x01)",
]

# show{T}(io::IO, x::Nullable{T})
Expand Down

0 comments on commit afcbab1

Please sign in to comment.