Remove unnecessary whitespace

This commit is contained in:
Marcel Otto 2019-04-01 02:04:51 +02:00
parent b5b7fefc3d
commit eb71b26f08
4 changed files with 36 additions and 36 deletions

View file

@ -58,7 +58,7 @@ defmodule RDF.Vocabulary.Namespace do
end end
@base_iri unquote(base_iri) @base_iri unquote(base_iri)
def __base_iri__, do: @base_iri def __base_iri__, do: @base_iri
@strict unquote(strict) @strict unquote(strict)
def __strict__, do: @strict def __strict__, do: @strict

View file

@ -17,7 +17,7 @@ defmodule RDF.SerializationTest do
@example_graph RDF.Graph.new [{EX.S, EX.p, EX.O}] @example_graph RDF.Graph.new [{EX.S, EX.p, EX.O}]
@example_graph_turtle """ @example_graph_turtle """
@prefix : <#{to_string(EX. __base_iri__)}> . @prefix : <#{to_string(EX.__base_iri__)}> .
:S :S
:p :O . :p :O .
@ -122,19 +122,19 @@ defmodule RDF.SerializationTest do
describe "write_string/2" do describe "write_string/2" do
test "with name of available format" do test "with name of available format" do
assert RDF.Serialization.write_string(@example_graph, format: :turtle, assert RDF.Serialization.write_string(@example_graph, format: :turtle,
prefixes: %{"" => EX. __base_iri__}) == prefixes: %{"" => EX.__base_iri__}) ==
{:ok, @example_graph_turtle} {:ok, @example_graph_turtle}
end end
test "with invalid format name" do test "with invalid format name" do
assert RDF.Serialization.write_string(@example_graph, format: :foo, assert RDF.Serialization.write_string(@example_graph, format: :foo,
prefixes: %{"" => EX. __base_iri__}) == prefixes: %{"" => EX.__base_iri__}) ==
{:error, "unable to detect serialization format"} {:error, "unable to detect serialization format"}
end end
test "with media type" do test "with media type" do
assert RDF.Serialization.write_string(@example_graph, media_type: "text/turtle", assert RDF.Serialization.write_string(@example_graph, media_type: "text/turtle",
prefixes: %{"" => EX. __base_iri__}) == prefixes: %{"" => EX.__base_iri__}) ==
{:ok, @example_graph_turtle} {:ok, @example_graph_turtle}
end end
end end
@ -142,20 +142,20 @@ defmodule RDF.SerializationTest do
describe "write_string!/2" do describe "write_string!/2" do
test "with name of available format" do test "with name of available format" do
assert RDF.Serialization.write_string!(@example_graph, format: :turtle, assert RDF.Serialization.write_string!(@example_graph, format: :turtle,
prefixes: %{"" => EX. __base_iri__}) == prefixes: %{"" => EX.__base_iri__}) ==
@example_graph_turtle @example_graph_turtle
end end
test "with invalid format name" do test "with invalid format name" do
assert_raise RuntimeError, "unable to detect serialization format", fn -> assert_raise RuntimeError, "unable to detect serialization format", fn ->
RDF.Serialization.write_string!(@example_graph, format: :foo, RDF.Serialization.write_string!(@example_graph, format: :foo,
prefixes: %{"" => EX. __base_iri__}) prefixes: %{"" => EX.__base_iri__})
end end
end end
test "with media type" do test "with media type" do
assert RDF.Serialization.write_string!(@example_graph, media_type: "text/turtle", assert RDF.Serialization.write_string!(@example_graph, media_type: "text/turtle",
prefixes: %{"" => EX. __base_iri__}) == prefixes: %{"" => EX.__base_iri__}) ==
@example_graph_turtle @example_graph_turtle
end end
end end
@ -165,7 +165,7 @@ defmodule RDF.SerializationTest do
file = file("write_file_test.ttl") file = file("write_file_test.ttl")
if File.exists?(file), do: File.rm(file) if File.exists?(file), do: File.rm(file)
assert RDF.Serialization.write_file(@example_graph, file, assert RDF.Serialization.write_file(@example_graph, file,
prefixes: %{"" => EX. __base_iri__}) == :ok prefixes: %{"" => EX.__base_iri__}) == :ok
assert File.exists?(file) assert File.exists?(file)
assert File.read!(file) == @example_graph_turtle assert File.read!(file) == @example_graph_turtle
File.rm(file) File.rm(file)
@ -175,7 +175,7 @@ defmodule RDF.SerializationTest do
file = file("write_file_test.nt") file = file("write_file_test.nt")
if File.exists?(file), do: File.rm(file) if File.exists?(file), do: File.rm(file)
assert RDF.Serialization.write_file(@example_graph, file, format: :turtle, assert RDF.Serialization.write_file(@example_graph, file, format: :turtle,
prefixes: %{"" => EX. __base_iri__}) == :ok prefixes: %{"" => EX.__base_iri__}) == :ok
assert File.exists?(file) assert File.exists?(file)
assert File.read!(file) == @example_graph_turtle assert File.read!(file) == @example_graph_turtle
File.rm(file) File.rm(file)
@ -187,7 +187,7 @@ defmodule RDF.SerializationTest do
file = file("write_file_test.ttl") file = file("write_file_test.ttl")
if File.exists?(file), do: File.rm(file) if File.exists?(file), do: File.rm(file)
assert RDF.Serialization.write_file!(@example_graph, file, assert RDF.Serialization.write_file!(@example_graph, file,
prefixes: %{"" => EX. __base_iri__}) == :ok prefixes: %{"" => EX.__base_iri__}) == :ok
assert File.exists?(file) assert File.exists?(file)
assert File.read!(file) == @example_graph_turtle assert File.read!(file) == @example_graph_turtle
File.rm(file) File.rm(file)
@ -197,7 +197,7 @@ defmodule RDF.SerializationTest do
file = file("write_file_test.nt") file = file("write_file_test.nt")
if File.exists?(file), do: File.rm(file) if File.exists?(file), do: File.rm(file)
assert RDF.Serialization.write_file!(@example_graph, file, format: :turtle, assert RDF.Serialization.write_file!(@example_graph, file, format: :turtle,
prefixes: %{"" => EX. __base_iri__}) == :ok prefixes: %{"" => EX.__base_iri__}) == :ok
assert File.exists?(file) assert File.exists?(file)
assert File.read!(file) == @example_graph_turtle assert File.read!(file) == @example_graph_turtle
File.rm(file) File.rm(file)

