From 3e346bbfed764085833a9741f5690fda835a016e Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 25 Apr 2015 01:43:20 -0400 Subject: [PATCH] Fix and test the SimpleVector writing code --- src/jld_types.jl | 5 +++-- test/jld.jl | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/jld_types.jl b/src/jld_types.jl index c218f1aae..5dc5755fc 100644 --- a/src/jld_types.jl +++ b/src/jld_types.jl @@ -306,9 +306,10 @@ if VERSION >= v"0.4.0-dev+4319" end gen_h5convert(::JldFile, ::Type{SimpleVector}) = nothing - h5convert!(out::Ptr, ::JldFile, x::SimpleVector, ::JldWriteSession) = - unsafe_store!(convert(Ptr{HDF5.HDF5ReferenceObj}, out), write_ref(parent::JldFile, [x...], wsession::JldWriteSession)) + h5convert!(out::Ptr, parent::JldFile, x::SimpleVector, wsession::JldWriteSession) = + unsafe_store!(convert(Ptr{HDF5.HDF5ReferenceObj}, out), write_ref(parent, [x...], wsession)) + push!(BUILTIN_TYPES, SimpleVector) function jlconvert(::Type{SimpleVector}, file::JldFile, ptr::Ptr) Base.svec(read_ref(file, unsafe_load(convert(Ptr{HDF5.HDF5ReferenceObj}, ptr)))...) end diff --git a/test/jld.jl b/test/jld.jl index 48c917b89..62b4516ac 100644 --- a/test/jld.jl +++ b/test/jld.jl @@ -205,6 +205,11 @@ bitsparamint16 = BitsParams{@compat Int16(1)}() # Tuple of tuples tuple_of_tuples = (1, 2, (3, 4, [5, 6]), [7, 8]) +# SimpleVector +if VERSION >= v"0.4.0-dev+4319" + simplevec = Base.svec(1, 2, Int64, "foo") +end + iseq(x,y) = isequal(x,y) iseq(x::MyStruct, y::MyStruct) = (x.len == y.len && x.data == y.data) iseq(x::MyImmutable, y::MyImmutable) = (isequal(x.x, y.x) && isequal(x.y, y.y) && isequal(x.z, y.z)) @@ -220,6 +225,7 @@ function iseq(c1::Base.Sys.CPUinfo, c2::Base.Sys.CPUinfo) end iseq(x::MyUnicodeStruct☺, y::MyUnicodeStruct☺) = (x.α == y.α && x.∂ₓα == y.∂ₓα) iseq(x::Array{None}, y::Array{None}) = size(x) == size(y) +iseq(x::SimpleVector, y::SimpleVector) = collect(x) == collect(y) macro check(fid, sym) ex = quote let tmp @@ -387,6 +393,7 @@ for compress in (true,false) @write fid bitsparamint @write fid bitsparamuint @write fid tuple_of_tuples + VERSION >= v"0.4.0-dev+4319" && @write fid simplevec # Make sure we can create groups (i.e., use HDF5 features) g = g_create(fid, "mygroup") @@ -515,6 +522,7 @@ for compress in (true,false) @check fidr bitsparamint @check fidr bitsparamuint @check fidr tuple_of_tuples + VERSION >= v"0.4.0-dev+4319" && @check fidr simplevec x1 = read(fidr, "group1/x") @assert x1 == Any[1]