Skip to content

Commit

Permalink
Merge pull request #71 from phillord/fix/clean-test-files
Browse files Browse the repository at this point in the history
Ensure test file generation is consistent
  • Loading branch information
phillord authored Mar 11, 2024
2 parents 6222654 + 6f24b1c commit 25fa218
Show file tree
Hide file tree
Showing 369 changed files with 5,679 additions and 2,766 deletions.
21 changes: 5 additions & 16 deletions src/io/owx/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,17 +1258,6 @@ pub mod test {
);
}

#[test]
fn test_simple_ontology_rendered_by_horned() {
let ont_s = include_str!("../../ont/owl-xml/one-ont-from-horned.owx");
let (ont, _) = read_ok(&mut ont_s.as_bytes());

assert_eq!(
ont.i().the_ontology_id_or_default().iri.as_ref().unwrap().as_ref(),
"http://example.com/iri"
);
}

#[test]
fn test_class() {
let ont_s = include_str!("../../ont/owl-xml/class.owx");
Expand Down Expand Up @@ -1323,7 +1312,7 @@ pub mod test {

#[test]
fn test_one_class_fqn() {
let ont_s = include_str!("../../ont/owl-xml/one-class-fully-qualified.owx");
let ont_s = include_str!("../../ont/owl-xml/manual/one-class-fully-qualified.owx");
let (ont, _) = read_ok(&mut ont_s.as_bytes());

assert_eq!(ont.i().declare_class().count(), 1);
Expand Down Expand Up @@ -1690,7 +1679,7 @@ pub mod test {
let ss = ont.i().sub_class_of().next().unwrap();
match ss.sup {
ClassExpression::ObjectHasSelf(ObjectPropertyExpression::ObjectProperty(ref op)) => {
assert_eq!(String::from(op), "http://example.com/iri#o")
assert_eq!(String::from(op), "http://www.example.com/iri#op")
}
_ => {
panic!("Expecting ObjectProperty");
Expand All @@ -1717,7 +1706,7 @@ pub mod test {
} => String::from(op),
_ => "It didn't match".to_string(),
},
"http://www.example.com#r"
"http://www.example.com/iri#r"
);
}

Expand Down Expand Up @@ -1835,7 +1824,7 @@ pub mod test {

match dd {
DatatypeDefinition { kind, range } => {
assert_eq!(String::from(kind), "http://www.example.com/D");
assert_eq!(String::from(kind), "http://www.example.com/iri#D");

match range {
DataRange::Datatype(real) => {
Expand Down Expand Up @@ -2081,7 +2070,7 @@ pub mod test {

#[test]
fn family() {
let ont_s = include_str!("../../ont/owl-xml/family.owx");
let ont_s = include_str!("../../ont/owl-xml/manual/family.owx");
let (_, _) = read_ok(&mut ont_s.as_bytes());
}
}
4 changes: 2 additions & 2 deletions src/io/owx/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ mod test {

#[test]
fn round_one_comment() {
assert_round(include_str!("../../ont/owl-xml/one-comment.owx"));
assert_round(include_str!("../../ont/owl-xml/comment.owx"));
}

#[test]
Expand Down Expand Up @@ -1483,6 +1483,6 @@ mod test {

#[test]
fn family() {
assert_round(include_str!("../../ont/owl-xml/family.owx"));
assert_round(include_str!("../../ont/owl-xml/manual/family.owx"));
}
}
22 changes: 11 additions & 11 deletions src/io/rdf/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,13 @@ impl<'a, A: ForIRI, AA: ForIndex<A>> OntologyParser<'a, A, AA> {
}
}
[[_, Term::OWL(VOWL::UnionOf), Term::BNode(bnodeid)],//: rustfmt hard line!
[_, Term::RDF(VRDF::Type), Term::RDFS(VRDFS::Datatype)]] =>
[_, Term::RDF(VRDF::Type), Term::RDFS(VRDFS::Datatype)]] =>
{
ok_some! {
DataRange::DataUnionOf(
self.fetch_dr_seq(bnodeid)?
)
}
ok_some! {
DataRange::DataUnionOf(
self.fetch_dr_seq(bnodeid)?
)
}
}
[[_, Term::OWL(VOWL::DatatypeComplementOf), term],//:
[_, Term::RDF(VRDF::Type), Term::RDFS(VRDFS::Datatype)]] =>
Expand Down Expand Up @@ -2071,8 +2071,8 @@ mod test {
}

#[test]
fn one_subclass() {
compare("one-subclass");
fn subclass() {
compare("subclass");
}

#[test]
Expand Down Expand Up @@ -2189,7 +2189,7 @@ mod test {
// comment a language and a datatype ("PlainLiteral") while
// the RDF one gives it just the language, as literals can't
// be both. Which is correct?
compare("one-comment");
compare("comment");
}

#[test]
Expand All @@ -2201,7 +2201,7 @@ mod test {
fn broken_ontology_annotation () {
// Some verisons of the OWL API do not include an
// AnnotationProperty declaration. We should make this work.
let ont:SetOntology<_> = read_ok(&mut slurp_rdfont("broken-ontology-annotation").as_bytes()).into();
let ont:SetOntology<_> = read_ok(&mut slurp_rdfont("manual/broken-ontology-annotation").as_bytes()).into();
let ont:ComponentMappedOntology<_, RcAnnotatedComponent> = ont.into();
assert_eq!(ont.i().ontology_annotation().count(), 1);
assert_eq!(ont.i().declare_annotation_property().count(), 0);
Expand Down Expand Up @@ -2570,7 +2570,7 @@ mod test {

#[test]
fn family_other() {
compare("family-other")
compare("manual/family-other")
}

#[test]
Expand Down
4 changes: 2 additions & 2 deletions src/io/rdf/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1689,8 +1689,8 @@ mod test {
}

#[test]
fn round_one_comment() {
assert_round(include_str!("../../ont/owl-rdf/one-comment.owl"));
fn round_comment() {
assert_round(include_str!("../../ont/owl-rdf/comment.owl"));
}

#[test]
Expand Down
14 changes: 14 additions & 0 deletions src/ont/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
all:
$(MAKE) -C bubo

all-and-test:
$(MAKE) -C bubo
cargo test

clean: $(MAKE) -C bubo clean

force-clean:
-rm owl-xml/*owx
-rm owl-rdf/*owl
-rm owl-ttl/*ttl
-rm owl-functional/*ofn
19 changes: 19 additions & 0 deletions src/ont/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
These are a series of test files in various OWL syntaxes.

The files in all the owl-* directories are auto-generated from the
bubo directory using the Tawny Bubo
(https://github.com/phillord/tawny-bubo) with associated .clj files
defining the ontology.

To regenerate all files use "make" in either this directory or the
bubo directory.

Autogenerated files are added to the git repository for simplicity.


There are a number of additional files in the directory `manual` which have been
generated in other ways. Most of these are by hand, when a test needs
to be broken or where the OWL API will not generate the file.

Finally, `family` and `family-other` are generated by
https://github.com/phillord/owl-primer.
1 change: 0 additions & 1 deletion src/ont/bubo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ clean:
-rm $(TARGETS)

.PHONY: all clean

11 changes: 11 additions & 0 deletions src/ont/bubo/annotation-domain.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(clojure.core/load-file "ontology.clj")

(defaproperty a)

(add-axiom
o
(.getOWLAnnotationPropertyDomainAxiom
(owl-data-factory)
a (iri "http://www.example.com/d")))

(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/annotation-on-transitive.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defoproperty t
:characteristic [(annotate :transitive (label "Annotation on transitive"))])


(save-all)
11 changes: 11 additions & 0 deletions src/ont/bubo/annotation-range.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(clojure.core/load-file "ontology.clj")

(defaproperty a)

(add-axiom
o
(.getOWLAnnotationPropertyRangeAxiom
(owl-data-factory)
a (iri "http://www.example.com/d")))

(save-all)
8 changes: 8 additions & 0 deletions src/ont/bubo/class-assertion.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(cc/load-file "ontology.clj")


(defclass A)
(defindividual I :type A)


(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/comment.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defclass A
:comment "A comment")


(save-all)
12 changes: 12 additions & 0 deletions src/ont/bubo/data-exact-cardinality.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(cc/load-file "ontology.clj")

(defdproperty d)
(defclass C
:super
(.getOWLDataExactCardinality
(owl-data-factory)
1
(#'tawny.owl/ensure-data-property d)
(#'tawny.owl/ensure-data-range (iri "http://www.w3.org/2001/XMLSchema#integer"))))

(save-all)
9 changes: 9 additions & 0 deletions src/ont/bubo/data-has-key.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(clojure.core/load-file "ontology.clj")

(defdproperty dp)


(defclass C
:haskey dp)

(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/data-has-value.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defdproperty d)
(defclass C
:super (has-value d "A Literal"))

(save-all)
12 changes: 12 additions & 0 deletions src/ont/bubo/data-max-cardinality.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(cc/load-file "ontology.clj")

(defdproperty d)
(defclass C
:super
(.getOWLDataMaxCardinality
(owl-data-factory)
1
(#'tawny.owl/ensure-data-property d)
(#'tawny.owl/ensure-data-range (iri "http://www.w3.org/2001/XMLSchema#integer"))))

(save-all)
12 changes: 12 additions & 0 deletions src/ont/bubo/data-min-cardinality.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(cc/load-file "ontology.clj")

(defdproperty d)
(defclass C
:super
(.getOWLDataMinCardinality
(owl-data-factory)
1
(#'tawny.owl/ensure-data-property d)
(#'tawny.owl/ensure-data-range (iri "http://www.w3.org/2001/XMLSchema#integer"))))

(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/data-only.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defdproperty d)
(defclass C
:super (only d (iri "http://www.w3.org/2001/XMLSchema#integer")))

(save-all)
8 changes: 8 additions & 0 deletions src/ont/bubo/data-property-assertion.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(cc/load-file "ontology.clj")

(defdproperty dp)

(defindividual I
:fact (fact dp "A literal"))

(save-all)
6 changes: 6 additions & 0 deletions src/ont/bubo/data-property-disjoint.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(cc/load-file "ontology.clj")

(defdproperty dp)
(defdproperty dp1 :disjoint dp)

(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/data-property-domain.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defclass C)
(defdproperty dp
:domain C)

(save-all)
6 changes: 6 additions & 0 deletions src/ont/bubo/data-property-equivalent.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(cc/load-file "ontology.clj")

(defdproperty dp)
(defdproperty dp1 :equivalent dp)

(save-all)
6 changes: 6 additions & 0 deletions src/ont/bubo/data-property-functional.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(cc/load-file "ontology.clj")

(defdproperty dp
:characteristic :functional)

(save-all)
6 changes: 6 additions & 0 deletions src/ont/bubo/data-property-range.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(cc/load-file "ontology.clj")

(defdproperty dp
:range (iri "http://www.w3.org/2001/XMLSchema#real"))

(save-all)
6 changes: 6 additions & 0 deletions src/ont/bubo/data-property-sub.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(cc/load-file "ontology.clj")

(defdproperty dp)
(defdproperty dp1 :super dp)

(save-all)
5 changes: 5 additions & 0 deletions src/ont/bubo/data-property.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(cc/load-file "ontology.clj")

(defdproperty c)

(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/data-some.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defdproperty d)
(defclass C
:super (some d (iri "http://www.w3.org/2001/XMLSchema#integer")))

(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/data-unqualified-exact.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defdproperty d)
(defclass C
:super (data-exactly 1 d))

(save-all)
6 changes: 6 additions & 0 deletions src/ont/bubo/datatype-alias.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(cc/load-file "ontology.clj")

(defdatatype D
:equivalent (iri "http://www.w3.org/2002/07/owl#real"))

(save-all)
7 changes: 7 additions & 0 deletions src/ont/bubo/datatype-complement.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(cc/load-file "ontology.clj")

(defdatatype D
:equivalent (data-not
(iri "http://www.w3.org/2002/07/owl#rational")))

(save-all)
Loading

0 comments on commit 25fa218

Please sign in to comment.