Skip to content

Commit

Permalink
test: ignore some lines for coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Oct 5, 2023
1 parent e02f861 commit b5e49e8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
2 changes: 2 additions & 0 deletions src/language/typing/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SdsLiteral,
} from '../generated/ast.js';

/* c8 ignore start */
export abstract class Type {
abstract isNullable: boolean;

Expand Down Expand Up @@ -373,3 +374,4 @@ class NotImplementedTypeClass extends Type {
}

export const NotImplementedType = new NotImplementedTypeClass();
/* c8 ignore stop */
40 changes: 21 additions & 19 deletions src/language/typing/safe-ds-type-computer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,15 @@ export class SafeDsTypeComputer {
return this.computeTypeOfType(node);
} else if (isSdsTypeProjection(node)) {
return this.computeTypeOfType(node.type);
}

/* c8 skip next */
return UnknownType;
} /* c8 ignore start */ else {
return UnknownType;
} /* c8 ignore stop */
}

private computeTypeOfAssignee(node: SdsAssignee): Type {
const containingAssignment = getContainerOfType(node, isSdsAssignment);
if (!containingAssignment) {
/* c8 skip next */
/* c8 ignore next 2 */
return UnknownType;
}

Expand Down Expand Up @@ -179,10 +178,9 @@ export class SafeDsTypeComputer {
return this.computeType(node.type);
} else if (isSdsSegment(node)) {
return this.computeTypeOfCallableWithManifestTypes(node);
}

/* c8 skip next */
return UnknownType;
} /* c8 ignore start */ else {
return UnknownType;
} /* c8 ignore stop */
}

private computeTypeOfCallableWithManifestTypes(node: SdsFunction | SdsSegment | SdsCallableType): Type {
Expand Down Expand Up @@ -216,6 +214,7 @@ export class SafeDsTypeComputer {
const containerOfLambda = containingCallable.$container;

// Lambda passed as argument
/* c8 ignore start */
if (isSdsArgument(containerOfLambda)) {
// val containerType = when (val container = callable.eContainer()) {
// is SdsArgument -> container.parameterOrNull()?.inferType(context)
Expand All @@ -228,6 +227,7 @@ export class SafeDsTypeComputer {

return NotImplementedType;
}
/* c8 ignore stop */

// Yielded lambda
else if (isSdsAssignment(containerOfLambda)) {
Expand Down Expand Up @@ -338,10 +338,9 @@ export class SafeDsTypeComputer {
}
} else if (isSdsReference(node)) {
return this.computeTypeOfReference(node);
}

/* c8 skip next */
return UnknownType;
} /* c8 ignore start */ else {
return UnknownType;
} /* c8 ignore stop */
}

private computeTypeOfCall(node: SdsCall): Type {
Expand Down Expand Up @@ -377,6 +376,7 @@ export class SafeDsTypeComputer {
private computeTypeOfElvisOperation(node: SdsInfixOperation): Type {
const leftOperandType = this.computeType(node.leftOperand);
if (leftOperandType.isNullable) {
/* c8 ignore next 3 */
const rightOperandType = this.computeType(node.rightOperand);
return this.lowestCommonSupertype(leftOperandType.copyWithNullability(false), rightOperandType);
} else {
Expand Down Expand Up @@ -409,6 +409,7 @@ export class SafeDsTypeComputer {
if (isSdsCallableType(node)) {
return this.computeTypeOfCallableWithManifestTypes(node);
} else if (isSdsLiteralType(node)) {
/* c8 ignore next */
return NotImplementedType;
} else if (isSdsMemberType(node)) {
return this.computeType(node.member);
Expand All @@ -417,19 +418,20 @@ export class SafeDsTypeComputer {
} else if (isSdsUnionType(node)) {
const typeArguments = typeArgumentsOrEmpty(node.typeArgumentList);
return new UnionType(typeArguments.map((typeArgument) => this.computeType(typeArgument.value)));
}

/* c8 skip next */
return UnknownType;
} /* c8 ignore start */ else {
return UnknownType;
} /* c8 ignore stop */
}

// -----------------------------------------------------------------------------------------------------------------
// Helpers
// -----------------------------------------------------------------------------------------------------------------

/* c8 ignore start */
private lowestCommonSupertype(..._types: Type[]): Type {
return NotImplementedType;
}
/* c8 ignore stop */

// private fun lowestCommonSupertype(context: EObject, types: List<Type>): Type {
// if (types.isEmpty()) {
Expand Down Expand Up @@ -535,8 +537,8 @@ export class SafeDsTypeComputer {
private createCoreType(coreClass: SdsClass | undefined, isNullable: boolean = false): Type {
if (coreClass) {
return new ClassType(coreClass, isNullable);
} else {
} /* c8 ignore start */ else {
return UnknownType;
}
} /* c8 ignore stop */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ segment mySegment() {
»(p) {
yield r, yield s = 1;
}«;

// $TEST$ serialization (p: $Unknown) -> (r: Int, s: $Unknown)
val f = »(p) {
yield r, yield s = 1;
}«;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ package tests.typing.expressions.expressionLambdas
segment mySegment() {
// $TEST$ serialization (p: $Unknown) -> (result: Int)
»(p) -> 1«;

// $TEST$ serialization (p: $Unknown) -> (result: Int)
val f = »(p) -> 1«;
}

0 comments on commit b5e49e8

Please sign in to comment.