Skip to content
Open
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
6 changes: 6 additions & 0 deletions src/commands/build-cql-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ export class BuildCommand {
testsName = r.testsName;
}

// Library-style tests carry their own complete CQL library and are evaluated inline
// (via the $cql `content` parameter), so they are not wrapped as a define here.
if (r.library !== undefined) {
continue;
}

if (r.invalid !== 'semantic') {
const defineVal = `define "${r.groupName}.${r.testName}": ${r.expression}`;
const key = `${r.testsName}-${r.groupName}-${r.testName}`;
Expand Down
14 changes: 13 additions & 1 deletion src/models/test-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ export interface TestExpression {
invalid: 'false' | 'true' | 'semantic';
}

export interface TestLibrary {
text: string;
invalid: 'false' | 'true' | 'semantic';
}

export interface TestOutput {
text: string;
// For library-style tests, the name of the define whose result this output describes.
name?: string;
type?:
| 'boolean'
| 'code'
Expand All @@ -29,7 +36,9 @@ export interface Test {
mode?: 'strict' | 'loose';
ordered?: boolean;
checkOrderedFunctions?: boolean;
expression: string | TestExpression;
// A test provides EITHER an expression OR a full CQL library (mutually exclusive; see testSchema.xsd).
expression?: string | TestExpression;
library?: string | TestLibrary;
capability: CapabilityKV[];
output?: string | TestOutput | string[] | TestOutput[];
}
Expand Down Expand Up @@ -79,6 +88,9 @@ export interface InternalTestResult {
testVersionTo?: string;
invalid?: 'false' | 'true' | 'semantic' | 'undefined';
expression: string;
// For library-style tests: the full CQL library source that is evaluated inline.
// (For these tests, `expression` holds the name of the define whose result is compared.)
library?: string;
capability?: CapabilityKV[];
SkipMessage?: string;
}
Expand Down
27 changes: 26 additions & 1 deletion src/shared/results-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class Result implements InternalTestResult {
testVersionTo?: string;
invalid: 'false' | 'true' | 'semantic' | 'undefined';
expression: string;
library?: string;
capability: CapabilityKV[] = [];

constructor(testsName: string, groupName: string, test: Test) {
Expand All @@ -28,7 +29,23 @@ export class Result implements InternalTestResult {
this.testVersion = test.version;
this.testVersionTo = test.versionTo;

if (typeof test.expression !== 'string') {
if (test.library !== undefined) {
// Library-style test: the whole CQL library is evaluated inline. The value sent as
// `expression` is the name of the define to evaluate, taken from the output's `name`
// attribute (defaults to 'output').
if (typeof test.library === 'string') {
this.invalid = 'false';
this.library = test.library;
} else {
this.invalid = test.library.invalid;
this.library = test.library.text;
}
const out = test.output;
this.expression =
out !== undefined && typeof out !== 'string' && !Array.isArray(out) && out.name
? out.name
: 'output';
} else if (typeof test.expression !== 'string') {
if (test.expression === undefined) {
this.invalid = 'undefined';
this.expression = 'undefined';
Expand Down Expand Up @@ -117,6 +134,14 @@ export function generateParametersResource(
},
],
};
// Library-style tests: pass the full CQL library inline via the `content` parameter.
// `expression` then names the define within that library to evaluate.
if (result.library !== undefined) {
data.parameter!.push({
name: 'content',
valueString: result.library,
});
}
} else if (cqlEndpoint === '$evaluate') {
data = {
resourceType: 'Parameters',
Expand Down