defmodule RDF.SigilsTest do use ExUnit.Case, async: true import RDF.Sigils doctest RDF.Sigils describe "~I sigil" do test "creates an IRI" do assert ~I == RDF.iri("http://example.com") end test "escaping" do assert ~I == RDF.iri("http://example.com/f\\no") end test "in pattern matches" do assert (case RDF.iri("http://example.com/foo") do ~I -> "match" _ -> :mismatch end) == "match" end end describe "~i sigil" do test "without interpolation" do assert ~i == RDF.iri("http://example.com") end test "with interpolation" do assert ~i == RDF.iri("http://example.com/3") assert ~i == RDF.iri("http://example.com/foo") assert ~i == RDF.iri("http://example.com/foo") end test "escaping" do assert ~i == RDF.iri("http://example.com/f\\no") end end describe "~B sigil" do test "creates a blank node" do assert ~B == RDF.bnode("foo") end end describe "~b sigil" do test "without interpolation" do assert ~b == RDF.bnode("foo") end test "with interpolation" do assert ~b == RDF.bnode("foo3") end end describe "~L sigil" do test "creates a plain Literal" do assert ~L"foo" == RDF.literal("foo") end test "creates a language-tagged Literal" do assert ~L"foo"en == RDF.literal("foo", language: "en") end end describe "~l sigil" do test "without interpolation" do assert ~l"foo" == RDF.literal("foo") assert ~l"foo"en == RDF.literal("foo", language: "en") end test "with interpolation" do assert ~l"foo#{1 + 2}" == RDF.literal("foo3") assert ~l"foo#{1 + 2}"en == RDF.literal("foo3", language: "en") end end end