Fix failing CI on Elixir 1.9

This commit is contained in:
Marcel Otto 2021-03-06 02:38:20 +01:00
parent fa4bd06250
commit 84b71d2b50
8 changed files with 44 additions and 9 deletions

View file

@ -880,9 +880,13 @@ defmodule RDF.Dataset do
def member?(dataset, statement), do: {:ok, Dataset.include?(dataset, statement)}
def count(dataset), do: {:ok, Dataset.statement_count(dataset)}
def slice(dataset) do
size = Dataset.statement_count(dataset)
{:ok, size, &Enumerable.List.slice(Dataset.statements(dataset), &1, &2, size)}
if Version.match?(System.version(), "~> 1.10") do
def slice(dataset) do
size = Dataset.statement_count(dataset)
{:ok, size, &Enumerable.List.slice(Dataset.statements(dataset), &1, &2, size)}
end
else
def slice(_), do: {:error, __MODULE__}
end
def reduce(dataset, acc, fun) do

View file

@ -828,9 +828,13 @@ defmodule RDF.Description do
def count(desc), do: {:ok, Description.statement_count(desc)}
def slice(desc) do
size = Description.statement_count(desc)
{:ok, size, &Enumerable.List.slice(Description.triples(desc), &1, &2, size)}
if Version.match?(System.version(), "~> 1.10") do
def slice(desc) do
size = Description.statement_count(desc)
{:ok, size, &Enumerable.List.slice(Description.triples(desc), &1, &2, size)}
end
else
def slice(_), do: {:error, __MODULE__}
end
def reduce(desc, acc, fun) do

View file

@ -1093,9 +1093,13 @@ defmodule RDF.Graph do
def member?(graph, triple), do: {:ok, Graph.include?(graph, triple)}
def count(graph), do: {:ok, Graph.statement_count(graph)}
def slice(graph) do
size = Graph.statement_count(graph)
{:ok, size, &Enumerable.List.slice(Graph.triples(graph), &1, &2, size)}
if Version.match?(System.version(), "~> 1.10") do
def slice(graph) do
size = Graph.statement_count(graph)
{:ok, size, &Enumerable.List.slice(Graph.triples(graph), &1, &2, size)}
end
else
def slice(_), do: {:error, __MODULE__}
end
def reduce(graph, acc, fun) do

View file

@ -1829,6 +1829,11 @@ defmodule RDF.DatasetTest do
assert ds ==
Enum.reduce(ds, dataset(), fn statement, acc -> acc |> Dataset.add(statement) end)
end
test "Enum.at (for Enumerable.slice/1)" do
assert Dataset.new({EX.S, EX.p(), EX.O, EX.Graph})
|> Enum.at(0) == {RDF.iri(EX.S), EX.p(), RDF.iri(EX.O), RDF.iri(EX.Graph)}
end
end
describe "Collectable protocol" do

View file

@ -953,6 +953,11 @@ defmodule RDF.DescriptionTest do
acc |> Description.add(triple)
end)
end
test "Enum.at (for Enumerable.slice/1)" do
assert Description.new(EX.S, init: {EX.S, EX.p(), EX.O})
|> Enum.at(0) == {RDF.iri(EX.S), EX.p(), RDF.iri(EX.O)}
end
end
describe "Collectable protocol" do

View file

@ -1504,6 +1504,11 @@ defmodule RDF.GraphTest do
assert g == Enum.reduce(g, graph(), fn triple, acc -> acc |> Graph.add(triple) end)
end
test "Enum.at (for Enumerable.slice/1)" do
assert Graph.new({EX.S, EX.p(), EX.O})
|> Enum.at(0) == {RDF.iri(EX.S), EX.p(), RDF.iri(EX.O)}
end
end
describe "Collectable protocol" do

View file

@ -395,5 +395,9 @@ defmodule RDF.PrefixMapTest do
assert Enum.reduce(@example2, [], fn mapping, acc -> [mapping | acc] end) ==
[{:ex2, @ex_ns2}, {:ex1, @ex_ns1}]
end
test "Enum.at (for Enumerable.slice/1)" do
assert Enum.at(@example2, 0) == {:ex1, @ex_ns1}
end
end
end

View file

@ -315,5 +315,9 @@ defmodule RDF.PropertyMapTest do
{:Baz, RDF.iri(EX.Baz)}
]
end
test "Enum.at (for Enumerable.slice/1)" do
assert Enum.at(@example_property_map, 0) == {:Baz, RDF.iri(EX.Baz)}
end
end
end