Skip to content

Commit 5248484

Browse files
committed
Use explicit test type checks.
Avoid problem with possibly skipping checks for unknown test types.
1 parent facb233 commit 5248484

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

tests/test-common.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -437,15 +437,20 @@ function addTest(manifest, test, tests) {
437437
}
438438

439439
try {
440-
if(isNegativeTest(test)) {
440+
if(isJsonLdType(test, 'jld:NegativeEvaluationTest')) {
441441
await compareExpectedError(test, err);
442-
} else if(isPositiveTest(test)) {
442+
} else if(isJsonLdType(test, 'jld:PositiveEvaluationTest')) {
443443
if(err) {
444444
throw err;
445445
}
446446
await testInfo.compare(test, result);
447+
} else if(isJsonLdType(test, 'jld:PositiveSyntaxTest') ||
448+
isJsonLdType(test, 'rdfn:Urgna2012EvalTest') ||
449+
isJsonLdType(test, 'rdfn:Urdna2015EvalTest')) {
450+
// no checks
451+
} else {
452+
throw Error('Unknown test type: ' + test.type);
447453
}
448-
// fallthrough without checks for PositiveSyntaxTest and others
449454

450455
if(options.benchmark) {
451456
// pre-load params to avoid doc loader and parser timing
@@ -502,14 +507,6 @@ function addTest(manifest, test, tests) {
502507
}
503508
}
504509

505-
function isPositiveTest(test) {
506-
return isJsonLdType(test, 'jld:PositiveEvaluationTest');
507-
}
508-
509-
function isNegativeTest(test) {
510-
return isJsonLdType(test, 'jld:NegativeEvaluationTest');
511-
}
512-
513510
function getJsonLdTestType(test) {
514511
const types = Object.keys(TEST_TYPES);
515512
for(let i = 0; i < types.length; ++i) {

0 commit comments

Comments
 (0)