Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default signature level from None to Overloads #1481

Merged
merged 5 commits into from
Dec 20, 2024
Merged
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
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
Loading