Skip to content

Commit

Permalink
Disable Nullable tests when Nullable isn't defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Dec 20, 2017
1 parent ad1f40c commit 22bd8dd
Showing 1 changed file with 54 additions and 52 deletions.
106 changes: 54 additions & 52 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,58 +213,60 @@ mktemp() do fname, f
end
end

types = [
Bool,
Float16,
Float32,
Float64,
Int128,
Int16,
Int32,
Int64,
Int8,
UInt16,
UInt32,
UInt64,
UInt8,
]
for T in types
# julia#18510, Nullable constructors
x = @compat Nullable(one(T), true)
@test isnull(x) === false
@test isa(x.value, T)
@test eltype(x) === T

x = @compat Nullable{T}(one(T), true)
y = @compat Nullable{Any}(one(T), true)
@test isnull(x) === false
@test isnull(y) === false
@test isa(x.value, T)
@test eltype(x) === T
@test eltype(y) === Any

x = @compat Nullable{T}(one(T), false)
y = @compat Nullable{Any}(one(T), false)
@test isnull(x) === true
@test isnull(y) === true
@test eltype(x) === T
@test eltype(y) === Any

x = @compat Nullable(one(T), false)
@test isnull(x) === true
@test eltype(x) === T

x = @compat Nullable{T}()
@test isnull(x) === true
@test eltype(x) === T

# julia#18484, generic isnull, unsafe_get
a = one(T)
x = @compat Nullable(a, true)
@test isequal(unsafe_get(x), a)

x = @compat Nullable{Array{T}}()
@test_throws UndefRefError unsafe_get(x)
if VERSION < v"0.7.0-DEV.3017"
types = [
Bool,
Float16,
Float32,
Float64,
Int128,
Int16,
Int32,
Int64,
Int8,
UInt16,
UInt32,
UInt64,
UInt8,
]
for T in types
# julia#18510, Nullable constructors
x = @compat Nullable(one(T), true)
@test isnull(x) === false
@test isa(x.value, T)
@test eltype(x) === T

x = @compat Nullable{T}(one(T), true)
y = @compat Nullable{Any}(one(T), true)
@test isnull(x) === false
@test isnull(y) === false
@test isa(x.value, T)
@test eltype(x) === T
@test eltype(y) === Any

x = @compat Nullable{T}(one(T), false)
y = @compat Nullable{Any}(one(T), false)
@test isnull(x) === true
@test isnull(y) === true
@test eltype(x) === T
@test eltype(y) === Any

x = @compat Nullable(one(T), false)
@test isnull(x) === true
@test eltype(x) === T

x = @compat Nullable{T}()
@test isnull(x) === true
@test eltype(x) === T

# julia#18484, generic isnull, unsafe_get
a = one(T)
x = @compat Nullable(a, true)
@test isequal(unsafe_get(x), a)

x = @compat Nullable{Array{T}}()
@test_throws UndefRefError unsafe_get(x)
end
end

@test xor(1,5) == 4
Expand Down

0 comments on commit 22bd8dd

Please sign in to comment.