Skip to content

Commit

Permalink
Change default signature level from None to Overloads (#1481)
Browse files Browse the repository at this point in the history
* Change default signature level from None to Overloads

* Fix tests

* Remove potential thrown exception from Lambda
  • Loading branch information
JPercival authored Dec 20, 2024
1 parent 12f59f3 commit b9f7ad3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public enum Options {
private boolean enableCqlOnly = false;
private String compatibilityLevel = "1.5";
private CqlCompilerException.ErrorSeverity errorLevel = CqlCompilerException.ErrorSeverity.Info;
private LibraryBuilder.SignatureLevel signatureLevel = LibraryBuilder.SignatureLevel.None;
private LibraryBuilder.SignatureLevel signatureLevel = LibraryBuilder.SignatureLevel.Overloads;
private boolean analyzeDataRequirements = false;
private boolean collapseDataRequirements = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"options":["EnableAnnotations","EnableLocators","DisableListDemotion","DisableListPromotion"],"formats":[ "XML"],"validateUnits":true,"verifyOnly":false,"errorLevel":"Info","signatureLevel":"None"}
{"options":["EnableAnnotations","EnableLocators","DisableListDemotion","DisableListPromotion"],"formats":[ "XML"],"validateUnits":true,"verifyOnly":false,"errorLevel":"Info","signatureLevel":"Overloads"}
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,32 @@
class TestFHIRHelpers extends FhirExecutionTestBase {

@Test
void testWithUnambiguousCompilerOptions() {
// Test with non-ambiguous compiler options. Should pass.
void testWithAmbiguousCompilerOptions() {
// This tests the behavior of the engine when the compiler
// options are set to allow ambiguous overloads
// It's expected that the engine will throw an exception
//
// If we update the FHIRHelpers content to not have ambiguous overloads
// the results of this test will change
var compilerOptions = CqlCompilerOptions.defaultOptions();
compilerOptions.setSignatureLevel(LibraryBuilder.SignatureLevel.Overloads);
compilerOptions.setSignatureLevel(LibraryBuilder.SignatureLevel.None);
var modelManager = new ModelManager();
var libraryManager = new LibraryManager(modelManager, compilerOptions);
libraryManager.getLibrarySourceLoader().clearProviders();
libraryManager.getLibrarySourceLoader().registerProvider(new FhirLibrarySourceProvider());
libraryManager.getLibrarySourceLoader().registerProvider(new TestLibrarySourceProvider());

var engine = new CqlEngine(new Environment(libraryManager));
engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider);
var badOptionsEngine = new CqlEngine(new Environment(libraryManager));
badOptionsEngine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider);

runTest(engine);
var identifier = library.getIdentifier();
assertThrows(CqlException.class, () -> badOptionsEngine.evaluate(identifier));
}

@Test
void standardCompilerOptions() {
// Test with standard compiler options. Should throw an Exception as of the
// time this test is written because the default compiler options produce
// ambiguous ELM output. This test is intended to fail, and if we change the
// compiler options to be non-ambiguous, this test should be updated to expect
// a different (presumably passing) result.
void testFhirHelpers() {
var engine = getEngine();
engine.getEnvironment().registerDataProvider("http://hl7.org/fhir", r4Provider);
assertThrows(CqlException.class, () -> runTest(engine));
}

void runTest(CqlEngine engine) {
var results = engine.evaluate(library.getIdentifier());

// Primitives
Expand Down

0 comments on commit b9f7ad3

Please sign in to comment.