Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Log Testing #64

Merged
merged 5 commits into from Jan 15, 2020
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Duplicate Comment Logging and Tests.

Made enum duplicate comment handling consistent with properties and
classes. A duplicate comment will now always replace the previously seen
comment.
  • Loading branch information
Eyas committed Jan 15, 2020
commit 60afa0d9ddb09f0fd5118e6b73876f4eeae3976e
@@ -15,6 +15,7 @@
*/
import {createAsExpression, createLiteralTypeNode, createPropertyAssignment, createStringLiteral, createTypeReferenceNode} from 'typescript';

import {Log} from '../logging';
import {ObjectPredicate, TSubject, TTypeName} from '../triples/triple';
import {GetComment, IsClassType, IsDataType} from '../triples/wellKnown';

@@ -60,8 +61,9 @@ export class EnumValue {
const comment = GetComment(value);
if (comment) {
if (this.comment) {
throw new Error(`Attempt to add comment on ${
this.value.toString()} enum but one already exists.`);
Log(`Duplicate comments provided on ${
this.value
.toString()} enum but one already exists. It will be overwritten.`);
}
this.comment = comment.comment;
return true;
@@ -0,0 +1,3 @@
Duplicate comments provided on class http://schema.org/Thing. It will be overwritten.
Duplicate comments provided on property http://schema.org/name. It will be overwritten.
Duplicate comments provided on http://schema.org/Gadget enum but one already exists. It will be overwritten.
@@ -0,0 +1,12 @@
<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/name> <http://www.w3.org/2000/01/rdf-schema#comment> "Simple!" .
<http://schema.org/Thing> <http://www.w3.org/2000/01/rdf-schema#comment> "Simple!" .
<http://schema.org/name> <http://www.w3.org/2000/01/rdf-schema#comment> "Names are great!\n <a href=\"X\">Y</a>"@en .
<http://schema.org/Thing> <http://www.w3.org/2000/01/rdf-schema#comment> "Things are amazing!\n\n<br/><br /><ul><li>Foo</li><li>Bar</li><li><em>Baz</em>, and <strong>Bat</strong></li><ul>"@en .
<http://schema.org/Widget> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Thing> .
<http://schema.org/Gadget> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Thing> .
<http://schema.org/Gadget> <http://www.w3.org/2000/01/rdf-schema#comment> "Simple!" .
<http://schema.org/Gadget> <http://www.w3.org/2000/01/rdf-schema#comment> "Complex!" .
@@ -0,0 +1,22 @@
type ThingBase = {
/** IRI identifying the canonical address of this object. */
"@id"?: string;
/** Names are great! {@link X Y} */
"name"?: Text | readonly Text[];
};
/**
* Things are amazing!
*
* - Foo
* - Bar
* - _Baz_, and __Bat__
*/
export type Thing = "http://schema.org/Gadget" | "http://schema.org/Widget" | ({
"@type": "Thing";
} & ThingBase);
export const Thing = {
/** Complex! */
Gadget: ("http://schema.org/Gadget" as const),
Widget: ("http://schema.org/Widget" as const)
};

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.