View file

@ -46,11 +46,11 @@ defmodule RDF.Turtle.EncoderTest do
{EX.S1, EX.p2, EX.O3}, {EX.S1, EX.p2, EX.O3},
{EX.S2, EX.p3, EX.O4}, {EX.S2, EX.p3, EX.O4},
]), prefixes: %{ ]), prefixes: %{
ex: EX. __base_iri__, ex: EX.__base_iri__,
xsd: XSD. __base_iri__ xsd: XSD.__base_iri__
}) == }) ==
""" """
@prefix ex: <#{to_string(EX. __base_iri__)}> . @prefix ex: <#{to_string(EX.__base_iri__)}> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:S1 ex:S1
@ -64,9 +64,9 @@ defmodule RDF.Turtle.EncoderTest do
test "statements with empty prefixed names" do test "statements with empty prefixed names" do
assert Turtle.Encoder.encode!(Graph.new({EX.S, EX.p, EX.O}), assert Turtle.Encoder.encode!(Graph.new({EX.S, EX.p, EX.O}),
prefixes: %{"" => EX. __base_iri__}) == prefixes: %{"" => EX.__base_iri__}) ==
""" """
@prefix : <#{to_string(EX. __base_iri__)}> . @prefix : <#{to_string(EX.__base_iri__)}> .
:S :S
:p :O . :p :O .
@ -104,22 +104,22 @@ defmodule RDF.Turtle.EncoderTest do
test "ordering of descriptions" do test "ordering of descriptions" do
assert Turtle.Encoder.encode!(Graph.new([ assert Turtle.Encoder.encode!(Graph.new([
{EX. __base_iri__, RDF.type, OWL.Ontology}, {EX.__base_iri__, RDF.type, OWL.Ontology},
{EX.S1, RDF.type, EX.O}, {EX.S1, RDF.type, EX.O},
{EX.S2, RDF.type, RDFS.Class}, {EX.S2, RDF.type, RDFS.Class},
{EX.S3, RDF.type, RDF.Property}, {EX.S3, RDF.type, RDF.Property},
]), ]),
base: EX. __base_iri__, base: EX.__base_iri__,
prefixes: %{ prefixes: %{
rdf: RDF. __base_iri__, rdf: RDF.__base_iri__,
rdfs: RDFS. __base_iri__, rdfs: RDFS.__base_iri__,
owl: OWL. __base_iri__, owl: OWL.__base_iri__,
}) == }) ==
""" """
@base <#{to_string(EX. __base_iri__)}> . @base <#{to_string(EX.__base_iri__)}> .
@prefix rdf: <#{to_string(RDF. __base_iri__)}> . @prefix rdf: <#{to_string(RDF.__base_iri__)}> .
@prefix rdfs: <#{to_string(RDFS. __base_iri__)}> . @prefix rdfs: <#{to_string(RDFS.__base_iri__)}> .
@prefix owl: <#{to_string(OWL. __base_iri__)}> . @prefix owl: <#{to_string(OWL.__base_iri__)}> .
<> <>
a owl:Ontology . a owl:Ontology .
@ -141,7 +141,7 @@ defmodule RDF.Turtle.EncoderTest do
setup do setup do
{:ok, {:ok,
prefixes: %{ prefixes: %{
RDF.iri(EX. __base_iri__) => "ex", RDF.iri(EX.__base_iri__) => "ex",
~I<http://example.org/> => "ex2" ~I<http://example.org/> => "ex2"
} }
} }
@ -153,7 +153,7 @@ defmodule RDF.Turtle.EncoderTest do
end end
test "hash iri namespace without name", %{prefixes: prefixes} do test "hash iri namespace without name", %{prefixes: prefixes} do
assert Turtle.Encoder.prefixed_name(RDF.iri(EX. __base_iri__), prefixes) == assert Turtle.Encoder.prefixed_name(RDF.iri(EX.__base_iri__), prefixes) ==
"ex:" "ex:"
end end
@ -396,9 +396,9 @@ defmodule RDF.Turtle.EncoderTest do
# |> assert_serialization( # |> assert_serialization(
# prefixes: %{ # prefixes: %{
# ex: ~I<http://example.com/>, # ex: ~I<http://example.com/>,
# rdf: RDF.NS.RDF. __base_iri__, # rdf: RDF.NS.RDF.__base_iri__,
# rdfs: RDFS. __base_iri__, # rdfs: RDFS.__base_iri__,
# owl: OWL. __base_iri__, # owl: OWL.__base_iri__,
# }, # },
# matches: [ # matches: [
# {~r[ex:a\s+rdfs:domain \[\s+a owl:Class;\s+owl:unionOf\s+\(ex:b\s+ex:c\)\s*\]\s*\.], # {~r[ex:a\s+rdfs:domain \[\s+a owl:Class;\s+owl:unionOf\s+\(ex:b\s+ex:c\)\s*\]\s*\.],
@ -419,7 +419,7 @@ defmodule RDF.Turtle.EncoderTest do
|> RDF.rest(RDF.nil)) |> RDF.rest(RDF.nil))
|> Graph.add({EX.Baz, EX.quux, ~B<Bar>}) |> Graph.add({EX.Baz, EX.quux, ~B<Bar>})
|> assert_serialization( |> assert_serialization(
prefixes: %{ex: EX. __base_iri__}, prefixes: %{ex: EX.__base_iri__},
# TODO: provide a positive match # TODO: provide a positive match
neg_matches: [ neg_matches: [
{~r[\(\s*ex:Foo\s+ex:Bar\s*\)], "does include the list as a Turtle list"} {~r[\(\s*ex:Foo\s+ex:Bar\s*\)], "does include the list as a Turtle list"}
@ -491,7 +491,7 @@ defmodule RDF.Turtle.EncoderTest do
~r[@prefix xsd: <http://www.w3.org/2001/XMLSchema#> \.], ~r[@prefix xsd: <http://www.w3.org/2001/XMLSchema#> \.],
~r["http://foo/"\^\^xsd:anyURI \.] ~r["http://foo/"\^\^xsd:anyURI \.]
], ],
prefixes: %{xsd: XSD. __base_iri__} prefixes: %{xsd: XSD.__base_iri__}
) )
end end

View file

@ -667,12 +667,12 @@ defmodule RDF.Vocabulary.NamespaceTest do
end end
test " __base_iri__ returns the base_iri" do test "__base_iri__ returns the base_iri" do
alias TestNS.ExampleFromGraph, as: HashVocab alias TestNS.ExampleFromGraph, as: HashVocab
alias TestNS.ExampleFromNTriplesFile, as: SlashVocab alias TestNS.ExampleFromNTriplesFile, as: SlashVocab
assert HashVocab. __base_iri__ == "http://example.com/from_graph#" assert HashVocab.__base_iri__ == "http://example.com/from_graph#"
assert SlashVocab. __base_iri__ == "http://example.com/from_ntriples/" assert SlashVocab.__base_iri__ == "http://example.com/from_ntriples/"
end end