Skip to content

Commit

Permalink
🚨 Fix tests for Julia 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ronisbr committed Mar 15, 2020
1 parent de032c3 commit a7d247d
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions test/text_backend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,25 @@
#
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #

# These structures must not be defined inside a @testset. Otherwise, the test
# will fail for Julia 1.0.
struct MyColumnTable{T <: AbstractMatrix}
names::Vector{Symbol}
lookup::Dict{Symbol, Int}
matrix::T
end

struct MyRowTable{T <: AbstractMatrix}
names::Vector{Symbol}
lookup::Dict{Symbol, Int}
matrix::T
end

struct MyMatrixRow{T} <: Tables.AbstractRow
row::Int
source::MyRowTable{T}
end

data = Any[1 false 1.0 0x01 ;
2 true 2.0 0x02 ;
3 false 3.0 0x03 ;
Expand Down Expand Up @@ -1331,12 +1350,6 @@ end
# Column table
# --------------------------------------------------------------------------

struct MyColumnTable{T <: AbstractMatrix}
names::Vector{Symbol}
lookup::Dict{Symbol, Int}
matrix::T
end

Tables.istable(::Type{<:MyColumnTable}) = true
names(m::MyColumnTable) = getfield(m, :names)
mat(m::MyColumnTable) = getfield(m, :matrix)
Expand Down Expand Up @@ -1364,12 +1377,6 @@ end
# First, we need to create a object that complies with Tables.jl and that
# does not have a schema. This is based on Tables.jl documentation.

struct MyRowTable{T <: AbstractMatrix}
names::Vector{Symbol}
lookup::Dict{Symbol, Int}
matrix::T
end

Tables.istable(::Type{<:MyRowTable}) = true
names(m::MyRowTable) = getfield(m, :names)
mat(m::MyRowTable) = getfield(m, :matrix)
Expand All @@ -1381,11 +1388,6 @@ end
Base.length(m::MyRowTable) = size(mat(m), 1)
Base.iterate(m::MyRowTable, st=1) = st > length(m) ? nothing : (MyMatrixRow(st, m), st + 1)

struct MyMatrixRow{T} <: Tables.AbstractRow
row::Int
source::MyRowTable{T}
end

Tables.getcolumn(m::MyMatrixRow, ::Type, col::Int, nm::Symbol) =
getfield(getfield(m, :source), :matrix)[getfield(m, :row), col]
Tables.getcolumn(m::MyMatrixRow, i::Int) =
Expand Down

0 comments on commit a7d247d

Please sign in to comment.