• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rdf-elixir / jsonld-ex / de3ca9b1dae3a8dffda3dec6d69d62a58ee3622e

10 Apr 2025 03:31PM UTC coverage: 91.542%. Remained the same
de3ca9b1dae3a8dffda3dec6d69d62a58ee3622e

push

github

marcelotto
Remove unused HTML versions of test manifests

1775 of 1939 relevant lines covered (91.54%)

4387.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.22
/test/support/json_ld_case.ex
1
defmodule JSON.LD.Case do
2
  @moduledoc """
3
  Common `ExUnit.CaseTemplate` for JSON-LD tests.
4
  """
5

6
  use ExUnit.CaseTemplate
7

8
  using do
40✔
9
    quote do
10
      alias RDF.{
11
        Dataset,
12
        Graph,
13
        Description,
14
        IRI,
15
        BlankNode,
16
        Literal,
17
        XSD,
18
        PrefixMap,
19
        PropertyMap,
20
        NS
21
      }
22

23
      alias RDF.NS.{RDFS, XSD}
24
      alias JSON.LD.TestVocabularyNamespaces.{EX, S, FOAF}
25

26
      @compile {:no_warn_undefined, JSON.LD.TestVocabularyNamespaces.EX}
27
      @compile {:no_warn_undefined, JSON.LD.TestVocabularyNamespaces.S}
28
      @compile {:no_warn_undefined, JSON.LD.TestVocabularyNamespaces.FOAF}
29

30
      import RDF.Namespace.IRI
31
      import RDF.Sigils
32
      import RDF.Test.Assertions
33

34
      import unquote(__MODULE__)
35
    end
36
  end
37

38
  def context_with_inverse(context) do
39
    context
40
    |> JSON.LD.context()
41
    |> JSON.LD.Context.set_inverse()
588✔
42
  end
43

44
  def assert_raise_json_ld_error(code, fun) do
45
    try do
1,312✔
46
      fun.()
1,312✔
47
    rescue
48
      error ->
1,312✔
49
        case error do
1,312✔
50
          %JSON.LD.Error{code: ^code} ->
51
            error
1,312✔
52

53
          %JSON.LD.Error{code: unexpected_code} ->
54
            message =
×
55
              "Expected JSON.LD.Error exception with code #{inspect(code)} " <>
56
                "but got JSON.LD.Error with code #{inspect(unexpected_code)} (#{Exception.message(error)})"
×
57

58
            reraise ExUnit.AssertionError, [message: message], __STACKTRACE__
×
59

60
          %ExUnit.AssertionError{} ->
61
            reraise(error, __STACKTRACE__)
×
62

63
          _ ->
64
            message =
×
65
              "Expected JSON.LD.Error exception with code #{inspect(code)} " <>
66
                "but got #{inspect(error.__struct__)} (#{Exception.message(error)})"
×
67

68
            reraise ExUnit.AssertionError, [message: message], __STACKTRACE__
×
69
        end
70
    else
71
      _ -> flunk("Expected exception JSON.LD.Error with code #{code} but nothing was raised")
×
72
    end
73
  end
74

75
  def assert_raise_json_ld_error(code, message, fun) do
76
    error = assert_raise_json_ld_error(code, fun)
16✔
77

78
    match? =
16✔
79
      cond do
80
        is_binary(message) -> error.message == message
12✔
81
        is_struct(message, Regex) -> error.message =~ message
4✔
82
      end
83

84
    message =
16✔
85
      "Wrong message for JSON.LD.Error exception with code #{inspect(code)}:\n" <>
86
        "expected:\n  #{inspect(message)}\n" <>
87
        "actual:\n" <> "  #{inspect(error.message)}"
16✔
88

89
    if not match?, do: flunk(message)
16✔
90

91
    error
16✔
92
  end
93
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc