Skip to content
Open
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
132 changes: 108 additions & 24 deletions tests/cql/CqlArithmeticFunctionsTest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
name="CqlArithmeticFunctionsTest" reference="https://cql.hl7.org/09-b-cqlreference.html#arithmetic-operators-4" version="1.0">
<capability code="arithmetic-operators"/>
<capability code="decimal-precision-and-scale" value="28,8"/>
<!--
These operator tests
#exp
#ln
#minimum
#maximum
#predecessor
#successor
now have <output> set to null per https://cql.hl7.org/09-b-cqlreference.html.
-->
<group name="Abs" version="1.0">
<capability code="arithmetic-operators"/>
<test name="AbsNull" version="1.0">
Expand Down Expand Up @@ -35,6 +45,16 @@
<expression>Abs(-1L)</expression>
<output>1L</output>
</test>
<test name="AbsMinIntegerOverflow" version="1.0">
<!-- Abs(minimum Integer) cannot be represented; result is null per https://cql.hl7.org/09-b-cqlreference.html#abs -->
<expression>Abs(minimum Integer)</expression>
<output>null</output>
</test>
<test name="AbsMinLongOverflow" version="1.5">
<capability code="system.long"/>
<expression>Abs(minimum Long)</expression>
<output>null</output>
</test>
</group>
<group name="Add" version="1.0">
<capability code="arithmetic-operators"/>
Expand Down Expand Up @@ -69,6 +89,21 @@
<expression>1L + 1L</expression>
<output>2L</output>
</test>
<test name="AddIntegerOverflow" version="1.0">
<!-- arithmetic overflow yields null per https://cql.hl7.org/09-b-cqlreference.html#add -->
<expression>(maximum Integer) + 1</expression>
<output>null</output>
</test>
<test name="AddLongAndInteger" version="1.5">
<capability code="system.long"/>
<expression>25L + 5</expression>
<output>30L</output>
</test>
<test name="AddQuantityInvalidDimension" version="1.0">
<capability code="ucum-unit-conversion-support"/>
<expression>5.5'cm' + 2'cm2'</expression>
<output>null</output>
</test>
</group>
<group name="Ceiling" version="1.0">
<capability code="precision-operators-for-decimal-and-date-time-types"/>
Expand Down Expand Up @@ -113,8 +148,8 @@
<output>null</output>
</test>
<test name="CeilingIntegerGreaterThanMaxInteger" version="1.0">
<expression invalid="syntax">Ceiling(2147483648)</expression>
<output>null</output>
<!-- 2147483648 exceeds maximum Integer (2^31-1); an out-of-range Integer literal is a translation (semantic) error -->
<expression invalid="semantic">Ceiling(2147483648)</expression>
</test>
<test name="CeilingDecimalGreaterThanMaxInteger" version="1.0">
<expression>Ceiling(2147483648.2)</expression>
Expand All @@ -133,8 +168,8 @@
<output>-2147483648</output>
</test>
<test name="CeilingIntegerLessThanMinInteger" version="1.0">
<expression invalid="syntax">Ceiling(-2147483649)</expression>
<output>null</output>
<!-- -2147483649 is below minimum Integer (-2^31); an out-of-range Integer literal is a translation (semantic) error -->
<expression invalid="semantic">Ceiling(-2147483649)</expression>
</test>
<test name="CeilingDecimalLessThanMinInteger" version="1.0">
<expression>Ceiling(-2147483649.2)</expression>
Expand Down Expand Up @@ -207,6 +242,12 @@
<expression>10.0 'g' / 5</expression>
<output>2.0'g'</output>
</test>
<test name="DivideQuantityByZero" version="1.0">
<!-- right argument 0 yields null per https://cql.hl7.org/09-b-cqlreference.html#divide -->
<capability code="ucum-unit-conversion-support"/>
<expression>5.0 'g' / 0</expression>
<output>null</output>
</test>
</group>
<group name="Floor" version="1.0">
<capability code="precision-operators-for-decimal-and-date-time-types"/>
Expand Down Expand Up @@ -255,8 +296,8 @@
<output>2147483647</output>
</test>
<test name="FloorIntegerGreaterThanMaxInteger" version="1.0">
<expression>Floor(2147483648)</expression>
<output>null</output>
<!-- 2147483648 exceeds maximum Integer (2^31-1); an out-of-range Integer literal is a translation (semantic) error -->
<expression invalid="semantic">Floor(2147483648)</expression>
</test>
<test name="FloorDecimalGreaterThanMaxInteger" version="1.0">
<expression>Floor(2147483648.2)</expression>
Expand All @@ -275,8 +316,8 @@
<output>null</output>
</test>
<test name="FloorIntegerLessThanMinInteger" version="1.0">
<expression>Floor(-2147483649)</expression>
<output>null</output>
<!-- -2147483649 is below minimum Integer (-2^31); an out-of-range Integer literal is a translation (semantic) error -->
<expression invalid="semantic">Floor(-2147483649)</expression>
</test>
<test name="FloorDecimalLessThanMinInteger" version="1.0">
<expression>Floor(-2147483649.2)</expression>
Expand Down Expand Up @@ -314,12 +355,13 @@
<output>0.36787944</output>
</test>
<test name="Exp1000" version="1.0">
<expression invalid="true">Exp(1000)</expression>
<!-- EXPECT: Results in positive infinity -->
<!-- Result cannot be represented (overflow); result is null per https://cql.hl7.org/09-b-cqlreference.html#exp -->
<expression>Exp(1000)</expression>
<output>null</output>
</test>
<test name="Exp1000D" version="1.0">
<expression invalid="true">Exp(1000.0)</expression>
<!-- EXPECT: Results in positive infinity -->
<expression>Exp(1000.0)</expression>
<output>null</output>
</test>
</group>
<group name="HighBoundary" version="1.0">
Expand Down Expand Up @@ -425,12 +467,13 @@
<output>null</output>
</test>
<test name="Ln0" version="1.4">
<expression invalid="true">Ln(0)</expression>
<!-- EXPECT: Results in negative infinity -->
<!-- Result cannot be represented (overflow); result is null per https://cql.hl7.org/09-b-cqlreference.html#ln -->
<expression>Ln(0)</expression>
<output>null</output>
</test>
<test name="LnNeg0" version="1.4">
<expression invalid="true">Ln(-0)</expression>
<!-- EXPECT: Results in negative infinity -->
<expression>Ln(-0)</expression>
<output>null</output>
</test>
<test name="Ln1" version="1.4">
<expression>Ln(1)</expression>
Expand Down Expand Up @@ -621,6 +664,11 @@
<output>2.0'cm2'</output>
<!-- TODO: make the units multiply -->
</test>
<test name="MultiplyIntegerOverflow" version="1.0">
<!-- arithmetic overflow yields null per https://cql.hl7.org/09-b-cqlreference.html#multiply -->
<expression>(maximum Integer) * 2</expression>
<output>null</output>
</test>
</group>
<group name="Negate" version="1.0">
<capability code="arithmetic-operators"/>
Expand Down Expand Up @@ -680,6 +728,16 @@
<expression>-(1'cm')</expression>
<output>-1.0'cm'</output>
</test>
<test name="NegateMinIntegerOverflow" version="1.0">
<!-- -(minimum Integer) cannot be represented; result is null per https://cql.hl7.org/09-b-cqlreference.html#negate -->
<expression>-(minimum Integer)</expression>
<output>null</output>
</test>
<test name="NegateMinLongOverflow" version="1.5">
<capability code="system.long"/>
<expression>-(minimum Long)</expression>
<output>null</output>
</test>
</group>
<group name="Precision" version="1.4">
<capability code="precision-operators-for-decimal-and-date-time-types"/>
Expand All @@ -704,6 +762,10 @@
<expression>Precision(@T10:30:00.000)</expression>
<output>9</output>
</test>
<test name="PrecisionNull" version="1.4">
<expression>Precision(null as Decimal)</expression>
<output>null</output>
</test>
</group>
<group name="Predecessor" version="1.0">
<capability code="arithmetic-operators"/>
Expand Down Expand Up @@ -747,12 +809,13 @@
<output>@T11:59:59.999</output>
</test>
<test name="PredecessorUnderflowDt" version="1.0">
<expression invalid="true">predecessor of DateTime(0001, 1, 1, 0, 0, 0, 0)</expression>
<!-- EXPECT: The result of the predecessor operation precedes the minimum value allowed for the type -->
<!-- Underflow yields null per https://cql.hl7.org/09-b-cqlreference.html#predecessor -->
<expression>predecessor of DateTime(0001, 1, 1, 0, 0, 0, 0)</expression>
<output>null</output>
</test>
<test name="PredecessorUnderflowT" version="1.0">
<expression invalid="true">predecessor of @T00:00:00.000</expression>
<!-- EXPECT: The result of the predecessor operation precedes the minimum value allowed for the type -->
<expression>predecessor of @T00:00:00.000</expression>
<output>null</output>
</test>
</group>
<group name="Power" version="1.0">
Expand Down Expand Up @@ -866,6 +929,16 @@
<expression>Round(-1.6)</expression>
<output>-2.0</output>
</test>
<test name="RoundPos2D5" version="1.0">
<!-- traditional rounding: 2.5 rounds away from zero to 3, not banker's 2 -->
<expression>Round(2.5)</expression>
<output>3.0</output>
</test>
<test name="RoundNullPrecision" version="1.0">
<!-- null precision is treated as 0 per https://cql.hl7.org/09-b-cqlreference.html#round -->
<expression>Round(3.14159, null)</expression>
<output>3.0</output>
</test>
</group>
<group name="Subtract" version="1.0">
<capability code="arithmetic-operators"/>
Expand Down Expand Up @@ -895,6 +968,16 @@
<expression>2 - 1.1</expression>
<output>0.9</output>
</test>
<test name="SubtractIntegerOverflow" version="1.0">
<!-- arithmetic overflow yields null per https://cql.hl7.org/09-b-cqlreference.html#subtract -->
<expression>(minimum Integer) - 1</expression>
<output>null</output>
</test>
<test name="SubtractQuantityInvalidDimension" version="1.0">
<capability code="ucum-unit-conversion-support"/>
<expression>3.14 'cm' - 3.12 'cm2'</expression>
<output>null</output>
</test>
</group>
<group name="Successor" version="1.0">
<capability code="arithmetic-operators"/>
Expand Down Expand Up @@ -933,12 +1016,13 @@
<output>@T12:00:00.001</output>
</test>
<test name="SuccessorOverflowDt" version="1.0">
<expression invalid="true">successor of DateTime(9999, 12, 31, 23, 59, 59, 999)</expression>
<!-- EXPECT: The result of the successor operation exceeds the maximum value allowed for the type -->
<!-- Overflow yields null per https://cql.hl7.org/09-b-cqlreference.html#successor -->
<expression>successor of DateTime(9999, 12, 31, 23, 59, 59, 999)</expression>
<output>null</output>
</test>
<test name="SuccessorOverflowT" version="1.0">
<expression invalid="true">successor of @T23:59:59.999</expression>
<!-- EXPECT: The result of the successor operation exceeds the maximum value allowed for the type -->
<expression>successor of @T23:59:59.999</expression>
<output>null</output>
</test>
</group>
<group name="Truncate" version="1.0">
Expand Down
Loading