diff --git a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java index a05dde8ae..242301f5f 100644 --- a/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java +++ b/Src/java/engine-fhir/src/test/java/org/hl7/fhirpath/CQLOperationsR4Test.java @@ -84,7 +84,6 @@ public static Object[][] dataMethod() { "cql/CqlComparisonOperatorsTest/Less Or Equal/LessOrEqualM1CM1", "cql/CqlComparisonOperatorsTest/Less Or Equal/LessOrEqualM1CM10", "cql/CqlComparisonOperatorsTest/Not Equal/QuantityNotEqCM1M01", - "cql/CqlDateTimeOperatorsTest/DateTimeComponentFrom/DateTimeComponentFromTimezone", "cql/CqlDateTimeOperatorsTest/Duration/DateTimeDurationBetweenYear", "cql/CqlDateTimeOperatorsTest/Uncertainty tests/DateTimeDurationBetweenUncertainAdd", "cql/CqlDateTimeOperatorsTest/Uncertainty tests/DateTimeDurationBetweenUncertainInterval", @@ -93,7 +92,6 @@ public static Object[][] dataMethod() { "cql/CqlDateTimeOperatorsTest/Uncertainty tests/DateTimeDurationBetweenUncertainSubtract", "cql/CqlDateTimeOperatorsTest/Uncertainty tests/DurationInDaysA", "cql/CqlDateTimeOperatorsTest/Uncertainty tests/DurationInDaysAA", - "cql/CqlDateTimeOperatorsTest/Uncertainty tests/TimeDurationBetweenHourDiffPrecision", "cql/CqlIntervalOperatorsTest/Intersect/TestIntersectNull", "cql/CqlIntervalOperatorsTest/Intersect/TestIntersectNull1", "cql/CqlIntervalOperatorsTest/Intersect/TestIntersectNull2", diff --git a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlDateTimeOperatorsTest.xml b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlDateTimeOperatorsTest.xml index 20fccccfc..0d1f016e8 100644 --- a/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlDateTimeOperatorsTest.xml +++ b/Src/java/engine-fhir/src/test/resources/org/hl7/fhirpath/cql/CqlDateTimeOperatorsTest.xml @@ -18,6 +18,14 @@ DateTime(2005, 5, 10) + 10 months @2006-03-10T + + DateTime(2018, 5, 2) + 3 weeks = DateTime(2018, 5, 23) + true + + + DateTime(2018, 5, 23) + 52 weeks = DateTime(2019, 5, 23) + true + DateTime(2005, 5, 10) + 5 days @2005-05-15T @@ -30,6 +38,34 @@ DateTime(2005, 5, 10, 5) + 5 hours @2005-05-10T10 + + DateTime(2005, 5, 10, 5, 20, 30) + 5 hours + @2005-05-10T10:20:30 + + + DateTime(2005, 5, 10) + 5 hours = DateTime(2005, 5, 10) + true + + + DateTime(2005, 5, 10) + 25 hours = DateTime(2005, 5, 11) + true + + + Date(2014) + 24 months + @2016 + + + Date(2014) + 25 months + @2016 + + + Date(2014,6) + 33 days + @2014-07 + + + Date(2014,6) + 1 year + @2015-06 + DateTime(2016, 6, 10, 5) + 19 hours @2016-06-11T00 @@ -377,9 +413,12 @@ 955 - timezone from DateTime(2003, 10, 29, 20, 50, 33, 955, 1) + timezone from DateTime(2003, 10, 29, 20, 50, 33, 955, 1) + + + + timezoneoffset from DateTime(2003, 10, 29, 20, 50, 33, 955, 1) 1.00 - date from DateTime(2003, 10, 29, 20, 50, 33, 955, 1) @@ -670,9 +709,12 @@ 2 - hours between @T06Z and @T07:00:00Z + hours between @T06Z and @T07:00:00Z + + + + hours between @T06 and @T07:00:00 1 - minutes between @T23:20:16.555 and @T23:25:15.555 @@ -1141,6 +1183,14 @@ DateTime(2005, 5, 10) - 6 months @2004-11-10T + + DateTime(2018, 5, 23) - 3 weeks = DateTime(2018, 5, 2) + true + + + DateTime(2018, 5, 23) - 52 weeks = DateTime(2017, 5, 23) + true + DateTime(2005, 5, 10) - 5 days @2005-05-05T @@ -1169,6 +1219,14 @@ DateTime(2005, 5, 10, 5, 5, 10) - 5 seconds @2005-05-10T05:05:05 + + DateTime(2016,5) - 31535999 seconds = DateTime(2015, 5) + true + + + DateTime(2016, 10, 1, 10, 20, 30) - 15 hours + @2016-09-30T19:20:30 + DateTime(2016, 6, 10, 5, 5, 5) - 6 seconds @2016-06-10T05:04:59 @@ -1189,6 +1247,22 @@ DateTime(2014) - 25 months @2012T + + Date(2014) - 24 months + @2012 + + + Date(2014) - 25 months + @2012 + + + Date(2014,6) - 33 days + @2014-05 + + + Date(2014,6) - 1 year + @2013-06 + @T15:59:59.999 - 5 hours @T10:59:59.999 diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.java deleted file mode 100644 index 344246947..000000000 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.opencds.cqf.cql.engine.execution; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.is; - -import java.io.IOException; -import org.hl7.elm.r1.VersionedIdentifier; -import org.junit.jupiter.api.Test; - -@SuppressWarnings("removal") -class CqlConditionalOperatorsTest extends CqlTestBase { - - private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlConditionalOperatorsTest"); - - @Test - void all_conditional_operators_tests() throws IOException { - var value = engine.expression(library, "IfTrue1").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "IfFalse1").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "IfNull1").value(); - assertThat(value, is(10)); - value = engine.expression(library, "StandardCase1").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "StandardCase2").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "StandardCase3").value(); - assertThat(value, is(15)); - } -} diff --git a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java index 8a9b5e3f9..5ecae9edd 100644 --- a/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java +++ b/Src/java/engine/src/test/java/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.java @@ -2,16 +2,13 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.nullValue; import static org.junit.jupiter.api.Assertions.*; -import java.math.BigDecimal; import org.hl7.elm.r1.VersionedIdentifier; import org.junit.jupiter.api.Test; import org.opencds.cqf.cql.engine.elm.executing.AfterEvaluator; import org.opencds.cqf.cql.engine.elm.executing.EquivalentEvaluator; import org.opencds.cqf.cql.engine.exception.CqlException; -import org.opencds.cqf.cql.engine.exception.InvalidDateTime; import org.opencds.cqf.cql.engine.runtime.*; @SuppressWarnings("removal") @@ -19,446 +16,12 @@ class CqlDateTimeOperatorsTest extends CqlTestBase { private static final VersionedIdentifier library = new VersionedIdentifier().withId("CqlDateTimeOperatorsTest"); - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.AddEvaluator#evaluate(Context)} - */ - @Test - void add() { - final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); - - var value = engine.expression(library, "DateTimeAdd5Years").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2010, 10, 10))); - - try { - engine.expression(library, "DateTimeAddInvalidYears").value(); - fail(); - } catch (InvalidDateTime ae) { - // pass - } - - value = engine.expression(library, "DateTimeAdd5Months").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 10, 10))); - - value = engine.expression(library, "DateTimeAddMonthsOverflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2006, 3, 10))); - - value = engine.expression(library, "DateTimeAddThreeWeeks").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2018, 5, 23))); - - value = engine.expression(library, "DateTimeAddYearInWeeks").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2019, 5, 23))); - - value = engine.expression(library, "DateTimeAdd5Days").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 15))); - - value = engine.expression(library, "DateTimeAddDaysOverflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 7, 1))); - - value = engine.expression(library, "DateTimeAdd5Hours").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 10))); - - value = engine.expression(library, "DateTimeAdd5HoursWithLeftMinPrecisionSecond") - .value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 10, 20, 30))); - - value = engine.expression(library, "DateTimeAdd5HoursWithLeftMinPrecisionDay") - .value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10))); - - value = engine.expression(library, "DateTimeAdd5HoursWithLeftMinPrecisionDayOverflow") - .value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 11))); - - value = engine.expression(library, "DateAdd2YearsAsMonths").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2016))); - - value = engine.expression(library, "DateAdd2YearsAsMonthsRem1").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2016))); - - value = engine.expression(library, "DateAdd33Days").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 7))); - - value = engine.expression(library, "DateAdd1Year").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2015, 6))); - - value = engine.expression(library, "DateTimeAddHoursOverflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 11, 0))); - - value = engine.expression(library, "DateTimeAdd5Minutes").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 10))); - - value = engine.expression(library, "DateTimeAddMinutesOverflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 6, 0))); - - value = engine.expression(library, "DateTimeAdd5Seconds").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 10))); - - value = engine.expression(library, "DateTimeAddSecondsOverflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 6, 0))); - - value = engine.expression(library, "DateTimeAdd5Milliseconds").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5, 10))); - - value = engine.expression(library, "DateTimeAddMillisecondsOverflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 5, 6, 0))); - - value = engine.expression(library, "DateTimeAddLeapYear").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2013, 2, 28))); - - value = engine.expression(library, "DateTimeAdd2YearsByMonths").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); - - value = engine.expression(library, "DateTimeAdd2YearsByDays").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); - - value = engine.expression(library, "DateTimeAdd2YearsByDaysRem5Days").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016))); - - value = engine.expression(library, "TimeAdd5Hours").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); - - value = engine.expression(library, "TimeAdd1Minute").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 59, 999))); - - value = engine.expression(library, "TimeAdd1Second").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 999))); - - value = engine.expression(library, "TimeAdd1Millisecond").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 0))); - - value = engine.expression(library, "TimeAdd5Hours1Minute").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(21, 0, 59, 999))); - - // checking access ordering and returning correct result - value = engine.expression(library, "TimeAdd1Second").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(16, 0, 0, 999))); - - value = engine.expression(library, "TimeAdd5hoursByMinute").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(20, 59, 59, 999))); - } - /** * {@link org.opencds.cqf.cql.engine.elm.execution.AfterEvaluator#evaluate(Context)} */ @Test void after() { - final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); - - var value = engine.expression(library, "DateTimeAfterYearTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAfterMonthTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterMonthFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAfterDayTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterDayTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterDayFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAfterHourTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAfterMinuteTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAfterSecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAfterMillisecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeAfterMillisecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAfterUncertain").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeAfterHourTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeAfterHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeAfterMinuteTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeAfterMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeAfterSecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeAfterSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeAfterMillisecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeAfterMillisecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeAfterTimeCstor").value(); - assertThat(value, is(true)); - try { - AfterEvaluator.after(12, "This is an error", null, engine.getState()); - fail(); - } catch (CqlException e) { - // pass - } - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.BeforeEvaluator#evaluate(Context)} - */ - @Test - void before() { - - var value = engine.expression(library, "DateTimeBeforeYearTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeBeforeMonthTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeMonthFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeBeforeDayTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeDayTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeDayFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeBeforeHourTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeBeforeMinuteTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeBeforeSecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeBeforeMillisecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeBeforeMillisecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "BeforeTimezoneTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "BeforeTimezoneFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeBeforeHourTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeBeforeHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeBeforeMinuteTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeBeforeMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeBeforeSecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeBeforeSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeBeforeMillisecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeBeforeMillisecondFalse").value(); - assertThat(value, is(false)); - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.DateTimeEvaluator#evaluate(Context)} - */ - @Test - void dateTime() { - final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); - - var value = engine.expression(library, "DateTimeYear").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003))); - - value = engine.expression(library, "DateTimeMonth").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10))); - - value = engine.expression(library, "DateTimeDay").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29))); - - value = engine.expression(library, "DateTimeHour").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20))); - - value = engine.expression(library, "DateTimeMinute").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50))); - - value = engine.expression(library, "DateTimeSecond").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50, 33))); - - value = engine.expression(library, "DateTimeMillisecond").value(); - assertTrue(EquivalentEvaluator.equivalent( - value, new DateTime(bigDecimalZoneOffset, 2003, 10, 29, 20, 50, 33, 955))); - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.DateTimeComponentFromEvaluator#evaluate(Context)} - */ - @Test - void dateTimeComponentFrom() { - - var value = engine.expression(library, "DateTimeComponentFromYear").value(); - assertThat(value, is(2003)); - - value = engine.expression(library, "DateTimeComponentFromMonth").value(); - assertThat(value, is(10)); - - value = engine.expression(library, "DateTimeComponentFromMonthMinBoundary") - .value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DateTimeComponentFromDay").value(); - assertThat(value, is(29)); - - value = engine.expression(library, "DateTimeComponentFromHour").value(); - assertThat(value, is(20)); - - value = engine.expression(library, "DateTimeComponentFromMinute").value(); - assertThat(value, is(50)); - - value = engine.expression(library, "DateTimeComponentFromSecond").value(); - assertThat(value, is(33)); - - value = engine.expression(library, "DateTimeComponentFromMillisecond").value(); - assertThat(value, is(955)); - - value = engine.expression(library, "DateTimeComponentFromTimezone").value(); - assertThat(value, is(new BigDecimal("1.0"))); - - value = engine.expression(library, "DateTimeComponentFromDate").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2003, 10, 29))); - - value = engine.expression(library, "TimeComponentFromHour").value(); - assertThat(value, is(23)); - - value = engine.expression(library, "TimeComponentFromMinute").value(); - assertThat(value, is(20)); - - value = engine.expression(library, "TimeComponentFromSecond").value(); - assertThat(value, is(15)); - - value = engine.expression(library, "TimeComponentFromMilli").value(); - assertThat(value, is(555)); - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.DifferenceBetweenEvaluator#evaluate(Context)} - */ - @Test - void difference() { - - var value = engine.expression(library, "DateTimeDifferenceYear").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "DateTimeDifferenceMonth").value(); - assertThat(value, is(8)); - - value = engine.expression(library, "DateTimeDifferenceDay").value(); - assertThat(value, is(10)); - - value = engine.expression(library, "DateTimeDifferenceHour").value(); - assertThat(value, is(8)); - - value = engine.expression(library, "DateTimeDifferenceMinute").value(); - assertThat(value, is(9)); - - value = engine.expression(library, "DateTimeDifferenceSecond").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "DateTimeDifferenceMillisecond").value(); - assertThat(value, is(3600400)); - - value = engine.expression(library, "DateTimeDifferenceWeeks").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DateTimeDifferenceWeeks2").value(); - assertThat(value, is(2)); - - value = engine.expression(library, "DateTimeDifferenceWeeks2").value(); - assertThat(value, is(2)); - - value = engine.expression(library, "DateTimeDifferenceNegative").value(); - assertThat(value, is(-18)); - - value = engine.expression(library, "DateTimeDifferenceUncertain").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeDifferenceHour").value(); - assertThat(value, is(3)); - - value = engine.expression(library, "TimeDifferenceMinute").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "TimeDifferenceSecond").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "TimeDifferenceMillis").value(); - assertThat(value, is(-5)); - - value = engine.expression(library, "DifferenceInHoursA").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DifferenceInMinutesA").value(); - assertThat(value, is(45)); - - value = engine.expression(library, "DifferenceInDaysA").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DifferenceInHoursAA").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DifferenceInMinutesAA").value(); - assertThat(value, is(45)); - - value = engine.expression(library, "DifferenceInDaysAA").value(); - assertThat(value, is(1)); + assertThrows(CqlException.class, () -> AfterEvaluator.after(12, "This is an error", null, engine.getState())); } /** @@ -470,25 +33,6 @@ void duration() { var value = engine.expression(library, "DateTimeDurationBetweenYear").value(); assertThat(value, is(5)); - value = engine.expression(library, "DurationInWeeks").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DurationInWeeks2").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DurationInWeeks3").value(); - assertThat(value, is(2)); - - value = engine.expression(library, "DateTimeDurationBetweenYearOffset").value(); - assertThat(value, is(4)); - - value = engine.expression(library, "DateTimeDurationBetweenMonth").value(); - assertThat(value, is(0)); - - value = engine.expression(library, "DateTimeDurationBetweenDaysDiffYears") - .value(); - assertThat(value, is(-788)); - value = engine.expression(library, "DateTimeDurationBetweenUncertainInterval") .value(); assertEquals(17, ((Interval) value).getStart()); @@ -515,76 +59,9 @@ void duration() { assertEquals(289, ((Interval) value).getStart()); assertEquals(1936, ((Interval) value).getEnd()); - try { - value = engine.expression(library, "DateTimeDurationBetweenUncertainDiv") - .value(); - fail(); - } catch (RuntimeException re) { - // pass - } - - value = engine.expression(library, "DateTimeDurationBetweenMonthUncertain") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeDurationBetweenMonthUncertain2") - .value(); - assertThat(value, is(nullValue())); - - value = engine.expression(library, "DateTimeDurationBetweenMonthUncertain3") - .value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeDurationBetweenMonthUncertain4") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeDurationBetweenMonthUncertain5") - .value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeDurationBetweenMonthUncertain6") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeDurationBetweenMonthUncertain7") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DurationInYears").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TimeDurationBetweenHour").value(); - assertThat(value, is(2)); - - value = engine.expression(library, "TimeDurationBetweenHourDiffPrecision") - .value(); - assertThat(value, is(1)); - - value = engine.expression(library, "TimeDurationBetweenMinute").value(); - assertThat(value, is(4)); - - value = engine.expression(library, "TimeDurationBetweenSecond").value(); - assertThat(value, is(4)); - - value = engine.expression(library, "TimeDurationBetweenMillis").value(); - assertThat(value, is(5)); - - value = engine.expression(library, "DurationInHoursA").value(); - assertThat(value, is(1)); - - value = engine.expression(library, "DurationInMinutesA").value(); - assertThat(value, is(45)); - - // value = engine.expression(library, "DurationInDaysA").value(); - // assertThat(value, is(1)); - - value = engine.expression(library, "DurationInHoursAA").value(); + value = engine.expression(library, "DurationInDaysA").value(); assertThat(value, is(1)); - value = engine.expression(library, "DurationInMinutesAA").value(); - assertThat(value, is(45)); - value = engine.expression(library, "DurationInDaysAA").value(); assertThat(value, is(1)); } @@ -594,11 +71,8 @@ void duration() { */ @Test void now() { - var value = engine.expression(library, "DateTimeNow").value(); - assertThat(value, is(true)); - DateTime evaluationDateTime = new DateTime(getBigDecimalZoneOffset(), 2016, 6, 10, 5, 5, 4, 999); - value = engine.expression( + var value = engine.expression( library, "Issue34A", evaluationDateTime.getDateTime().toZonedDateTime()) .value(); assertTrue(EquivalentEvaluator.equivalent(value, evaluationDateTime)); @@ -607,443 +81,6 @@ void now() { evaluationDateTime.getDateTime().getOffset()); } - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.SameAsEvaluator#evaluate(Context)} - */ - @Test - void sameAs() { - - var value = engine.expression(library, "DateTimeSameAsYearTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameAsYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameAsMonthTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameAsMonthFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameAsDayTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameAsDayFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameAsHourTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameAsHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameAsMinuteTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameAsMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameAsSecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameAsSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameAsMillisecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameAsMillisecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameAsNull").value(); - assertThat(value, is(nullValue())); - - value = engine.expression(library, "SameAsTimezoneTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "SameAsTimezoneFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameAsHourTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameAsHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameAsMinuteTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameAsMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameAsSecondTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameAsSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameAsMillisTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameAsMillisFalse").value(); - assertThat(value, is(false)); - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.SameOrAfterEvaluator#evaluate(Context)} - */ - @Test - void sameOrAfter() { - var value = engine.expression(library, "DateTimeSameOrAfterYearTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterYearTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrAfterMonthTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterMonthTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterMonthFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrAfterDayTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterDayTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterDayFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrAfterHourTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterHourTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrAfterMinuteTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterMinuteTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrAfterSecondTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterSecondTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrAfterMillisecondTrue1") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterMillisecondTrue2") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrAfterMillisecondFalse") - .value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrAfterNull1").value(); - assertThat(value, is(nullValue())); - - value = engine.expression(library, "SameOrAfterTimezoneTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "SameOrAfterTimezoneFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameOrAfterHourTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterHourTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameOrAfterMinuteTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterMinuteTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameOrAfterSecondTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterSecondTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "TimeSameOrAfterMillisTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterMillisTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "TimeSameOrAfterMillisFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "OnOrAfterTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "Issue32DateTime").value(); - assertThat(value, is(true)); - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.SameOrBeforeEvaluator#evaluate(Context)} - */ - @Test - void sameOrBefore() { - var value = engine.expression(library, "DateTimeSameOrBeforeYearTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeMonthTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeMonthTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeMonthFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeDayTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeDayTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeDayFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeHourTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeHourTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeHourFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeMinuteTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeMinuteTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeMinuteFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeSecondTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeSecondTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeSecondFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeMillisecondTrue1") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeMillisecondTrue2") - .value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeMillisecondFalse") - .value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeNull1").value(); - assertThat(value, is(nullValue())); - - value = engine.expression(library, "SameOrBeforeTimezoneTrue").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "SameOrBeforeTimezoneFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeYearFalse").value(); - assertThat(value, is(false)); - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.SubtractEvaluator#evaluate(Context)} - */ - @Test - void subtract() { - final BigDecimal bigDecimalZoneOffset = getBigDecimalZoneOffset(); - - var value = engine.expression(library, "DateTimeSubtract5Years").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2000, 10, 10))); - - try { - engine.expression(library, "DateTimeSubtractInvalidYears").value(); - fail(); - } catch (InvalidDateTime ae) { - // pass - } - - value = engine.expression(library, "DateTimeSubtract5Months").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 1, 10))); - - value = engine.expression(library, "DateTimeSubtractMonthsUnderflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2004, 11, 10))); - - value = engine.expression(library, "DateTimeSubtractThreeWeeks").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2018, 5, 2))); - - value = engine.expression(library, "DateTimeSubtractYearInWeeks").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2017, 5, 23))); - - value = engine.expression(library, "DateTimeSubtract5Days").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 5))); - - value = engine.expression(library, "DateTimeSubtractDaysUnderflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 5, 30))); - - value = engine.expression(library, "DateTimeSubtract5Hours").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5))); - - value = engine.expression(library, "DateTimeSubtractHoursUnderflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 9, 23))); - - value = engine.expression(library, "DateTimeSubtract5Minutes").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5))); - - value = engine.expression(library, "DateTimeSubtractMinutesUnderflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 4, 59))); - - value = engine.expression(library, "DateTimeSubtract5Seconds").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5))); - - value = engine.expression(library, "DateTimeSubtract1YearInSeconds").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2015, 5))); - - value = engine.expression(library, "DateTimeSubtract15HourPrecisionSecond") - .value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 9, 30, 19, 20, 30))); - - value = engine.expression(library, "DateTimeSubtractSecondsUnderflow").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 4, 59))); - - value = engine.expression(library, "DateTimeSubtract5Milliseconds").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2005, 5, 10, 5, 5, 5, 5))); - - value = engine.expression(library, "DateTimeSubtractMillisecondsUnderflow") - .value(); - assertTrue( - EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2016, 6, 10, 5, 5, 4, 999))); - - value = engine.expression(library, "DateTimeSubtract2YearsAsMonths").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012))); - - value = engine.expression(library, "DateTimeSubtract2YearsAsMonthsRem1").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new DateTime(bigDecimalZoneOffset, 2012))); - - value = engine.expression(library, "DateSubtract2YearsAsMonthsRem1").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2012))); - - value = engine.expression(library, "DateSubtract2YearsAsMonths").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2012))); - - value = engine.expression(library, "DateSubtract33Days").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2014, 5))); - - value = engine.expression(library, "DateSubtract1Year").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Date(2013, 6))); - - value = engine.expression(library, "TimeSubtract5Hours").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 59, 59, 999))); - - value = engine.expression(library, "TimeSubtract1Minute").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 58, 59, 999))); - - value = engine.expression(library, "TimeSubtract1Second").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 59, 58, 999))); - - value = engine.expression(library, "TimeSubtract1Millisecond").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(15, 59, 58, 999))); - - value = engine.expression(library, "TimeSubtract5Hours1Minute").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 58, 59, 999))); - - value = engine.expression(library, "TimeSubtract5hoursByMinute").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(10, 59, 59, 999))); - } - - /** - * {@link org.opencds.cqf.cql.engine.elm.execution.TimeEvaluator#evaluate(Context)} - */ - @Test - void time() { - - var value = engine.expression(library, "TimeTest2").value(); - assertTrue(EquivalentEvaluator.equivalent(value, new Time(23, 59, 59, 999))); - } - /** * {@link org.opencds.cqf.cql.engine.elm.execution.TimeOfDayEvaluator#evaluate(Context)} */ @@ -1060,19 +97,6 @@ void timeOfDay() { */ @Test void today() { - - var value = engine.expression(library, "DateTimeSameOrBeforeTodayTrue1").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeTodayTrue2").value(); - assertThat(value, is(true)); - - value = engine.expression(library, "DateTimeSameOrBeforeTodayFalse").value(); - assertThat(value, is(false)); - - value = engine.expression(library, "DateTimeAddTodayTrue").value(); - assertThat(value, is(true)); - // context = new Context(library, new DateTime(TemporalHelper.getDefaultOffset(), 2016, 6, 10, 5, 5, 4, // 999)); // value = engine.expression(library, "Issue34B").value(); diff --git a/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.cql b/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.cql deleted file mode 100644 index a988783a5..000000000 --- a/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlConditionalOperatorsTest.cql +++ /dev/null @@ -1,59 +0,0 @@ -library CqlConditionalOperatorsTest - -define x: 5 -define y: 10 -define z: null - -// if-then-else -define IfTrue1: - if y > x then x else y - -define IfFalse1: - if y = x then y + x else y - x - -define IfNull1: - if y = z then x else y - -// standard case -define StandardCase1: - case - when y > x then x - when x > y then y - else z - end - -define StandardCase2: - case - when x > y then x + y - when x = y then x - else y - x - end - -define StandardCase3: - case - when z ~ y then z + y - when z ~ x then x - else x + y - end - -// selected case -define SelectedCase1: - case x - when 5 then 12 - when 10 then y + x - else y - x - end - -define SelectedCase2: - case y - when 5 then 12 - when 10 then y + x - else y - x - end - -define SelectedCase3: - case y + x - when 5 then 12 - when 10 then y + x - else y - x - end diff --git a/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.cql b/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.cql index 3c1660bea..256abea06 100644 --- a/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.cql +++ b/Src/java/engine/src/test/resources/org/opencds/cqf/cql/engine/execution/CqlDateTimeOperatorsTest.cql @@ -1,354 +1,23 @@ library CqlDateTimeOperatorsTest -//Add -define DateTimeAdd5Years: DateTime(2005, 10, 10) + 5 years -define DateTimeAddInvalidYears: DateTime(2005, 10, 10) + 8000 years -define DateTimeAdd5Months: DateTime(2005, 5, 10) + 5 months -define DateTimeAddMonthsOverflow: DateTime(2005, 5, 10) + 10 months -define DateTimeAddThreeWeeks: DateTime(2018, 5, 2) + 3 weeks -define DateTimeAddYearInWeeks: DateTime(2018, 5, 23) + 52 weeks -define DateTimeAdd5Days: DateTime(2005, 5, 10) + 5 days -define DateTimeAddDaysOverflow: DateTime(2016, 6, 10) + 21 days -define DateTimeAdd5Hours: DateTime(2005, 5, 10, 5) + 5 hours -define DateTimeAdd5HoursWithLeftMinPrecisionSecond: DateTime(2005, 5, 10, 5, 20, 30) + 5 hours -define DateTimeAdd5HoursWithLeftMinPrecisionDay: DateTime(2005, 5, 10) + 5 hours -define DateTimeAdd5HoursWithLeftMinPrecisionDayOverflow: DateTime(2005, 5, 10) + 25 hours -define DateAdd2YearsAsMonths: Date(2014) + 24 months -define DateAdd2YearsAsMonthsRem1: Date(2014) + 25 months -define DateAdd33Days: Date(2014,6) + 33 days -define DateAdd1Year: Date(2014,6) + 1 year -define DateTimeAddHoursOverflow: DateTime(2016, 6, 10, 5) + 19 hours -define DateTimeAdd5Minutes: DateTime(2005, 5, 10, 5, 5) + 5 minutes -define DateTimeAddMinutesOverflow: DateTime(2016, 6, 10, 5, 5) + 55 minutes -define DateTimeAdd5Seconds: DateTime(2005, 5, 10, 5, 5, 5) + 5 seconds -define DateTimeAddSecondsOverflow: DateTime(2016, 6, 10, 5, 5, 5) + 55 seconds -define DateTimeAdd5Milliseconds: DateTime(2005, 5, 10, 5, 5, 5, 5) + 5 milliseconds -define DateTimeAddMillisecondsOverflow: DateTime(2016, 6, 10, 5, 5, 5, 5) + 995 milliseconds -define DateTimeAddLeapYear: DateTime(2012, 2, 29) + 1 year -define DateTimeAdd2YearsByMonths: DateTime(2014) + 24 months -define DateTimeAdd2YearsByDays: DateTime(2014) + 730 days -define DateTimeAdd2YearsByDaysRem5Days: DateTime(2014) + 735 days -define TimeAdd5Hours: @T15:59:59.999 + 5 hours -define TimeAdd1Minute: @T15:59:59.999 + 1 minute -define TimeAdd1Second: @T15:59:59.999 + 1 seconds -define TimeAdd1Millisecond: @T15:59:59.999 + 1 milliseconds -define TimeAdd5Hours1Minute: @T15:59:59.999 + 5 hours + 1 minutes -define TimeAdd5hoursByMinute: @T15:59:59.999 + 300 minutes - -//After -define DateTimeAfterYearTrue: DateTime(2005, 10, 10) after year of DateTime(2004, 10, 10) -define DateTimeAfterYearFalse: DateTime(2004, 11, 10) after year of DateTime(2004, 10, 10) -define DateTimeAfterMonthTrue: DateTime(2004, 12, 10) after month of DateTime(2004, 11, 10) -define DateTimeAfterMonthFalse: DateTime(2004, 9, 10) after month of DateTime(2004, 10, 10) -define DateTimeAfterDayTrue: DateTime(2004, 12, 11) after day of DateTime(2004, 10, 10) -define DateTimeAfterDayTrue2: DateTime(2004, 12, 09) after day of DateTime(2003, 10, 10) -define DateTimeAfterDayFalse: DateTime(2004, 10, 9) after day of DateTime(2004, 10, 10) -define DateTimeAfterHourTrue: DateTime(2004, 10, 10, 10) after hour of DateTime(2004, 10, 10, 5) -define DateTimeAfterHourFalse: DateTime(2004, 10, 10, 20) after hour of DateTime(2004, 10, 10, 21) -define DateTimeAfterMinuteTrue: DateTime(2004, 10, 10, 20, 30) after minute of DateTime(2004, 10, 10, 20, 29) -define DateTimeAfterMinuteFalse: DateTime(2004, 10, 10, 20, 30) after minute of DateTime(2004, 10, 10, 20, 31) -define DateTimeAfterSecondTrue: DateTime(2004, 10, 10, 20, 30, 15) after second of DateTime(2004, 10, 10, 20, 30, 14) -define DateTimeAfterSecondFalse: DateTime(2004, 10, 10, 20, 30, 15) after second of DateTime(2004, 10, 10, 20, 30, 16) -define DateTimeAfterMillisecondTrue: DateTime(2004, 10, 10, 20, 30, 15, 512) after millisecond of DateTime(2004, 10, 10, 20, 30, 15, 510) -define DateTimeAfterMillisecondFalse: DateTime(2004, 10, 10, 20, 30, 15, 512) after millisecond of DateTime(2004, 10, 10, 20, 30, 15, 513) -define DateTimeAfterUncertain: DateTime(2005, 10, 10) after day of DateTime(2005, 9) -define AfterTimezoneTrue: @2012-03-10T10:20:00.999+07:00 after hour of @2012-03-10T08:20:00.999+06:00 -define AfterTimezoneFalse: @2012-03-10T10:20:00.999+07:00 after hour of @2012-03-10T10:20:00.999+06:00 -define TimeAfterHourTrue: @T15:59:59.999 after hour of @T14:59:59.999 -define TimeAfterHourFalse: @T15:59:59.999 after hour of @T16:59:59.999 -define TimeAfterMinuteTrue: @T15:59:59.999 after minute of @T15:58:59.999 -define TimeAfterMinuteFalse: @T15:58:59.999 after minute of @T15:59:59.999 -define TimeAfterSecondTrue: @T15:59:59.999 after second of @T15:59:58.999 -define TimeAfterSecondFalse: @T15:59:58.999 after second of @T15:59:59.999 -define TimeAfterMillisecondTrue: @T15:59:59.999 after millisecond of @T15:59:59.998 -define TimeAfterMillisecondFalse: @T15:59:59.998 after millisecond of @T15:59:59.999 -define TimeAfterTimeCstor: Time(12, 30) after hour of Time(11, 55) -// TODO: do uncertainty tests for Time once the Time(x,x,x,x,x) format has been implemented - -//Before -define DateTimeBeforeYearTrue: DateTime(2003) before year of DateTime(2004, 10, 10) -define DateTimeBeforeYearFalse: DateTime(2004, 11, 10) before year of DateTime(2003, 10, 10) -define DateTimeBeforeMonthTrue: DateTime(2004, 10, 10) before month of DateTime(2004, 11, 10) -define DateTimeBeforeMonthFalse: DateTime(2004, 11, 10) before month of DateTime(2004, 10, 10) -define DateTimeBeforeDayTrue: DateTime(2004, 10, 1) before day of DateTime(2004, 10, 10) -define DateTimeBeforeDayTrue2: DateTime(2003, 10, 11) before day of DateTime(2004, 10, 10) -define DateTimeBeforeDayFalse: DateTime(2004, 10, 11) before day of DateTime(2004, 10, 10) -define DateTimeBeforeHourTrue: DateTime(2004, 10, 10, 1) before hour of DateTime(2004, 10, 10, 5) -define DateTimeBeforeHourFalse: DateTime(2004, 10, 10, 23) before hour of DateTime(2004, 10, 10, 21) -define DateTimeBeforeMinuteTrue: DateTime(2004, 10, 10, 20, 28) before minute of DateTime(2004, 10, 10, 20, 29) -define DateTimeBeforeMinuteFalse: DateTime(2004, 10, 10, 20, 35) before minute of DateTime(2004, 10, 10, 20, 31) -define DateTimeBeforeSecondTrue: DateTime(2004, 10, 10, 20, 30, 12) before second of DateTime(2004, 10, 10, 20, 30, 14) -define DateTimeBeforeSecondFalse: DateTime(2004, 10, 10, 20, 30, 55) before second of DateTime(2004, 10, 10, 20, 30, 16) -define DateTimeBeforeMillisecondTrue: DateTime(2004, 10, 10, 20, 30, 15, 508) before millisecond of DateTime(2004, 10, 10, 20, 30, 15, 510) -define DateTimeBeforeMillisecondFalse: DateTime(2004, 10, 10, 20, 30, 15, 599) before millisecond of DateTime(2004, 10, 10, 20, 30, 15, 513) -define BeforeTimezoneTrue: @2012-03-10T10:20:00.999+07:00 before hour of @2012-03-10T10:20:00.999+06:00 -define BeforeTimezoneFalse: @2012-03-10T10:20:00.999+07:00 before hour of @2012-03-10T09:20:00.999+06:00 -define TimeBeforeHourTrue: @T13:59:59.999 before hour of @T14:59:59.999 -define TimeBeforeHourFalse: @T16:59:59.999 before hour of @T15:59:59.999 -define TimeBeforeMinuteTrue: @T15:57:59.999 before minute of @T15:58:59.999 -define TimeBeforeMinuteFalse: @T15:59:59.999 before minute of @T15:59:59.999 -define TimeBeforeSecondTrue: @T15:59:57.999 before second of @T15:59:58.999 -define TimeBeforeSecondFalse: @T15:59:56.999 before second of @T15:59:55.999 -define TimeBeforeMillisecondTrue: @T15:59:59.997 before millisecond of @T15:59:59.998 -define TimeBeforeMillisecondFalse: @T15:59:59.998 before millisecond of @T15:59:59.997 -// TODO: do uncertainty tests for Time once the Time(x,x,x,x,x) format has been implemented - -//DateTime -define DateTimeYear: DateTime(2003) -define DateTimeMonth: DateTime(2003, 10) -define DateTimeDay: DateTime(2003, 10, 29) -define DateTimeHour: DateTime(2003, 10, 29, 20) -define DateTimeMinute: DateTime(2003, 10, 29, 20, 50) -define DateTimeSecond: DateTime(2003, 10, 29, 20, 50, 33) -define DateTimeMillisecond: DateTime(2003, 10, 29, 20, 50, 33, 955) - -//DateTimeComponentFrom -define DateTimeComponentFromYear: year from DateTime(2003, 10, 29, 20, 50, 33, 955) -define DateTimeComponentFromMonth: month from DateTime(2003, 10, 29, 20, 50, 33, 955) -define DateTimeComponentFromMonthMinBoundary: month from DateTime(2003, 01, 29, 20, 50, 33, 955) -define DateTimeComponentFromDay: day from DateTime(2003, 10, 29, 20, 50, 33, 955) -define DateTimeComponentFromHour: hour from DateTime(2003, 10, 29, 20, 50, 33, 955) -define DateTimeComponentFromMinute: minute from DateTime(2003, 10, 29, 20, 50, 33, 955) -define DateTimeComponentFromSecond: second from DateTime(2003, 10, 29, 20, 50, 33, 955) -define DateTimeComponentFromMillisecond: millisecond from DateTime(2003, 10, 29, 20, 50, 33, 955) -define DateTimeComponentFromTimezone: timezoneoffset from DateTime(2003, 10, 29, 20, 50, 33, 955, 1) -define DateTimeComponentFromDate: date from DateTime(2003, 10, 29, 20, 50, 33, 955, 1) -define TimeComponentFromHour: hour from @T23:20:15.555 -define TimeComponentFromMinute: minute from @T23:20:15.555 -define TimeComponentFromSecond: second from @T23:20:15.555 -define TimeComponentFromMilli: millisecond from @T23:20:15.555 - -//Difference -define DateTimeDifferenceYear: difference in years between DateTime(2000) and DateTime(2005, 12) -define DateTimeDifferenceMonth: difference in months between DateTime(2000, 2) and DateTime(2000, 10) -define DateTimeDifferenceDay: difference in days between DateTime(2000, 10, 15, 10, 30) and DateTime(2000, 10, 25, 10, 0) -define DateTimeDifferenceHour: difference in hours between DateTime(2000, 4, 1, 12) and DateTime(2000, 4, 1, 20) -define DateTimeDifferenceMinute: difference in minutes between DateTime(2005, 12, 10, 5, 16) and DateTime(2005, 12, 10, 5, 25) -define DateTimeDifferenceSecond: difference in seconds between DateTime(2000, 10, 10, 10, 5, 45) and DateTime(2000, 10, 10, 10, 5, 50) -define DateTimeDifferenceMillisecond: difference in milliseconds between DateTime(2000, 10, 10, 10, 5, 45, 500, -6.0) and DateTime(2000, 10, 10, 10, 5, 45, 900, -7.0) -define DateTimeDifferenceWeeks: difference in weeks between DateTime(2000, 10, 15) and DateTime(2000, 10, 28) -define DateTimeDifferenceWeeks2: difference in weeks between DateTime(2000, 10, 15) and DateTime(2000, 10, 29) -define DateTimeDifferenceWeeks3: difference in weeks between @2012-03-10T22:05:09 and @2012-03-24T07:19:33 -define DateTimeDifferenceNegative: difference in years between DateTime(2016) and DateTime(1998) -define DateTimeDifferenceUncertain: difference in months between DateTime(2005) and DateTime(2006, 7) > 5 -define TimeDifferenceHour: difference in hours between @T20 and @T23:25:15.555 -define TimeDifferenceMinute: difference in minutes between @T20:20:15.555 and @T20:25:15.555 -define TimeDifferenceSecond: difference in seconds between @T20:20:15.555 and @T20:20:20.555 -define TimeDifferenceMillis: difference in milliseconds between @T20:20:15.555 and @T20:20:15.550 - -// From Github issue #29 -define DateTimeA: @2017-03-12T01:00:00-07:00 // March 12, 2017, 1:00 AM MST -define DateTimeAA: DateTime(2017, 3, 12, 1, 0, 0, 0, -7.0) -define DateTimeB: @2017-03-12T03:00:00-06:00 // 3:00 AM MDT -define DateTimeBB: DateTime(2017, 3, 12, 3, 0, 0, 0, -6.0) -define DateTimeC: @2017-11-05T01:30:00-06:00 // November 5, 2017, 1:30 AM MDT -define DateTimeCC: DateTime(2017, 11, 5, 1, 30, 0, 0, -6.0) -define DateTimeD: @2017-11-05T01:15:00-07:00 // November 5, 2017, 1:15 AM MST -define DateTimeDD: DateTime(2017, 11, 5, 1, 15, 0, 0, -7.0) -define DateTimeE: @2017-03-12T00:00:00-07:00 // March 12, 2017 -define DateTimeEE: DateTime(2017, 3, 12, 0, 0, 0, 0, -7.0) -define DateTimeF: @2017-03-13T00:00:00-06:00 // March 13, 2017 -define DateTimeFF: DateTime(2017, 3, 13, 0, 0, 0, 0, -6.0) - -define DifferenceInHoursA: difference in hours between DateTimeA and DateTimeB // Should be 1 -define DifferenceInMinutesA: difference in minutes between DateTimeC and DateTimeD // Should be 45 -define DifferenceInDaysA: difference in days between DateTimeE and DateTimeF // Should be 1 -define DifferenceInHoursAA: difference in hours between DateTimeAA and DateTimeBB // Should be 1 -define DifferenceInMinutesAA: difference in minutes between DateTimeCC and DateTimeDD // Should be 45 -define DifferenceInDaysAA: difference in days between DateTimeEE and DateTimeFF // Should be 1 -// TODO: Time uncertainty tests - //Duration define DateTimeDurationBetweenYear: years between DateTime(2005) and DateTime(2010) -define DateTimeDurationBetweenYearOffset: years between DateTime(2005, 5) and DateTime(2010, 4) -define DateTimeDurationBetweenMonth: months between DateTime(2014, 1, 31) and DateTime(2014, 2, 1) -define DateTimeDurationBetweenDaysDiffYears: days between DateTime(2010, 10, 12, 12, 5) and DateTime(2008, 8, 15, 8, 8) + // Uncertainty tests define DateTimeDurationBetweenUncertainInterval: days between DateTime(2014, 1, 15) and DateTime(2014, 2) define DateTimeDurationBetweenUncertainInterval2: months between DateTime(2005) and DateTime(2006, 5) define DateTimeDurationBetweenUncertainAdd: DateTimeDurationBetweenUncertainInterval + DateTimeDurationBetweenUncertainInterval define DateTimeDurationBetweenUncertainSubtract: DateTimeDurationBetweenUncertainInterval - DateTimeDurationBetweenUncertainInterval2 define DateTimeDurationBetweenUncertainMultiply: DateTimeDurationBetweenUncertainInterval * DateTimeDurationBetweenUncertainInterval -define DateTimeDurationBetweenUncertainDiv: DateTimeDurationBetweenUncertainInterval div DateTimeDurationBetweenUncertainInterval2 -define DateTimeDurationBetweenMonthUncertain: months between DateTime(2005) and DateTime(2006, 7) > 5 -define DateTimeDurationBetweenMonthUncertain2: months between DateTime(2005) and DateTime(2006, 2) > 5 -define DateTimeDurationBetweenMonthUncertain3: months between DateTime(2005) and DateTime(2006, 7) > 25 -define DateTimeDurationBetweenMonthUncertain4: months between DateTime(2005) and DateTime(2006, 7) < 24 -define DateTimeDurationBetweenMonthUncertain5: months between DateTime(2005) and DateTime(2006, 7) = 24 -define DateTimeDurationBetweenMonthUncertain6: months between DateTime(2005) and DateTime(2006, 7) >= 5 -define DateTimeDurationBetweenMonthUncertain7: months between DateTime(2005) and DateTime(2006, 7) <= 24 - -define DateTime1: @2012-03-10T10:20:00 -define DateTime2: @2013-03-10T09:20:00 -define DurationInYears: years between (date from DateTime1) and (date from DateTime2) -define DurationInWeeks: weeks between @2012-03-10T22:05:09 and @2012-03-20T07:19:33 -define DurationInWeeks2: weeks between @2012-03-10T22:05:09 and @2012-03-24T07:19:33 -define DurationInWeeks3: weeks between @2012-03-10T06:05:09 and @2012-03-24T07:19:33 +define DurationInDaysA: days between @2017-03-12T00:00:00-07:00 and @2017-03-13T00:00:00-06:00 // Should be 1 +define DurationInDaysAA: days between DateTime(2017, 3, 12, 0, 0, 0, 0, -7.0) and DateTime(2017, 3, 13, 0, 0, 0, 0, -6.0) // Should be 1 -define TimeDurationBetweenHour: hours between @T20:26:15.555 and @T23:25:15.555 -define TimeDurationBetweenHourDiffPrecision: hours between @T06 and @T07:00:00 -define TimeDurationBetweenMinute: minutes between @T23:20:16.555 and @T23:25:15.555 -define TimeDurationBetweenSecond: seconds between @T23:25:10.556 and @T23:25:15.555 -define TimeDurationBetweenMillis: milliseconds between @T23:25:25.555 and @T23:25:25.560 -// TODO: Time uncertainty tests - -define DurationInHoursA: hours between DateTimeA and DateTimeB // Should be 1 -define DurationInMinutesA: minutes between DateTimeC and DateTimeD // Should be 45 -define DurationInDaysA: days between DateTimeE and DateTimeF // Should be 1 -define DurationInHoursAA: hours between DateTimeAA and DateTimeBB // Should be 1 -define DurationInMinutesAA: minutes between DateTimeCC and DateTimeDD // Should be 45 -define DurationInDaysAA: days between DateTimeEE and DateTimeFF // Should be 1 //Now -define DateTimeNow: Now() = Now() define Issue34A: Now() -//SameAs -define DateTimeSameAsYearTrue: DateTime(2014) same year as DateTime(2014) -define DateTimeSameAsYearFalse: DateTime(2013) same year as DateTime(2014) -define DateTimeSameAsMonthTrue: DateTime(2014, 12) same month as DateTime(2014, 12) -define DateTimeSameAsMonthFalse: DateTime(2014, 12) same month as DateTime(2014, 10) -define DateTimeSameAsDayTrue: DateTime(2014, 12, 10) same day as DateTime(2014, 12, 10) -define DateTimeSameAsDayFalse: DateTime(2014, 10, 10) same day as DateTime(2014, 10, 11) -define DateTimeSameAsHourTrue: DateTime(2014, 12, 10, 20) same hour as DateTime(2014, 12, 10, 20) -define DateTimeSameAsHourFalse: DateTime(2014, 10, 10, 20) same hour as DateTime(2014, 10, 10, 21) -define DateTimeSameAsMinuteTrue: DateTime(2014, 12, 10, 20, 55) same minute as DateTime(2014, 12, 10, 20, 55) -define DateTimeSameAsMinuteFalse: DateTime(2014, 10, 10, 20, 55) same minute as DateTime(2014, 10, 10, 21, 56) -define DateTimeSameAsSecondTrue: DateTime(2014, 12, 10, 20, 55, 45) same second as DateTime(2014, 12, 10, 20, 55, 45) -define DateTimeSameAsSecondFalse: DateTime(2014, 10, 10, 20, 55, 45) same second as DateTime(2014, 10, 10, 21, 55, 44) -define DateTimeSameAsMillisecondTrue: DateTime(2014, 12, 10, 20, 55, 45, 500) same millisecond as DateTime(2014, 12, 10, 20, 55, 45, 500) -define DateTimeSameAsMillisecondFalse: DateTime(2014, 10, 10, 20, 55, 45, 500) same millisecond as DateTime(2014, 10, 10, 21, 55, 45, 501) -define DateTimeSameAsNull: DateTime(2014, 10) same day as DateTime(2014, 10, 12) -define SameAsTimezoneTrue: @2012-03-10T10:20:00.999+07:00 same hour as @2012-03-10T09:20:00.999+06:00 -define SameAsTimezoneFalse: @2012-03-10T10:20:00.999+07:00 same hour as @2012-03-10T10:20:00.999+06:00 -define TimeSameAsHourTrue: @T23:25:25.555 same hour as @T23:55:25.900 -define TimeSameAsHourFalse: @T22:25:25.555 same hour as @T23:25:25.555 -define TimeSameAsMinuteTrue: @T23:55:22.555 same minute as @T23:55:25.900 -define TimeSameAsMinuteFalse: @T23:26:25.555 same minute as @T23:25:25.555 -define TimeSameAsSecondTrue: @T23:55:25.555 same second as @T23:55:25.900 -define TimeSameAsSecondFalse: @T23:25:35.555 same second as @T23:25:25.555 -define TimeSameAsMillisTrue: @T23:55:25.555 same millisecond as @T23:55:25.555 -define TimeSameAsMillisFalse: @T23:25:25.555 same millisecond as @T23:25:25.554 - -//SameOrAfter -define DateTimeSameOrAfterYearTrue1: DateTime(2014) same year or after DateTime(2014) -define DateTimeSameOrAfterYearTrue2: DateTime(2016) same year or after DateTime(2014) -define DateTimeSameOrAfterYearFalse: DateTime(2013) same year or after DateTime(2014) -define DateTimeSameOrAfterMonthTrue1: DateTime(2014, 12) same month or after DateTime(2014, 12) -define DateTimeSameOrAfterMonthTrue2: DateTime(2014, 10) same month or after DateTime(2014, 9) -define DateTimeSameOrAfterMonthFalse: DateTime(2014, 10) same month or after DateTime(2014, 11) -define DateTimeSameOrAfterDayTrue1: DateTime(2014, 12, 20) same day or after DateTime(2014, 12, 20) -define DateTimeSameOrAfterDayTrue2: DateTime(2014, 10, 25) same day or after DateTime(2014, 10, 20) -define DateTimeSameOrAfterDayFalse: DateTime(2014, 10, 20) same day or after DateTime(2014, 10, 25) -define DateTimeSameOrAfterHourTrue1: DateTime(2014, 12, 20, 12) same hour or after DateTime(2014, 12, 20, 12) -define DateTimeSameOrAfterHourTrue2: DateTime(2014, 10, 25, 12) same hour or after DateTime(2014, 10, 25, 10) -define DateTimeSameOrAfterHourFalse: DateTime(2014, 10, 25, 12) same hour or after DateTime(2014, 10, 25, 15) -define DateTimeSameOrAfterMinuteTrue1: DateTime(2014, 12, 20, 12, 30) same minute or after DateTime(2014, 12, 20, 12, 30) -define DateTimeSameOrAfterMinuteTrue2: DateTime(2014, 10, 25, 10, 30) same minute or after DateTime(2014, 10, 25, 10, 25) -define DateTimeSameOrAfterMinuteFalse: DateTime(2014, 10, 25, 15, 30) same minute or after DateTime(2014, 10, 25, 15, 45) -define DateTimeSameOrAfterSecondTrue1: DateTime(2014, 12, 20, 12, 30, 15) same second or after DateTime(2014, 12, 20, 12, 30, 15) -define DateTimeSameOrAfterSecondTrue2: DateTime(2014, 10, 25, 10, 25, 25) same second or after DateTime(2014, 10, 25, 10, 25, 20) -define DateTimeSameOrAfterSecondFalse: DateTime(2014, 10, 25, 15, 45, 20) same second or after DateTime(2014, 10, 25, 15, 45, 21) -define DateTimeSameOrAfterMillisecondTrue1: DateTime(2014, 12, 20, 12, 30, 15, 250) same millisecond or after DateTime(2014, 12, 20, 12, 30, 15, 250) -define DateTimeSameOrAfterMillisecondTrue2: DateTime(2014, 10, 25, 10, 25, 20, 500) same millisecond or after DateTime(2014, 10, 25, 10, 25, 20, 499) -define DateTimeSameOrAfterMillisecondFalse: DateTime(2014, 10, 25, 15, 45, 20, 500) same millisecond or after DateTime(2014, 10, 25, 15, 45, 20, 501) -define DateTimeSameOrAfterNull1: DateTime(2014, 12, 20) same day or after DateTime(2014, 12) -define SameOrAfterTimezoneTrue: @2012-03-10T10:20:00.999+07:00 same hour or after @2012-03-10T09:20:00.999+06:00 -define SameOrAfterTimezoneFalse: @2012-03-10T10:20:00.999+07:00 same hour or after @2012-03-10T10:20:00.999+06:00 -define TimeSameOrAfterHourTrue1: @T23:25:25.555 same hour or after @T23:55:25.900 -define TimeSameOrAfterHourTrue2: @T23:25:25.555 same hour or after @T22:55:25.900 -define TimeSameOrAfterHourFalse: @T22:25:25.555 same hour or after @T23:55:25.900 -define TimeSameOrAfterMinuteTrue1: @T23:25:25.555 same minute or after @T23:25:25.900 -define TimeSameOrAfterMinuteTrue2: @T23:25:25.555 same minute or after @T22:15:25.900 -define TimeSameOrAfterMinuteFalse: @T23:25:25.555 same minute or after @T23:55:25.900 -define TimeSameOrAfterSecondTrue1: @T23:25:25.555 same second or after @T23:25:25.900 -define TimeSameOrAfterSecondTrue2: @T23:25:35.555 same second or after @T22:25:25.900 -define TimeSameOrAfterSecondFalse: @T23:55:25.555 same second or after @T23:55:35.900 -define TimeSameOrAfterMillisTrue1: @T23:25:25.555 same millisecond or after @T23:25:25.555 -define TimeSameOrAfterMillisTrue2: @T23:25:25.555 same millisecond or after @T22:25:25.550 -define TimeSameOrAfterMillisFalse: @T23:55:25.555 same millisecond or after @T23:55:25.900 -define OnOrAfterTrue: @2017-12-20T11:00:00.000 on or after @2017-12-20T11:00:00.000 -define Issue32DateTime: @2017-12-21T02:00:00.0 same or after @2017-12-20T11:00:00.0 - -//SameOrBefore -define DateTimeSameOrBeforeYearTrue1: DateTime(2014) same year or before DateTime(2014) -define DateTimeSameOrBeforeYearTrue2: DateTime(2013) same year or before DateTime(2014) -define DateTimeSameOrBeforeYearFalse: DateTime(2015) same year or before DateTime(2014) -define DateTimeSameOrBeforeMonthTrue1: DateTime(2014, 12) same month or before DateTime(2014, 12) -define DateTimeSameOrBeforeMonthTrue2: DateTime(2014, 8) same month or before DateTime(2014, 9) -define DateTimeSameOrBeforeMonthFalse: DateTime(2014, 12) same month or before DateTime(2014, 11) -define DateTimeSameOrBeforeDayTrue1: DateTime(2014, 12, 20) same day or before DateTime(2014, 12, 20) -define DateTimeSameOrBeforeDayTrue2: DateTime(2014, 10, 15) same day or before DateTime(2014, 10, 20) -define DateTimeSameOrBeforeDayFalse: DateTime(2014, 10, 30) same day or before DateTime(2014, 10, 25) -define DateTimeSameOrBeforeHourTrue1: DateTime(2014, 12, 20, 12) same hour or before DateTime(2014, 12, 20, 12) -define DateTimeSameOrBeforeHourTrue2: DateTime(2014, 10, 25, 5) same hour or before DateTime(2014, 10, 25, 10) -define DateTimeSameOrBeforeHourFalse: DateTime(2014, 10, 25, 20) same hour or before DateTime(2014, 10, 25, 15) -define DateTimeSameOrBeforeMinuteTrue1: DateTime(2014, 12, 20, 12, 30) same minute or before DateTime(2014, 12, 20, 12, 30) -define DateTimeSameOrBeforeMinuteTrue2: DateTime(2014, 10, 25, 10, 20) same minute or before DateTime(2014, 10, 25, 10, 25) -define DateTimeSameOrBeforeMinuteFalse: DateTime(2014, 10, 25, 15, 55) same minute or before DateTime(2014, 10, 25, 15, 45) -define DateTimeSameOrBeforeSecondTrue1: DateTime(2014, 12, 20, 12, 30, 15) same second or before DateTime(2014, 12, 20, 12, 30, 15) -define DateTimeSameOrBeforeSecondTrue2: DateTime(2014, 10, 25, 10, 25, 15) same second or before DateTime(2014, 10, 25, 10, 25, 20) -define DateTimeSameOrBeforeSecondFalse: DateTime(2014, 10, 25, 15, 45, 25) same second or before DateTime(2014, 10, 25, 15, 45, 21) -define DateTimeSameOrBeforeMillisecondTrue1: DateTime(2014, 12, 20, 12, 30, 15, 250) same millisecond or before DateTime(2014, 12, 20, 12, 30, 15, 250) -define DateTimeSameOrBeforeMillisecondTrue2: DateTime(2014, 10, 25, 10, 25, 20, 450) same millisecond or before DateTime(2014, 10, 25, 10, 25, 20, 499) -define DateTimeSameOrBeforeMillisecondFalse: DateTime(2014, 10, 25, 15, 45, 20, 505) same millisecond or before DateTime(2014, 10, 25, 15, 45, 20, 501) -define DateTimeSameOrBeforeNull1: DateTime(2014, 12, 20) same minute or before DateTime(2014, 12, 20, 15) -define SameOrBeforeTimezoneTrue: @2012-03-10T09:20:00.999+07:00 same hour or before @2012-03-10T10:20:00.999+06:00 -define SameOrBeforeTimezoneFalse: @2012-03-10T10:20:00.999+06:00 same hour or before @2012-03-10T10:20:00.999+07:00 -define TimeSameOrBeforeHourTrue1: @T23:25:25.555 same hour or before @T23:55:25.900 -define TimeSameOrBeforeHourFalse0: @T21:25:25.555 same hour or before @T22:55:25.900 -define TimeSameOrBeforeHourFalse: @T22:25:25.555 same hour or before @T21:55:25.900 -define TimeSameOrBeforeMinuteTrue1: @T23:25:25.555 same minute or before @T23:25:25.900 -define TimeSameOrBeforeMinuteFalse0: @T23:10:25.555 same minute or before @T22:15:25.900 -define TimeSameOrBeforeMinuteFalse: @T23:56:25.555 same minute or before @T23:55:25.900 -define TimeSameOrBeforeSecondTrue1: @T23:25:25.555 same second or before @T23:25:25.900 -define TimeSameOrBeforeSecondFalse0: @T23:25:35.555 same second or before @T22:25:45.900 -define TimeSameOrBeforeSecondFalse: @T23:55:45.555 same second or before @T23:55:35.900 -define TimeSameOrBeforeMillisTrue1: @T23:25:25.555 same millisecond or before @T23:25:25.555 -define TimeSameOrBeforeMillisTrue2: @T23:25:25.200 same millisecond or before @T22:25:25.550 -define TimeSameOrBeforeMillisFalse: @T23:55:25.966 same millisecond or before @T23:55:25.900 - -//Subtract -define DateTimeSubtract5Years: DateTime(2005, 10, 10) - 5 years -define DateTimeSubtractInvalidYears: DateTime(2005, 10, 10) - 2005 years -define DateTimeSubtract5Months: DateTime(2005, 6, 10) - 5 months -define DateTimeSubtractMonthsUnderflow: DateTime(2005, 5, 10) - 6 months -define DateTimeSubtractThreeWeeks: DateTime(2018, 5, 23) - 3 weeks -define DateTimeSubtractYearInWeeks: DateTime(2018, 5, 23) - 52 weeks -define DateTimeSubtract5Days: DateTime(2005, 5, 10) - 5 days -define DateTimeSubtractDaysUnderflow: DateTime(2016, 6, 10) - 11 days -define DateTimeSubtract5Hours: DateTime(2005, 5, 10, 10) - 5 hours -define DateTimeSubtractHoursUnderflow: DateTime(2016, 6, 10, 5) - 6 hours -define DateTimeSubtract5Minutes: DateTime(2005, 5, 10, 5, 10) - 5 minutes -define DateTimeSubtractMinutesUnderflow: DateTime(2016, 6, 10, 5, 5) - 6 minutes -define DateTimeSubtract5Seconds: DateTime(2005, 5, 10, 5, 5, 10) - 5 seconds -define DateTimeSubtract1YearInSeconds: DateTime(2016,5) - 31535999 seconds -define DateTimeSubtract15HourPrecisionSecond: DateTime(2016, 10, 1, 10, 20, 30) - 15 hours -define DateTimeSubtractSecondsUnderflow: DateTime(2016, 6, 10, 5, 5, 5) - 6 seconds -define DateTimeSubtract5Milliseconds: DateTime(2005, 5, 10, 5, 5, 5, 10) - 5 milliseconds -define DateTimeSubtractMillisecondsUnderflow: DateTime(2016, 6, 10, 5, 5, 5, 5) - 6 milliseconds -define DateTimeSubtract2YearsAsMonths: DateTime(2014) - 24 months -define DateTimeSubtract2YearsAsMonthsRem1: DateTime(2014) - 25 months -define DateSubtract2YearsAsMonths: Date(2014) - 24 months -define DateSubtract2YearsAsMonthsRem1: Date(2014) - 25 months -define DateSubtract33Days: Date(2014,6) - 33 days -define DateSubtract1Year: Date(2014,6) - 1 year -define TimeSubtract5Hours: @T15:59:59.999 - 5 hours -define TimeSubtract1Minute: @T15:59:59.999 - 1 minutes -define TimeSubtract1Second: @T15:59:59.999 - 1 seconds -define TimeSubtract1Millisecond: @T15:59:59.0 - 1 milliseconds -define TimeSubtract5Hours1Minute: @T15:59:59.999 - 5 hours - 1 minutes -define TimeSubtract5hoursByMinute: @T15:59:59.999 - 300 minutes - -//Time -define TimeTest2: @T23:59:59.999 - //TimeOfDay define TimeOfDayTest: TimeOfDay() //Today -define DateTimeSameOrBeforeTodayTrue1: Today() same day or before Today() -define DateTimeSameOrBeforeTodayTrue2: Today() same day or before Today() + 1 days -define DateTimeSameOrBeforeTodayFalse: Today() + 1 years same day or before Today() -define DateTimeAddTodayTrue: Today() + 1 days > Today() define Issue34B: Today() \ No newline at end of file