@@ -19,6 +19,7 @@ export class Result implements InternalTestResult {
1919 testVersionTo ?: string ;
2020 invalid : 'false' | 'true' | 'semantic' | 'undefined' ;
2121 expression : string ;
22+ library ?: string ;
2223 capability : CapabilityKV [ ] = [ ] ;
2324
2425 constructor ( testsName : string , groupName : string , test : Test ) {
@@ -28,7 +29,23 @@ export class Result implements InternalTestResult {
2829 this . testVersion = test . version ;
2930 this . testVersionTo = test . versionTo ;
3031
31- if ( typeof test . expression !== 'string' ) {
32+ if ( test . library !== undefined ) {
33+ // Library-style test: the whole CQL library is evaluated inline. The value sent as
34+ // `expression` is the name of the define to evaluate, taken from the output's `name`
35+ // attribute (defaults to 'output').
36+ if ( typeof test . library === 'string' ) {
37+ this . invalid = 'false' ;
38+ this . library = test . library ;
39+ } else {
40+ this . invalid = test . library . invalid ;
41+ this . library = test . library . text ;
42+ }
43+ const out = test . output ;
44+ this . expression =
45+ out !== undefined && typeof out !== 'string' && ! Array . isArray ( out ) && out . name
46+ ? out . name
47+ : 'output' ;
48+ } else if ( typeof test . expression !== 'string' ) {
3249 if ( test . expression === undefined ) {
3350 this . invalid = 'undefined' ;
3451 this . expression = 'undefined' ;
@@ -117,6 +134,14 @@ export function generateParametersResource(
117134 } ,
118135 ] ,
119136 } ;
137+ // Library-style tests: pass the full CQL library inline via the `content` parameter.
138+ // `expression` then names the define within that library to evaluate.
139+ if ( result . library !== undefined ) {
140+ data . parameter ! . push ( {
141+ name : 'content' ,
142+ valueString : result . library ,
143+ } ) ;
144+ }
120145 } else if ( cqlEndpoint === '$evaluate' ) {
121146 data = {
122147 resourceType : 'Parameters' ,
0 commit comments