Skip to content

Merge CQL library-based comparison operator tests into XML-based tests#1398

Merged
JPercival merged 8 commits intomasterfrom
merge-comparison-operator-tests
Sep 13, 2024
Merged

Merge CQL library-based comparison operator tests into XML-based tests#1398
JPercival merged 8 commits intomasterfrom
merge-comparison-operator-tests

Conversation

@antvaset
Copy link
Copy Markdown
Contributor

@antvaset antvaset commented Aug 9, 2024

I copied all the tests from the engine's CqlComparisonOperatorsTest.all_comparison_operators_tests (CQL library-based) to CqlComparisonOperatorsTest.xml (unless the same or equivalent tests were there already) and removed the library-based tests that test the same functionality as the XML tests.

The CqlComparisonOperatorsTest.all_comparison_operators_tests method uses the engine/.../CqlComparisonOperatorsTest.cql library. Note that there are also similar define's in cql-to-elm/.../CqlComparisonOperators.cql and cql-to-elm/.../ComparisonOperators.cql. I went through
all three and added the new tests to CqlComparisonOperatorsTest.xml.

Note also:

  1. I renamed these tests:
define TupleEqDateTimeNull: Tuple { dateId: 12, Date: DateTime(2012, 1, 1) } = Tuple { dateId: 12, Date: DateTime(2012, 1, 1) }

define DateTimeEqNull2: DateTime(2001, 1, 1, null) = DateTime(2001, 1, 1, null, null)

to TupleEqDateTimeTrue2 and DateTimeEqTrue respectively because they both evaluate to true. They come from cql-to-elm/.../CqlComparisonOperators.cql which is only used in cql2elm tests that check translatability and not compare the results of the tests.

  1. These were already in CqlListOperatorsTest.xml:
define ListEqEmptyEmpty : {} = {}

define EquivListEmptyEmpty          : {} ~ {}
define EquivListABCABC              : { 'a', 'b', 'c' } ~ { 'a', 'b', 'c' }
define EquivListABCAB               : { 'a', 'b', 'c' } ~ { 'a', 'b' }
define EquivListABC123              : { 'a', 'b', 'c' } ~ { 1, 2, 3 }
define EquivList123ABC              : { 1, 2, 3 } ~ { 'a', 'b', 'c' }
define EquivList123String123        : { 1, 2, 3 } ~  { '1', '2', '3' }

define ListNotEqEmptyEmpty : {} != {}
define ListNotEqABCABC : { 'a', 'b', 'c' } != { 'a', 'b', 'c' }
define ListNotEqABCAB : { 'a', 'b', 'c' } != { 'a', 'b' }
define ListNotEqABC123: { 'a', 'b', 'c' } != { 1, 2, 3 }
define ListNotEq123ABC: { 1, 2, 3 } != { 'a', 'b', 'c' }
define ListNotEq123String123:  { 1, 2, 3 } != { '1', '2', '3' }
  1. These were missing from CqlListOperatorsTest.xml:
define ListEqABCABC : { 'a', 'b', 'c' } = { 'a', 'b', 'c' }
define ListEqABCAB : { 'a', 'b', 'c' } = { 'a', 'b' }
define ListEqABC123: { 'a', 'b', 'c' } = { 1, 2, 3 }
define ListEq123ABC: { 1, 2, 3 } = { 'a', 'b', 'c' }
define ListEq123String123:  { 1, 2, 3 } = { '1', '2', '3' }
  1. These or equivalent were already in CqlIntervalOperatorsTest.xml:
define IntervalEq1To101To10: Interval[1, 10] = Interval[1, 10]
define IntervalEq1To101To5: Interval[1, 10] = Interval[1, 5]

define EquivInterval1To101To10      : Interval[1, 10] ~ Interval[1, 10]
define EquivInterval1To101To5       : Interval[1, 10] ~ Interval[1, 5]

define IntervalNotEq1To101To10: Interval[1, 10] != Interval[1, 10]
define IntervalNotEq1To101To5: Interval[1, 10] != Interval[1, 5]
  1. These tests were skipped in CqlComparisonOperatorsTest.all_comparison_operators_tests:
define TupleEqJohnJohnFalse: Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' } = Tuple { Id : 1, Name : 'John' }
define TupleEqJohnJohnFalse2: Tuple { Id : 1, Name : 'John' } = Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' }
define EquivTupleJohnJohnFalse            : Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' } ~ Tuple { Id : 1, Name : 'John' }
define EquivTupleJohnJohnFalse2           : Tuple { Id : 1, Name : 'John' } ~ Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' }

but they work as expected (throw a translation error), so I added them to CqlComparisonOperatorsTest.xml.

Now that everything is synced into CqlComparisonOperatorsTest.xml, I could remove engine/.../CqlComparisonOperatorsTest.cql which was only used by the engine's CqlComparisonOperatorsTest. I also removed the cql_comparison_test_suite_compiles test from that class which made sure that the CQL library compiled with no errors. The test used the default options without DisableListDemotion and DisableListPromotion. The same compiler options are used when the XML tests are run (with the addition of EnableDateRangeOptimization which should not affect the translatability of the comparison operator tests in question), so they also test the same translation functionality.

At this stage, we have to keep the other two CQL files because they are currently used in other tests (some cql2elm and cql-formatter tests). In the future, we can generate those CQL files dynamically from the XML content when we run the tests and not have to maintain the files separately?

There are corresponding PRs in the cql-tests repo: cqframework/cql-tests#45 and cqframework/cql-tests#46.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 9, 2024

Formatting check succeeded!

@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.73%. Comparing base (dd98ccc) to head (e905da9).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1398   +/-   ##
=========================================
  Coverage     63.73%   63.73%           
  Complexity     2666     2666           
=========================================
  Files           494      494           
  Lines         27836    27829    -7     
  Branches       5528     5528           
=========================================
- Hits          17741    17737    -4     
+ Misses         7852     7848    -4     
- Partials       2243     2244    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JPercival JPercival merged commit 3f4aacb into master Sep 13, 2024
@JPercival JPercival deleted the merge-comparison-operator-tests branch September 13, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants