Fix non-empty RDF.Graph when adding empty RDF.Description (#8)
This commit is contained in:
parent
0e81f4c02c
commit
2d68a352ed
2 changed files with 12 additions and 2 deletions
|
@ -177,8 +177,13 @@ defmodule RDF.Graph do
|
|||
end)
|
||||
end
|
||||
|
||||
def add(%__MODULE__{} = graph, %Description{subject: subject} = description),
|
||||
do: do_add(graph, subject, description)
|
||||
def add(%__MODULE__{} = graph, %Description{subject: subject} = description) do
|
||||
if Description.count(description) > 0 do
|
||||
do_add(graph, subject, description)
|
||||
else
|
||||
graph
|
||||
end
|
||||
end
|
||||
|
||||
def add(graph, %__MODULE__{descriptions: descriptions, prefixes: prefixes}) do
|
||||
graph =
|
||||
|
|
|
@ -98,6 +98,11 @@ defmodule RDF.GraphTest do
|
|||
assert graph_includes_statement?(g, {EX.Subject, EX.predicate(), EX.Object})
|
||||
end
|
||||
|
||||
test "creating an unnamed graph with an empty description" do
|
||||
g = Graph.new(Description.new(EX.Subject))
|
||||
assert empty_graph?(g)
|
||||
end
|
||||
|
||||
test "creating a named graph from another graph" do
|
||||
g =
|
||||
Graph.new(Graph.new({EX.Subject, EX.predicate(), EX.Object}),
|
||||
|
|
Loading…
Reference in a new issue