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

Get Class coverage to 100%. This fixes: #72

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/ts/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ export class Class {
return createIntersectionTypeNode([parentNode, propLiteral]);
} else if (parentNode) {
return parentNode;
} else if (propLiteral.members.length > 0) {
return propLiteral;
} else {
return createTypeLiteralNode([]);
return propLiteral;
}
}

Expand Down Expand Up @@ -245,9 +243,9 @@ export class Class {
createVariableDeclarationList(
[createVariableDeclaration(
this.className(),
/*type=*/undefined,
/*type=*/ undefined,
createObjectLiteral(
enums.map(e => e.toNode()), /*multiLine=*/true))],
enums.map(e => e.toNode()), /*multiLine=*/ true))],
NodeFlags.Const));
}

Expand Down Expand Up @@ -343,7 +341,7 @@ export class BooleanEnum extends Builtin {
createVariableDeclarationList(
[createVariableDeclaration(
this.subject.name,
/*type=*/undefined,
/*type=*/ undefined,
createObjectLiteral(
[
createPropertyAssignment(
Expand Down Expand Up @@ -385,14 +383,14 @@ export class DataTypeUnion extends Builtin {
/**
* Defines a Sort order between Class declarations.
*
* DataTypes come first, by the 'DataType' union itself, followed by all regular
* classes. Within each group, class names are ordered alphabetically in UTF-16
* code units order.
* DataTypes come first, next the 'DataType' union itself, followed by all
* regular classes. Within each group, class names are ordered alphabetically in
* UTF-16 code units order.
*/
export function Sort(a: Class, b: Class): number {
if (a instanceof Builtin && !(a instanceof DataTypeUnion)) {
if (b instanceof Builtin && !(b instanceof DataTypeUnion)) {
return a.subject.name.localeCompare(b.subject.name);
return CompareKeys(a.subject, b.subject);
} else {
return -1;
}
Expand All @@ -401,7 +399,8 @@ export function Sort(a: Class, b: Class): number {
} else if (a instanceof DataTypeUnion) {
return b instanceof DataTypeUnion ? 0 : -1;
} else if (b instanceof DataTypeUnion) {
return a instanceof DataTypeUnion ? 0 : +1;
// If we are here, a is never a DataTypeUnion.
return +1;
} else {
return CompareKeys(a.subject, b.subject);
}
Expand Down
Loading