Skip to content

Commit

Permalink
Merge CQL library-based comparison operator tests into XML-based tests (
Browse files Browse the repository at this point in the history
#1398)

* Merge CQL library-based comparison operator tests into XML-based tests

* Fix formatting

---------

Co-authored-by: JP <[email protected]>
  • Loading branch information
antvaset and JPercival authored Sep 13, 2024
1 parent 277cfd5 commit 3f4aacb
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 906 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import ca.uhn.fhir.model.primitive.IdDt;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.hl7.fhir.r5.context.IWorkerContext;
import org.hl7.fhir.r5.model.ImplementationGuide;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ define TupleEqJohnJane: Tuple { Id : 1, Name : 'John' } = Tuple { Id : 2, Name :
define TupleEqJohn1John2: Tuple { Id : 1, Name : 'John' } = Tuple { Id : 2, Name : 'John' }
define TupleEqDateTimeTrue: Tuple { dateId: 1, Date: DateTime(2012, 10, 5, 0, 0, 0, 0) } = Tuple { dateId: 1, Date: DateTime(2012, 10, 5, 0, 0, 0, 0) }
define TupleEqDateTimeFalse: Tuple { dateId: 1, Date: DateTime(2012, 10, 5, 0, 0, 0, 0) } = Tuple { dateId: 1, Date: DateTime(2012, 10, 5, 5, 0, 0, 0) }
define TupleEqDateTimeNull: Tuple { dateId: 12, Date: DateTime(2012, 1, 1) } = Tuple { dateId: 12, Date: DateTime(2012, 1, 1) }
define TupleEqDateTimeTrue2: Tuple { dateId: 12, Date: DateTime(2012, 1, 1) } = Tuple { dateId: 12, Date: DateTime(2012, 1, 1) }
define TupleEqTimeTrue: Tuple { timeId: 55, TheTime: @T05:15:15.541 } = Tuple { timeId: 55, TheTime: @T05:15:15.541 }
define TupleEqTimeFalse: Tuple { timeId: 55, TheTime: @T05:15:15.541 } = Tuple { timeId: 55, TheTime: @T05:15:15.540 }
define ListEqEmptyEmpty : {} = {}
Expand All @@ -45,7 +45,7 @@ define DateTimeEqJanJan: DateTime(2014, 1, 5, 5, 0, 0, 0, 0) = DateTime(2014, 1,
define DateTimeEqJanJuly: DateTime(2014, 1, 5, 5, 0, 0, 0, 0) = DateTime(2014, 7, 5, 5, 0, 0, 0, 0)
define DateTimeEqMissingArg: DateTime(2015, 1, 5, 5, 0, 0) = DateTime(2015, 1, 5, 5, 0, 0)
define DateTimeEqNull: DateTime(null) = DateTime(null)
define DateTimeEqNull2: DateTime(2001, 1, 1, null) = DateTime(2001, 1, 1, null, null)
define DateTimeEqTrue: DateTime(2001, 1, 1, null) = DateTime(2001, 1, 1, null, null)
define DateTimeUTC: @2014-01-25T14:30:14.559+01:00 = @2014-01-25T14:30:14.559+01:00
define TimeEq10A10A: @T10:00:00.000 = @T10:00:00.000
define TimeEq10A10P: @T10:00:00.000 = @T22:00:00.000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public static Object[][] dataMethod() {
"cql/CqlIntervalOperatorsTest/Expand/ExpandPer1",
"cql/CqlIntervalOperatorsTest/Expand/ExpandPer2Days",
"cql/CqlIntervalOperatorsTest/Expand/ExpandPerMinute",
"cql/CqlListOperatorsTest/Equal/EqualABCAnd123",
"cql/CqlListOperatorsTest/Equal/Equal123AndABC",
"cql/CqlListOperatorsTest/Equal/Equal123AndString123",
"cql/CqlListOperatorsTest/Equivalent/Equivalent123AndABC",
"cql/CqlListOperatorsTest/Equivalent/Equivalent123AndString123",
"cql/CqlListOperatorsTest/Equivalent/EquivalentABCAnd123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
<expression>1 = 2</expression>
<output>false</output>
</test>
<test name="SimpleEqInt1Int2Long">
<expression>10L = 20L</expression>
<output>false</output>
</test>
<test name="SimpleEqStringAStringA">
<expression>'a' = 'a'</expression>
<output>true</output>
Expand All @@ -60,6 +64,14 @@
<expression>1.0 = 2.0</expression>
<output>false</output>
</test>
<test name="SimpleEqFloat1Float1WithZ">
<expression>1.0 = 1.00</expression>
<output>true</output>
</test>
<test name="SimpleEqFloat1Float1WithPrecisionAndZ">
<expression>1.50 = 1.55</expression>
<output>false</output>
</test>
<test name="SimpleEqFloat1Int1">
<expression>1.0 = 1</expression>
<output>true</output>
Expand All @@ -80,10 +92,26 @@
<expression>2.0'cm' = 2.00'cm'</expression>
<output>true</output>
</test>
<test name="RatioEqual">
<expression>1'cm':2'cm' = 1'cm':2'cm'</expression>
<output>true</output>
</test>
<test name="RatioNotEqual">
<expression>1'cm':2'cm' = 1.1'cm':2'cm'</expression>
<output>false</output>
</test>
<test name="TupleEqJohnJohn">
<expression>Tuple { Id : 1, Name : 'John' } = Tuple { Id : 1, Name : 'John' }</expression>
<output>true</output>
</test>
<test name="TupleEqJohnJohnFalse">
<expression invalid="true">Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' } = Tuple { Id : 1, Name : 'John' }</expression>
<!-- EXPECT: Could not resolve call to operator Equal with signature (tuple{Id:System.Integer,Name:System.String,Position:System.String},tuple{Id:System.Integer,Name:System.String}). -->
</test>
<test name="TupleEqJohnJohnFalse2">
<expression invalid="true">Tuple { Id : 1, Name : 'John' } = Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' }</expression>
<!-- EXPECT: Could not resolve call to operator Equal with signature (tuple{Id:System.Integer,Name:System.String},tuple{Id:System.Integer,Name:System.String,Position:System.String}). -->
</test>
<test name="TupleEqJohnJane">
<expression>Tuple { Id : 1, Name : 'John' } = Tuple { Id : 2, Name : 'Jane' }</expression>
<output>false</output>
Expand All @@ -100,6 +128,10 @@
<expression>Tuple { dateId: 1, Date: DateTime(2012, 10, 5, 0, 0, 0, 0) } = Tuple { dateId: 1, Date: DateTime(2012, 10, 5, 5, 0, 0, 0) }</expression>
<output>false</output>
</test>
<test name="TupleEqDateTimeTrue2">
<expression>Tuple { dateId: 12, Date: DateTime(2012, 1, 1) } = Tuple { dateId: 12, Date: DateTime(2012, 1, 1) }</expression>
<output>true</output>
</test>
<test name="TupleEqTimeTrue">
<expression>Tuple { timeId: 55, TheTime: @T05:15:15.541 } = Tuple { timeId: 55, TheTime: @T05:15:15.541 }</expression>
<output>true</output>
Expand All @@ -124,10 +156,18 @@
<expression>DateTime(2014, 1, 5, 5, 0, 0, 0, 0) = DateTime(2014, 7, 5, 5, 0, 0, 0, 0)</expression>
<output>false</output>
</test>
<test name="DateTimeEqMissingArg">
<expression>DateTime(2015, 1, 5, 5, 0, 0) = DateTime(2015, 1, 5, 5, 0, 0)</expression>
<output>true</output>
</test>
<test name="DateTimeEqNull">
<expression>DateTime(null) = DateTime(null)</expression>
<output>null</output>
</test>
<test name="DateTimeEqTrue">
<expression>DateTime(2001, 1, 1, null) = DateTime(2001, 1, 1, null, null)</expression>
<output>true</output>
</test>
<test name="DateTimeUTC">
<expression>@2014-01-25T14:30:14.559+01:00 = @2014-01-25T14:30:14.559+01:00</expression>
<output>true</output>
Expand All @@ -154,6 +194,10 @@
<expression>0 &gt; 1</expression>
<output>false</output>
</test>
<test name="GreaterLong">
<expression>00L > 10L</expression>
<output>false</output>
</test>
<test name="GreaterZNeg1">
<expression>0 &gt; -1</expression>
<output>true</output>
Expand Down Expand Up @@ -256,6 +300,10 @@
<expression>0 &gt;= 1</expression>
<output>false</output>
</test>
<test name="GreaterOrEqualZ1Long">
<expression>00L &gt;= 10L</expression>
<output>false</output>
</test>
<test name="GreaterOrEqualZNeg1">
<expression>0 &gt;= -1</expression>
<output>true</output>
Expand Down Expand Up @@ -366,6 +414,14 @@
<expression>0 &lt; 1</expression>
<output>true</output>
</test>
<test name="LessLong">
<expression>00L &lt; 10L</expression>
<output>true</output>
</test>
<test name="LessLongNeg">
<expression>-30L &lt; -20L</expression>
<output>true</output>
</test>
<test name="LessZNeg1">
<expression>0 &lt; -1</expression>
<output>false</output>
Expand Down Expand Up @@ -468,6 +524,10 @@
<expression>0 &lt;= 1</expression>
<output>true</output>
</test>
<test name="LessOrEqualZ1Long">
<expression>00L &lt;= 10L</expression>
<output>true</output>
</test>
<test name="LessOrEqualZNeg1">
<expression>0 &lt;= -1</expression>
<output>false</output>
Expand Down Expand Up @@ -614,6 +674,10 @@
<expression>'a' ~ 'b'</expression>
<output>false</output>
</test>
<test name="EquivStringIgnoreCase">
<expression>'Abel' ~ 'abel'</expression>
<output>true</output>
</test>
<test name="EquivFloat1Float1">
<expression>1.0 ~ 1.0</expression>
<output>true</output>
Expand All @@ -622,6 +686,22 @@
<expression>1.0 ~ 2.0</expression>
<output>false</output>
</test>
<test name="EquivFloat1Float1WithZ">
<expression>1.0 ~ 1.00</expression>
<output>true</output>
</test>
<test name="EquivFloat1Float1WithPrecision">
<expression>1.5 ~ 1.55</expression>
<output>true</output>
</test>
<test name="EquivFloat1Float1WithPrecisionAndZ">
<expression>1.50 ~ 1.55</expression>
<output>true</output>
</test>
<test name="EquivFloatTrailingZero">
<expression>1.001 ~ 1.000</expression>
<output>true</output>
</test>
<test name="EquivFloat1Int1">
<expression>1.0 ~ 1</expression>
<output>true</output>
Expand All @@ -638,6 +718,14 @@
<expression>1'cm' ~ 0.01'm'</expression>
<output>true</output>
</test>
<test name="RatioEquivalent">
<expression>1'cm':2'cm' ~ 1'cm':2'cm'</expression>
<output>true</output>
</test>
<test name="RatioNotEquivalent">
<expression>1'cm':2'cm' ~ 1'cm':3'cm'</expression>
<output>false</output>
</test>
<test name="EquivTupleJohnJohn">
<expression>Tuple { Id : 1, Name : 'John' } ~ Tuple { Id : 1, Name : 'John' }</expression>
<output>true</output>
Expand All @@ -646,6 +734,14 @@
<expression>Tuple { Id : 1, Name : 'John', Position: null } ~ Tuple { Id : 1, Name : 'John', Position: null }</expression>
<output>true</output>
</test>
<test name="EquivTupleJohnJohnFalse">
<expression invalid="true">Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' } ~ Tuple { Id : 1, Name : 'John' }</expression>
<!-- EXPECT: Could not resolve call to operator Equivalent with signature (tuple{Id:System.Integer,Name:System.String,Position:System.String},tuple{Id:System.Integer,Name:System.String}). -->
</test>
<test name="EquivTupleJohnJohnFalse2">
<expression invalid="true">Tuple { Id : 1, Name : 'John' } ~ Tuple { Id : 1, Name : 'John', Position: 'Shift Manager' }</expression>
<!-- EXPECT: Could not resolve call to operator Equivalent with signature (tuple{Id:System.Integer,Name:System.String},tuple{Id:System.Integer,Name:System.String,Position:System.String}). -->
</test>
<test name="EquivTupleJohnJane">
<expression>Tuple { Id : 1, Name : 'John' } ~ Tuple { Id : 2, Name : 'Jane' }</expression>
<output>false</output>
Expand Down Expand Up @@ -708,6 +804,10 @@
<expression>1 != 2</expression>
<output>true</output>
</test>
<test name="SimpleNotEqInt1Int2Long">
<expression>10L != 20L</expression>
<output>true</output>
</test>
<test name="SimpleNotEqStringAStringA">
<expression>'a' != 'a'</expression>
<output>false</output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,29 @@
<expression>{} = {}</expression>
<output>true</output>
</test>
<test name="EqualABCAndABC">
<expression>{ 'a', 'b', 'c' } = { 'a', 'b', 'c' }</expression>
<output>true</output>
</test>
<test name="EqualABCAndAB">
<expression>{ 'a', 'b', 'c' } = { 'a', 'b' }</expression>
<output>false</output>
</test>
<test name="EqualABCAnd123">
<expression>{ 'a', 'b', 'c' } = { 1, 2, 3 }</expression>
<output>false</output>
<!-- TODO: make Translator resolve isolated Equivalent operator signatures -->
</test>
<test name="Equal123AndABC">
<expression>{ 1, 2, 3 } = { 'a', 'b', 'c' }</expression>
<output>false</output>
<!-- TODO: make Translator resolve isolated Equivalent operator signatures -->
</test>
<test name="Equal123AndString123">
<expression>{ 1, 2, 3 } = { '1', '2', '3' }</expression>
<output>false</output>
<!-- TODO: make Translator resolve isolated Equivalent operator signatures -->
</test>
<test name="Equal12And123">
<expression>{ 1, 2 } = { 1, 2, 3 }</expression>
<output>false</output>
Expand Down
Loading

0 comments on commit 3f4aacb

Please sign in to comment.