-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from Eyas/datatype-rationalize
Rationalize DataTypes and Fix PronounceableText
- Loading branch information
Showing
8 changed files
with
203 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/** | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* @fileoverview Baseline tests are a set of tests (in tests/baseline/) that | ||
* correspond to full comparisons of a generate .ts output based on a set of | ||
* Triples representing an entire ontology. | ||
*/ | ||
import {basename} from 'path'; | ||
|
||
import {inlineCli} from '../helpers/main_driver'; | ||
|
||
test(`baseine_${basename(__filename)}`, async () => { | ||
const {actual} = await inlineCli( | ||
` | ||
<http://schema.org/name> <http://schema.org/rangeIncludes> <http://schema.org/Text> . | ||
<http://schema.org/name> <http://schema.org/domainIncludes> <http://schema.org/Thing> . | ||
<http://schema.org/name> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://schema.org/Thing> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/Text> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/DataType> . | ||
<http://schema.org/Text> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/URL> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/URL> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Text> . | ||
<http://schema.org/FancyURL> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/FancyURL> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/URL> . | ||
<http://schema.org/PronounceableText> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/PronounceableText> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/Text> . | ||
<http://schema.org/phoneticText> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://schema.org/phoneticText> <http://schema.org/domainIncludes> <http://schema.org/PronounceableText> . | ||
<http://schema.org/phoneticText> <http://schema.org/rangeIncludes> <http://schema.org/Text> . | ||
<http://schema.org/ArabicText> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/ArabicText> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/PronounceableText> . | ||
<http://schema.org/arabicPhoneticText> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://schema.org/arabicPhoneticText> <http://schema.org/domainIncludes> <http://schema.org/ArabicText> . | ||
<http://schema.org/arabicPhoneticText> <http://schema.org/rangeIncludes> <http://schema.org/Text> . | ||
<http://schema.org/EnglishText> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2000/01/rdf-schema#Class> . | ||
<http://schema.org/EnglishText> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://schema.org/PronounceableText> . | ||
<http://schema.org/website> <http://schema.org/rangeIncludes> <http://schema.org/URL> . | ||
<http://schema.org/website> <http://schema.org/domainIncludes> <http://schema.org/Thing> . | ||
<http://schema.org/website> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
<http://schema.org/pronunciation> <http://schema.org/rangeIncludes> <http://schema.org/PronounceableText> . | ||
<http://schema.org/pronunciation> <http://schema.org/domainIncludes> <http://schema.org/Thing> . | ||
<http://schema.org/pronunciation> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> . | ||
`, | ||
['--ontology', `https://fake.com/${basename(__filename)}.nt`] | ||
); | ||
|
||
expect(actual).toMatchInlineSnapshot(` | ||
"/** Used at the top-level node to indicate the context for the JSON-LD objects used. The context provided in this type is compatible with the keys and URLs in the rest of this generated file. */ | ||
export type WithContext<T extends Thing> = T & { | ||
\\"@context\\": \\"https://schema.org\\"; | ||
}; | ||
type SchemaValue<T> = T | readonly T[]; | ||
type IdReference = { | ||
/** IRI identifying the canonical address of this object. */ | ||
\\"@id\\": string; | ||
}; | ||
export type Text = PronounceableText | URL | string; | ||
type ArabicTextBase = PronounceableTextBase & { | ||
\\"arabicPhoneticText\\"?: SchemaValue<Text>; | ||
}; | ||
type ArabicTextLeaf = { | ||
\\"@type\\": \\"ArabicText\\"; | ||
} & ArabicTextBase; | ||
export type ArabicText = ArabicTextLeaf | string; | ||
type EnglishTextLeaf = { | ||
\\"@type\\": \\"EnglishText\\"; | ||
} & PronounceableTextBase; | ||
export type EnglishText = EnglishTextLeaf | string; | ||
export type FancyURL = string; | ||
type PronounceableTextBase = Partial<IdReference> & { | ||
\\"phoneticText\\"?: SchemaValue<Text>; | ||
}; | ||
type PronounceableTextLeaf = { | ||
\\"@type\\": \\"PronounceableText\\"; | ||
} & PronounceableTextBase; | ||
export type PronounceableText = PronounceableTextLeaf | ArabicText | EnglishText | string; | ||
type ThingBase = Partial<IdReference> & { | ||
\\"name\\"?: SchemaValue<Text>; | ||
\\"pronunciation\\"?: SchemaValue<PronounceableText | IdReference>; | ||
\\"website\\"?: SchemaValue<URL>; | ||
}; | ||
type ThingLeaf = { | ||
\\"@type\\": \\"Thing\\"; | ||
} & ThingBase; | ||
export type Thing = ThingLeaf; | ||
export type URL = FancyURL | string; | ||
" | ||
`); | ||
}); |
Oops, something went wrong.