moxml-testsuite 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "testsuite/dataset"
5
+ require_relative "testsuite/report"
6
+ require_relative "testsuite/reference"
7
+ require_relative "testsuite/families/serialization"
8
+ require_relative "testsuite/families/c14n"
9
+ require_relative "testsuite/families/xsd_structural"
10
+ require_relative "testsuite/families/entity_registry"
11
+ require_relative "testsuite/families/decisions"
12
+
13
+ module Moxml
14
+ module TestSuite
15
+ # The certification runner. Give it a facade implementing the
16
+ # certification protocol and it drives every engine-implementable
17
+ # family in the dataset, returning a Report.
18
+ #
19
+ # The protocol (all methods required unless noted):
20
+ #
21
+ # parse(xml_string) -> a document handle
22
+ # serialize(doc) -> xml string (the model's
23
+ # emitter shapes)
24
+ # canonicalize(doc) -> C14N 1.0 bytes
25
+ # validate_xsd(schema_xml, instance) -> [] | [#to_s messages]
26
+ # lexical_valid?(type_name, lexical) -> bool
27
+ # wildcard_covers?(...) -> bool
28
+ # wildcard_exclusion?(...) -> String | nil
29
+ # entity_declared? / entity_codepoint / entity_names /
30
+ # entity_primary_name / entity_standard? /
31
+ # entity_should_restore? -> the registry answers
32
+ # regex_translates?(pattern) -> regexp | nil
33
+ #
34
+ # The decision faces are the model's committed answers as pure
35
+ # functions - the DOM faces wrap the same answers in a tree.
36
+ # Reference (below) implements the whole protocol on moxml;
37
+ # engines that cannot answer a family's faces see that family
38
+ # SKIP, loudly - never a quiet pass.
39
+ def self.run(facade, families: nil)
40
+ dataset = Dataset.load
41
+ families ||= Dataset::FAMILIES
42
+ report = Report.new(facade_class: facade.class.name)
43
+ families.each do |family|
44
+ runner = runner_for(family, facade, dataset)
45
+ next report.skip(family, "not certifiable by this facade") unless runner
46
+
47
+ runner.call(report)
48
+ end
49
+ report
50
+ end
51
+
52
+ def self.runner_for(family, facade, dataset)
53
+ case family
54
+ when "serialization" then Families::Serialization.new(facade, dataset)
55
+ when "c14n" then Families::C14n.new(facade, dataset)
56
+ when "xsd_structural" then Families::XsdStructural.new(facade, dataset)
57
+ when "entity_registry" then Families::EntityRegistry.new(facade, dataset)
58
+ when "builtin_lexical", "schema_wildcards", "xsd_regex_translation"
59
+ Families::Decisions.new(facade, dataset)
60
+ end
61
+ end
62
+ end
63
+ end